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

Remove "if else" statements which is slower by nearly 7 times compared to HashMaps in generated MessageCracker class #577

Open
busy-spin opened this issue Nov 20, 2022 · 1 comment · May be fixed by #578
Labels

Comments

@busy-spin
Copy link
Contributor

busy-spin commented Nov 20, 2022

Describe the bug
MessageCracker generated class contains a lengthy if else statement to resolve the method call for the respective message type.
Current logic is about 7 times slower than using HashMap key'd by message type and value as the method reference.

I wrote a new MessageCracker.xsl which use the HashMap to resolve the method respective to message type.

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

Expected behavior
N/A

system information:

  • OS: [Windows11]
  • Java version [JDK8]
  • QFJ Version [3.0.0-SNAPSHOT]

Additional context
N/A

@busy-spin busy-spin added the bug label Nov 20, 2022
busy-spin added a commit to busy-spin/quickfixj that referenced this issue Nov 20, 2022
@busy-spin busy-spin linked a pull request Nov 20, 2022 that will close this issue
@busy-spin
Copy link
Contributor Author

I made a PR for this , #578

@busy-spin busy-spin changed the title Remove "if else" statements which is slower by nearly 7 time compared to HashMaps in generated MessageCracker class Remove "if else" statements which is slower by nearly 7 times compared to HashMaps in generated MessageCracker class Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant