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

MessageCracker.xsl optimization using HashMap #578

Merged

Conversation

busy-spin
Copy link
Contributor

@busy-spin busy-spin commented Nov 20, 2022

Fixes #577

@busy-spin
Copy link
Contributor Author

busy-spin commented Nov 20, 2022

Following is the JMH benchmarking results.

Before:

benchmarkCrackingGenerated - use the current MessageCracker.xls generated class
benchmarkCrackingWithHashMap use custom MessageCracker class which use HashMaps to resolve methods

Benchmark Mode Cnt Score Error Units
MessageCrackerBenchmark.benchmarkCrackingGenerated thrpt 5 10923194.106 ± 2861197.934 ops/s
MessageCrackerBenchmark.benchmarkCrackingWithHashMap thrpt 5 69723897.515 ± 3242125.694 ops/s

After:

benchmarkCrackingGenerated - use the new MessageCracker.xls generated class
benchmarkCrackingWithHashMap use custom MessageCracker class which use HashMaps to resolve methods

Benchmark Mode Cnt Score Error Units
MessageCrackerBenchmark.benchmarkCrackingGenerated thrpt 5 71897498.754 ± 19147681.365 ops/s
MessageCrackerBenchmark.benchmarkCrackingWithHashMap thrpt 5 72165054.010 ± 4905711.116 ops/s

To Reproduce
Run my JMH benchmark code in my forked repo for QFJ

Before

Before Code Benchmark

After

After Code Benchmark

@chrjohn chrjohn added this to the QFJ 3.0.0 milestone Dec 30, 2023
@chrjohn
Copy link
Member

chrjohn commented Dec 30, 2023

@chrjohn need to check if new code generator for FIX Latest can benefit from this.

@mrFloony
Copy link

hi, I implemented my version of MessageCracker based on HashMap, and he showed a deterioration in processing speed (~30 ms difference compared to If-Else on one message). The replacement with a Switch turned out to be a little faster (a gain of ~15 ms with the same parameters). Tested on a pre-battle stand (with slightly reduced parameters of the virtual machine and allocated memory), as a result, the implementation on the Switch went to the product stand (three weeks - normal flight)
Therefore, I would rather replace the basic MessageCracker with an implementation from Switch

@chrjohn
Copy link
Member

chrjohn commented Dec 30, 2023

@mrFloony thanks for your comment. Are you maybe able to create a benchmark as linked in #578 (comment) or as used in the quickfixj-perf-test module #582

@busy-spin
Copy link
Contributor Author

hi @mrFloony

Can let me know more details about your test. 30ms or 15ms for cracking message seems quiet high. Even the if-else approach is much faster than that. Do you have similar JMH test for this.

@busy-spin
Copy link
Contributor Author

@chrjohn need to check if new code generator for FIX Latest can benefit from this.

Can let me know more details about this, I should be able to update my test. And also add comparison with switch statement vs hash map also.

@chrjohn chrjohn changed the title MessageCracker.xsl optimization using hash map. Issue #577 MessageCracker.xsl optimization using HashMap May 29, 2024
@chrjohn
Copy link
Member

chrjohn commented May 29, 2024

@chrjohn need to check if new code generator for FIX Latest can benefit from this.

Can let me know more details about this, I should be able to update my test. And also add comparison with switch statement vs hash map also.

Actually this is in a different project which generates the classes from orchestrations: https://github.com/quickfix-j/quickfixj-orchestra/blob/fac2493c93f79e21ffcb3cb67cc25459dc2f467d/quickfixj-from-fix-orchestra-repository/quickfixj-from-fix-orchestra-generator/src/main/java/org/quickfixj/orchestra/CodeGeneratorJ.java#L577

@chrjohn chrjohn merged commit 9c7877e into quickfix-j:master Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants