Read the RF2 files concurrently, and make the repository safe for it - #4
Open
dionmcm wants to merge 10 commits into
Open
Read the RF2 files concurrently, and make the repository safe for it#4dionmcm wants to merge 10 commits into
dionmcm wants to merge 10 commits into
Conversation
Keep validation workers supplied with concepts instead of every 10
Scale validation workers to the host, and let callers override it
…apshot Skip the effective-component pre-pass when the input is a single Snapshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch:
perf/parallel-rf2-loading· Module:snomed-drools-rf2-validatorProblem
loadComponentsFromRF2passedmultiThreaded=false(hardcoded), so RF2 files were read one after another even thoughReleaseImporter.loadAllalready has the structure to overlap them: the concept file inline first, then core component files, then reference set files, with a barrier between phases.The flag was correctly
false, becauseSnomedDroolsComponentRepositorywas not safe for concurrent writes. This change makes the repository thread safe with synchronisation and allows parallel loading increasing throughput.Change
Guard the repository, then enable it:
addDescription,addRelationship,addAnnotationandaddOntologyAxiomlock the concept being appended to. Locking the concept stripes by concept, so it costs no memory and contends only when two rows touch the same concept at the same instant.addRelationshiptouches the source and the destination concept. Those two locks are taken separately, never nested - a relationship pair pointing at each other would otherwise give two threads the same two locks in opposite order, which deadlocks.annotationsandontologyAxioms, are guarded like the existingdescriptionMap.snomed.drools.parallelLoading=falserestores the old behaviour - may be unnecessary but was preserved in case it was desired in some use casesDescriptions resolve their concept, and language reference set members resolve their description, because the phase they depend on has completed and
Future.get()ensures it happens before. Within a phase, the files that write thesame collections are the relationship/concrete-relationship pair and the description/text-definition pair, which is what the new locking covers.
Tests
SnomedDroolsComponentRepositoryConcurrencyTestdrives 8 threads x 500 rows at a single concept and asserts nothing is lost, plus a reciprocal-relationship case that times out rather than passing if the lock order regresses.With the locking reverted the tests fail with 3,964 and 3,975 of 4,000 entries arriving. A lost entry is a missing finding, not a crash, which is why this is tested.
Measurement
Load phase 94s -> 68s. Total 165s -> 118s across the three runs quoted above.
Findings of the assertions unchanged.
About this series
One of five independent performance changes to the Drools validation path, measured against a real 722,404-concept AU edition Snapshot. Each is a single commit on
master, builds and passes the full suite alone, and leaves the findings byte-identical: 10,949 before and after, with matching report TSVs.Together they take a full-Snapshot validation from 636s to 118s.
This PR and
perf/skip-effective-filter-single-snapshottouch adjacent lines; whichever merges second needs a one-line rebase. There is no logical dependency and the order does not matter.