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

ExpressionRef Library context_values performance issue #329

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

Conversation

AymericGrassart
Copy link

@AymericGrassart AymericGrassart commented Dec 4, 2024

A performance slowdown has been identified when executing referenced CQL statements under certain conditions.

Assumptions

  • Execution results of ExpressionDef expressions are cached in their library context.
  • ExpressionRef expressions use those cached results.

Issue

The CQL below performs in a degraded, non-cached way. We suspect the wrong context is used to store or lookup the cached context values when ExpressionRefs cross library contexts.

Test

CommonLib3:

library Common3
using Simple version '1.0.0'
context Patient

define function ExpensiveFunction():
  First(expand Interval[1, 100000])

define ExpensiveStatement:
  ExpensiveFunction()

define ExpensiveStatementRef:
  ExpensiveStatement union 
  ExpensiveStatement union 
  ExpensiveStatement union 
  ExpensiveStatement union 
  ExpensiveStatement

Using CommonLib3:

using Simple version '1.0.0'
include Common3 called common3
context Patient

define ExpensiveStatementRef: common3.ExpensiveStatementRef

The result of the library-test shows the perf degradation as if ExpensiveStatement was not being cached:

$ npm test

  CommonLib3
    ✔ should be able to execute an expensive expression (123ms)

  Using CommonLib3
    ✔ should execute expression from included library at similar cost (565ms)
    ✔ should execute expression directly from included library at similar cost (291ms)

Solution

?

Please note there are no changes to src code, only tests were added to demonstrate the perf issue. Looking for feedback.

We hope that a fix can be identified and included with this PR.

Pull requests into cql-execution require the following.
Submitter and reviewer should ✔ when done.
For items that are not-applicable, mark "N/A" and ✔.

Submitter:

  • This pull request describes why these changes were made
  • Code diff has been done and been reviewed (it does not contain: additional white space, not applicable code changes, debug statements, etc.)
  • Tests are included and test edge cases
  • Tests have been run locally and pass
  • Code coverage has not gone down and all code touched or added is covered.
  • Code passes lint and prettier (hint: use npm run test:plus to run tests, lint, and prettier)
  • All dependent libraries are appropriately updated or have a corresponding PR related to this change
  • cql4browsers.js built with npm run build:browserify if source changed.

Reviewer:

Name:

  • Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose
  • The tests appropriately test the new code, including edge cases
  • You have tried to break the code

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