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

FML transform getting very slow for growing/large lists #1699

Open
mrunibe opened this issue Jul 23, 2024 · 0 comments
Open

FML transform getting very slow for growing/large lists #1699

mrunibe opened this issue Jul 23, 2024 · 0 comments
Labels

Comments

@mrunibe
Copy link
Contributor

mrunibe commented Jul 23, 2024

We have noticed that the FML transform is getting very slow if it is used with a large number of elements (target has an element with many children). I could reproduce it with a simple dummy testcase: A bundle with a large number of observations.

Runtimes for the transformations (time measured just for the transform() without loading resources):

# Elements Time [s]
10 0.2
100 0.5
1000 2
10000 64
20000 250
100000 5316

The approx. quadratic increase of runtime is caused by the recursive call to numberChildren() for every child that is created with makeElement(). For every element that is added, the entire list of children is recursively re-numbered every time.

profiler

With a workaround by disabling the numberChildren (mrunibe@a0f67d4), the performance becomes linear again:

# Elements Time [s] Time with Workaround [s]
10 0.2 0.2
100 0.5 0.5
1000 2 2
10000 64 11
20000 250 23
100000 5316 126

The issue/numbers can be reproduced with the attached testcase.zip:

java org.hl7.fhir.validation.ValidatorCli testcase/bundle-10000.json -transform http://test.ch/DummyBundleToBundle -version 4.0 -ig testcase/map -output result-10000.json

Not sure if numberChildren() is required in the makeElement() (the index seems to be used for the $index FHIRPath expression)? At least I have not observed any issues for the transform with the workaround.

CC @oliveregger

mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Jul 23, 2024
hapifhir#1699 Workaround for performance issue with FML transform: Growing/large lists getting very slow due to numberChildren() getting called recursively for every element that is added to a list.
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Jul 29, 2024
hapifhir#1699 defer numberChildren to end of transform
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Oct 18, 2024
hapifhir#1699 Workaround for performance issue with FML transform: Growing/large lists getting very slow due to numberChildren() getting called recursively for every element that is added to a list.

merge upstream
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Oct 18, 2024
hapifhir#1699 defer numberChildren to end of transform
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Nov 2, 2024
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Nov 2, 2024
instead of calling numberChildren() recursively whenever an element is
added.
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Nov 2, 2024
hapifhir#1699 Workaround for performance issue with FML transform: Growing/large lists getting very slow due to numberChildren() getting called recursively for every element that is added to a list.

merge upstream
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Nov 2, 2024
hapifhir#1699 defer numberChildren to end of transform
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Nov 2, 2024
mrunibe added a commit to mrunibe/org.hl7.fhir.core that referenced this issue Nov 2, 2024
instead of calling numberChildren() recursively whenever an element is
added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants