Repository navigation
Return read-only JSON flag values with exact integers - #13484
Draft
leoromanovsky wants to merge 11 commits into
Draft
leoromanovsky wants to merge 11 commits into
leoromanovsky wants to merge 11 commits into
Conversation
Contributor
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This was referenced Nov 16, 2026
1 task done
Add ScaleSuiteBenchmark, which evaluates each case of the opt-in scale suite of the shared FFE fixtures. The setup checks every expected value and reason first. Pin ffe-system-test-data to the scale suite PR head.
The scale benchmark sat on the JSON value change and checked JSON integers by type, so it could not set a baseline on master. It now compares JSON numbers by value, covers every case file of the scale and scale-json suites, can isolate one case with the index parameter, and prints each case's index. A load benchmark measures parsing each suite's configuration and prints the heap it retains, so changes that move work to load time show their cost. The submodule points to the scale-suite fixture branch, which adds the N x M dimensions and JSON values up to 10 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each evaluation of a JSON flag converted the whole variant tree to a new OpenFeature Value. The cost grew with the variant size: about 21 us and 83 KB for a 712-node variant. The parser now builds one Value for each JSON object or array variant. Evaluations return that instance. Its structures are MutableStructure over unmodifiable maps and its lists are unmodifiable, so callers cannot change it, and equals is the same as Value.objectToValue. The plain-map form is built once and shared. Integers in JSON variant values now stay Integer or Long instead of Double, so 5 is returned as 5 and integers above 2^53 stay exact. Scalar flags keep Double values.
- Keep Long values only when the loaded OpenFeature SDK supports them. SDK 1.21.0 and older reject a Long with TypeMismatchError, which rejected the whole configuration. - Freeze JSON variants in the parser, and store the frozen tree's plain form as Variant.value. The parsed tree is no longer kept as well. - Make the parser scope follow positions, so a flag keyed "variations" keeps exact integers. - Change nested integers of non-JSON flags back to Double, as before. - Use one number model for JSON fixture defaults and results. - Size maps exactly, and make FrozenValues package-private. - Correct javadoc, and document the read-only values and exact integers. - Add tests for the CDN envelope, the "variations" key, non-JSON flags and integers beyond the long range.
Handle non-JSON flags first in toVariant, use assertNull, and shorten the javadoc. No behavior change.
The submodule points to the scale suite plus the JSON number precision fixture, so CanonicalFixtureTest checks exact JSON integers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leoromanovsky
force-pushed
the
leo.romanovsky/ffe-json-frozen-values
branch
from
November 17, 2026 01:00
1ef0bc5 to
7f5bb63
Compare
leoromanovsky
changed the base branch from
master
to
leo.romanovsky/ffe-scale-suite-benchmark
November 17, 2026 01:00
Base automatically changed from
leo.romanovsky/ffe-scale-suite-benchmark
to
master
November 19, 2026 03:09
Master has the scale benchmarks of #13485 as one squashed commit, with the fixtures moved to dd-openfeature/src/test/fixtures. Take master's benchmarks, fixture path and fixture pin, and drop the old fixture path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- OpenFeature SDK 1.22.0 has Value(Long) but cannot convert it back, so asObjectMap() on a JSON flag with a large integer threw there. Probe the conversion instead of the constructor; 1.22.0 now keeps doubles. - A JSON object or array variant now holds only its frozen Value. The plain map form was built for every variant at load time and kept; it is now built on the first asObjectMap() call, which cuts the load time and the retained heap. The evaluator needs no special case: mapValue already returns a Value as is. - Share the null and boolean Values, convert non-JSON variants to doubles in place, and use forEach to build the plain map. - The README says when integers stay Double. - Tests: compare against an independent expected value, cover scalar JSON variants, and check that an after hook that changes the value gets the default with GENERAL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Exact integers are read only at flags.<flag>.variations.<key>.value from the root of a UFC document or the data.attributes of the JSON:API envelope. A "flags" key nested elsewhere no longer starts the path. - Frozen maps start at the default capacity of 16, as the maps that Value.objectToValue and asObjectMap() build, so keySet() and asObjectMap() list the keys in the same order as before. - Changing a frozen structure throws an UnsupportedOperationException that says the value is read-only and should be copied. - Pin ffe-system-test-data to the latest main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ffe-system-test-data main now has the JSON number precision fixture (#77), so CanonicalFixtureTest runs its two cases again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The read-only test called only one of the eight add overloads, so the coverage gate failed for FrozenStructure. It now calls each one and checks the message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 19, 2026
This branch has not been deployed
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.
What Does This Do
Valuethat is built once, when the configuration is parsed. Before, each evaluation converted the whole variant to a newValue, so its cost grew with the size of the variant.5is returned as5, not5.0, and integers up toLong.MAX_VALUEkeep their value.asObjectMap()returns is built on its first call and then shared.Motivation
Applications that serve large JSON flags pay for each evaluation in proportion to the variant size. On
master, a 1 MB variant takes milliseconds and allocates megabytes on every call (see Results).The JSON number handling is also a correctness bug. The parser reads every JSON number as a
double, so integer fields come back asDouble, and integer IDs above 2^53 change value.Additional Notes
Results
ScaleSuiteBenchmarkandScaleSuiteLoadBenchmarkfrom #13485,master(4075f1f) against this PR (d81545f), back to back. AWS workspace, Intel Xeon Platinum 8175M, 16 vCPUs, JDK 21.0.10, JMH AverageTime, 1 fork, 3 warm-up and 5 measurement iterations of 2 s,-prof gc. Each row is the mean over the cases of the file. The host load average was 12–14 during the run, so treat differences under about 10% as noise.masterscale-json/json-sizes(100 KB, 1 MB, 4 MB)scale-json/json-shapes(100,000 numbers, 1 MB string, escapes, nested arrays)scale-json/json-values(719 nodes, 2,000 keys, 16 levels)The cost of a JSON evaluation no longer depends on the size of the value. The 368 B per call is the provider's result object. The 14 case files of the
scalesuite, which have no JSON values, allocate the same bytes per call on both builds, and their times match within noise.masterscale-json(7.9 MB) parse timescale-jsonallocated by one parsescale-jsonretained heapscale(7.9 MB, 10,030 small flags) parse time and retained heapFreezing moves the conversion to load time: parsing the JSON-heavy configuration takes about 20 ms longer and keeps about 14% more heap. A configuration without large JSON values does not change.
Decisions
asObjectMap()is built only when an application calls it, so a variant that is served but never read as a map does not keep a second copy.Longsupport by behavior. The provider declares OpenFeature SDK 1.23.0, but Maven can resolve an older SDK that an application declares. 1.22.0 addedValue(Long)but itsStructure.convertValuecannot convert it back, so the check converts aLongonce, when the class loads. On 1.22.0 and older, integers outside theIntegerrange stayDouble, as before.MutableStructureover an unmodifiable map, notImmutableStructure.ImmutableStructure.getValuedeep-copies on each call.MutableStructurekeeps the type and theequalsbehavior of today's result, and the frozen maps keep its key order.flags.<flag>.variations.<key>.value, from the document root or the JSON:APIdata.attributes. Other UFC values (shard ranges, serial IDs, conditions) still expectDouble.IntegerorLong, notBigInteger.Structure.convertValuecannot convert aBigInteger. Integers beyond theLongrange stayDouble.Behavior changes
asObjectMap()map throwsUnsupportedOperationException, with a message that says to copy the value first.asMap()still returns a new copy.aftermakes the evaluation return the default value with theGENERALerror code. The next evaluation still returns the configured value.asObjectMap(),Value.asObject()andValue.equalssee5(Integer) instead of5.0(Double) for JSON integers. This fixes the bug, but it can change what an application serializes or compares:value.equals(new Value(5.0))is now false.Value.asInteger()on an integer above 2^31-1 now wraps (Long.intValue()). Before, theDoublesaturated.Testing
FlagEvaluatorJsonValueTestcovers the shared instance, equality with an independently built expected value, exact integers (also through the JSON:API envelope and a flag keyed"variations"), scalar and array variants, the key order, the read-only error, and theDoublevalues outside JSON variants. AProviderTestcase covers theafterhook.CanonicalFixtureTestexpects exact integers in JSON results and defaults, againstffe-system-test-datamain(cd0081d). That includes both cases of the JSON number precision fixture from Add JSON number precision fixture ffe-system-test-data#77.Longcheck was run by hand against 1.21.0, 1.22.0, 1.22.1 and 1.23.0.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue🤖 Generated with Claude Code