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

Optimize the JSON parsing in NpmPackageIndexBuilder.seeFile #1898

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

qligier
Copy link
Contributor

@qligier qligier commented Feb 5, 2025

While working on some performance issues in Matchbox, I noticed that NpmPackageIndexBuilder.seeFile was using a lot of resources (time and memory allocation). The reason is that it fully parses many JSON files, allocating memory for objects representing the whole file, just to read a few properties and discard the object immediately.

This is a use case where streaming parsers shine: they only parse and allocate memory for the parts we're interested in.

This PR uses the streaming parser provided in Jackson.

In Matchbox startup, we measured a reduction of ~6 seconds (12%) and ~7 Go of allocation (23%), when loading hl7.fhir.r4.core, hl7.terminology.r4 and hl7.fhir.uv.extensions.r4.

@grahamegrieve
Copy link
Collaborator

The R4B test failures look related to this

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 12.91%. Comparing base (627d282) to head (053d201).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1898   +/-   ##
=========================================
  Coverage     12.91%   12.91%           
- Complexity    34012    34021    +9     
=========================================
  Files          2252     2252           
  Lines        686541   686547    +6     
  Branches     202569   202576    +7     
=========================================
+ Hits          88643    88650    +7     
+ Misses       566487   566483    -4     
- Partials      31411    31414    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qligier
Copy link
Contributor Author

qligier commented Feb 6, 2025

Yep, I fixed it.

@dotasek dotasek self-requested a review February 6, 2025 16:26
@dotasek dotasek merged commit 57e9513 into hapifhir:master Feb 6, 2025
33 checks passed
@qligier qligier deleted the ql_optimize_npib branch February 7, 2025 06:40
hl7-devops added a commit that referenced this pull request Feb 9, 2025
## Announcement

This release marks the beginning of a process of refactoring the HAPI core code.
We are trimming and refactoring the core model code to reduce dependencies. As part
of this, we will be culling all the old unmaintained code in the older versions. In
addition, we will be moving all the terminology, rendering, view definition, and
validation related code to a new partner package for R4, R4B, and R5.

This change is planned for July 2025. This release starts the process of marking the
code with annotations to indicate it's proposed fate:
- @deprecated classes will be deleted in July 2025 unless users raise issues with that
- @MarkedToMoveToAdjunctPackage is code that will move the other package
- Code with no annotations will not move or be deleted

## Validator Changes

* Add HL7 CodeSystem display and definition checks
* Add Matchetype validator
* Add "http://hl7.org/fhir/tools/StructureDefinition/snapshot-base-version" to snapshot generation
* Optimize the JSON parsing in NpmPackageIndexBuilder.seeFile (#1898) (faster loading)
* Fix stack crash when structure definitions are circular
* Fix error reporting duplicate contained IDs when contained resources are sliced by a profile
* Allow cardinality changes in obligation profiles (but not recommended)
* Fix bug with wrongly processing -ips#(v) parameter
* Add underscore to regex to be able to use underscore in Bundle URLs

## Other code changes

* Refactor FileUtilities and other Utilities classes
* fix element order in Element.forceElement()
* fix NPE in patient renderer
* Resource Factory updates for loading generated resources in IG publisher
* Fix intermittent thread issue in Date rendering
***NO_CI***
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.

3 participants