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

Fix performance issue with CaseSensitivity enabled #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aviita
Copy link

@aviita aviita commented Aug 10, 2021

When CaseSensitive is set to true from JaceOptions, performance should
be significantly better than without case sensitivity. Case sensitivity
setting was not passed to FunctionRegistry and ConstantRegistry
constructors, which caused them to do extra lower case conversions in
case variable dictionary was passed to the formula. Fixes issue #75.

New benchmark was created to verify the fix. Benchmark needs to have
variables which are provided to CalculationEngine.Calculate(), so
VerifyVariableNames() gets called, which causes the extra calls to
ToLowerFast().

Below results show ~200 ms improvement when Case Sensitive is true.
Results table was created by running benchmark separately with
and without fix and copying results to one table.

Engine Case Sensitive Formula Total Iteration Total Duration (fix) Total Duration (no fix)
Interpreted False something2 - (var1 + var2 * 3)/(2+3) 1000000 00:00:01.6005267 00:00:01.5919016
Interpreted True something2 - (var1 + var2 * 3)/(2+3) 1000000 00:00:00.6069845 00:00:00.8390435
Compiled False something2 - (var1 + var2 * 3)/(2+3) 1000000 00:00:01.5865326 00:00:01.5770084
Compiled True something2 - (var1 + var2 * 3)/(2+3) 1000000 00:00:00.5930012 00:00:00.8189981

Additionally:

  • Unit test which tests case sensitivity enabled throws when variable
    case does not match
  • Benchmark uses dictionary copy constructor to avoid throwing due to
    dictionary being modified with constants and then failing on
    VerifyVariableNames().

When CaseSensitive is set to true from JaceOptions, performance should
be significantly better than without case sensitivity. Case sensitivity
setting was not passed to `FunctionRegistry` and `ConstantRegistry`
constructors, which caused them to do extra lower case conversions in
case variable dictionary was passed to the formula. Fixes [issue pieterderycke#75][1].

New benchmark was created to verify the fix. Benchmark needs to have
variables which are provided to `CalculationEngine.Calculate()`, so
VerifyVariableNames() gets called, which causes the extra calls to
`ToLowerFast()`.

Below results show ~200 ms improvement when Case Sensitive is true.
Results table was created by running benchmark separately with
and without fix and copying results to one table.

| Engine     | Case Sensitive | Formula | Total Iteration | Total Duration (fix)   | Total Duration (no fix) |
|------------|----------------|---------|-----------------|------------------------|-------------------------|
| Interpreted |False |something2 - (var1 + var2 * 3)/(2+3) |1000000|00:00:01.6005267|00:00:01.5919016 |
| Interpreted |True  |something2 - (var1 + var2 * 3)/(2+3) |1000000|00:00:00.6069845|00:00:00.8390435 |
| Compiled    |False |something2 - (var1 + var2 * 3)/(2+3) |1000000|00:00:01.5865326|00:00:01.5770084 |
| Compiled    |True  |something2 - (var1 + var2 * 3)/(2+3) |1000000|00:00:00.5930012|00:00:00.8189981 |

Additionally:
- Unit test which tests case sensitivity enabled throws when variable
  case does not match
- Benchmark uses dictionary copy constructor to avoid throwing due to
  dictionary being modified with constants and then failing on
  `VerifyVariableNames()`.

[1]: pieterderycke#75
@aviita
Copy link
Author

aviita commented Sep 2, 2021

@pieterderycke Any chance of getting this merged?

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