Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use static dispatch for onMessage() methods in ITCHHandler class. #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dingobye
Copy link
Contributor

@dingobye dingobye commented Nov 6, 2019

Hi, Ivan @chronoxor

After playing around with this platform, I noticed that the current design of ITCHHandler class falls in the traditional polymorphism (i.e., via dynamic dispatch). This can be inefficient when frequent calling virtual functions. This patch applies static polymorphism with CRTP (curiously recurring template pattern), and thus improves the performance of ITCH message latency.

The benchmark environment is following:

CPU: Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz
Cache:  32KB L1-d, 32KB L1-i, 256KB L2, 6MB L3
OS: macOS 10.14.6
Input Data Feed: 07302019.NASDAQ_ITCH50

The experiments are repeated 5 times for each scenario and the results of ITCH message latency are shown below.

benchmark ITCH message latency mean (ns) speedup
master this patch
itch_handler 20.8 15.4 1.35x
market_manager 357.8 320.4 1.12x
market_manager_optimized 101.8 84.4 1.21x
market_manager_optimized_aggressive 118.2 97.6 1.21x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant