ci: publish candidate image for #24810 performance validation (do not review) - #24859
Closed
netroms wants to merge 4 commits into
Closed
ci: publish candidate image for #24810 performance validation (do not review)#24859netroms wants to merge 4 commits into
netroms wants to merge 4 commits into
Conversation
Every cached region in DHIS2 uses READ_WRITE, whose access strategy holds one ReentrantReadWriteLock PER REGION (not per key): every get takes the region read lock and every putFromLoad takes the region WRITE lock, even when it writes nothing (entities are unversioned, so an existing entry is never overwritten from a load). Under concurrent load on option-heavy metadata this serialises a whole region behind single-key work: measured 14-15% of ALL JVM wall samples parked in AbstractReadWriteAccess. Switches the static reference bucket (Option*, PeriodType, DataElement, Category*, OptionSet.options, Legend*, Indicator*, OrgUnit hierarchy; 30 files, 71 declarations) to NONSTRICT_READ_WRITE, which has no region lock. Trade-off: a brief staleness window after a write, accepted for reference metadata (sign-off: Morten, 2026-08-07). Period/RelativePeriods stay READ_WRITE. Measured on a tracker-import ramp: parked-in-region-lock 14.15% -> 0.05%, p99 at 100 concurrent users 58.4s -> 20.7s as an isolated change. AI Assisted
Regions created on demand through the jsr107 template are store-by-value: every get and put copies the entry through SerializingCopier, inside the READ_WRITE region lock critical section. Predefining a region in ehcache.xml keeps ehcache-native store-by-reference semantics (Hibernate caches disassembled, immutable entries, so by-reference is safe; 2.41 ran Ehcache 2 by-reference for years). Region list and heap bounds come from measured traffic: the hot metadata regions from a read/write metadata ramp, plus the tracker-import hot set (the Option region alone takes ~98M gets per 25 minute import run). Measured effect in the full combination: SerializingCopier wall samples 236,287 -> 1,057. AI Assisted
dataElementCountDoesNotScaleQueryCount compares a metadata export with 3 data elements against one with 8 and asserted the two select counts were equal. With the cache changes in this branch the second export legitimately issues FEWER selects (21 vs 22): what the first export loaded is still cached during the second. Assert the invariant the test name and comment state - the count must not grow - so the test keeps catching a reintroduced N+1 without failing on a cache improvement. AI Assisted
The previous six hour TTL was inherited from the old Ehcache 2 configuration. TTL is the upper bound on how long a stale cache entry can survive, whether it went stale through an out-of-band database change (no load ever refreshes an existing entry for unversioned entities) or through a late cache-put re-inserting a value just evicted by a concurrent write under NONSTRICT_READ_WRITE. One hour tightens that bound for every region at the cost of one reload per entry per hour, which is noise at production request rates. Instances with stricter staleness expectations can override the whole file via cache.ehcache.config.file. Also rewrites the region declaration comments in neutral terms: why declared caches are store-by-reference while runtime-created ones are forced store-by-value by the JCache defaults, how the region list and heap bounds were chosen, and how to tune both from the per-region metrics exposed at /api/metrics. AI Assisted
|
Contributor
Author
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.




Not for review. This draft PR exists only to make CI publish
dhis2/core-pr:<this PR number>, the candidate image for the performance comparison requested on #24810 (fork PRs cannot publish images because they have no access to the Docker Hub secrets).Content is identical to #24810 (same commits, head
809d8e332d). All review happens there. This PR will be closed once the performance comparison runs are done.AI Assisted