fedjabosnic / hotfix

Low latency fix engine for .net
GNU Lesser General Public License v3.0
16 stars 5 forks source link

Method inlining performance gains #1

Open fedjabosnic opened 7 years ago

fedjabosnic commented 7 years ago

Method inlining in C# (see https://www.dotnetperls.com/inline-optimization and https://www.dotnetperls.com/aggressiveinlining) can drastically improve performance in respect of latency/throughput.

For example, for the Message.Parse method, inlining the private methods ParseField, ParseTag and ParseValue improves the latency and throughput quite dramatically:

Parsing a real-world FIX message of length 1000 with 90 fields:

Methodology Latency Throughput
Original 3.22 us 309,000 /s
Inlined 2.02 us 494,000 /s

Because of the drastic improvements that are possible, we should remember to revisit code on the hot path and verify whether it is worth inlining method/function calls for performance improvements...