You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: implement additive log size metric for LookupCoin
Replace ValueLogOuterOrMaxInner with ValueLogOuterSizeAddLogMaxInnerSize
for LookupCoin costing. This change reflects experimental findings that
two-level map lookup time scales linearly with log(outerSize) + log(innerSize)
rather than max(log(outerSize), log(innerSize)).
Implementation:
- Add ValueLogOuterSizeAddLogMaxInnerSize type computing sum of log sizes
- Update LookupCoin builtin signature to use new size measurement
- Implement worst-case benchmark generation targeting max-size inner maps
- Optimize size test combinations for BST worst-case coverage (depths 10-18)
- Filter out empty values which cannot provide worst-case keys
Benchmark strategy:
- All lookups target the policy with maximum tokens (worst case)
- Test combinations maximize nodes at each depth: (32,32), (64,128),
(256,256), (512,512), (1024,128), (2048,64)
- Ensures conservative costing that prevents underestimation attacks
* feat: update LookupCoin cost model with remote benchmark data
Updated benchmark data (206 entries) and cost model parameters for
LookupCoin using the new ValueLogOuterSizeAddLogMaxInnerSize metric.
Cost model changes:
- CPU: linear_in_z (intercept: 204546, slope: 7423)
- Memory: constant 10 (updated from 1)
Benchmark data sourced from GitHub Actions run 19272430553 using
worst-case targeting strategy (max-size inner map lookups).
* refactor: use exhaustive power-of-2 grid for LookupCoin benchmarks
Replace mixed random/specific test points with systematic exhaustive
coverage of all (2^a, 2^b) combinations where a, b ∈ {1..10}.
This provides:
- 100 deterministic test points (10×10 grid)
- Complete coverage of depths 2 to 20
- All distribution patterns (balanced, outer-heavy, inner-heavy)
- Reproducible results with no randomness
Removed random value generation and extractWorstCaseKeys function
which are no longer needed with systematic enumeration.
* feat: apply additive log metric to ValueContains and remove old wrapper
Update ValueContains to use ValueLogOuterSizeAddLogMaxInnerSize for
consistency with LookupCoin. The additive log metric better reflects
the algorithmic complexity where each containment check performs
multiple two-level lookups, each exhibiting additive depth behavior.
Changes:
- Update ValueContains builtin signature
- Update ValueContains benchmark wrapper
- Update golden signature test
- Update test generators
- Remove ValueLogOuterOrMaxInner (now completely unused)
This provides consistent and accurate costing across all Value lookup
operations based on the experimental evidence.
* feat: update benchmark data for LookupCoin and ValueContains
Merged new benchmark results from GitHub Actions using additive log metric:
- LookupCoin: 400 entries (power-of-2 grid, run 19294057613)
- ValueContains: 100 entries (run 19294814942)
Fixed lookupCoin memory cost from 10 to 1 (matches result type: Integer).
CPU costs remain from previous remote benchmarking.
Total: 500 new benchmark entries with systematic worst-case coverage.
* feat: refine LookupCoin and ValueContains cost models with remote benchmarks
Updated benchmark data and cost models for LookupCoin and ValueContains
based on remote GitHub Actions benchmark run (19295960854).
Benchmark changes:
- LookupCoin: 400 data points (3 parameters)
- ValueContains: 100 data points (2 parameters)
Cost model refinements:
- lookupCoin: adjusted intercept (204546→252573) and slope (7423→4734)
- valueContains: refined slope (96034→94269)
Both functions maintain their cost model types:
- lookupCoin: linear_in_z
- valueContains: linear_in_y
* test: update conformance budgets for refined cost models
Update expected CPU budgets in conformance test cases to reflect the refined cost models for LookupCoin and ValueContains builtins. These changes align with the additive log metric improvements and remote benchmark calibration applied in recent commits.
LookupCoin CPU increased from 338744 to 378875 (both scenarios). ValueContains CPU adjustments range from +108 to +216 depending on the specific test case complexity.
* feat(bench): strengthen ValueContains with systematic worst-case benchmarks
Replace random sampling approach with systematic power-of-2 grid targeting worst-case BST depth scenarios. Generate ~916 test cases (up from 100) using uniform container distributions and ensuring all lookups succeed by maintaining subset relationship (contained ⊆ container).
Key improvements:
- Use generateConstrainedValueWithMaxPolicy for worst-case BST structure
- Test all combinations of 10 power-of-2 sizes for containers
- Vary contained sizes to explore iteration count dimension
- Include deepest BST entry in each test to force maximum traversal depth
- No early exits as all entries are guaranteed to be found
This aligns ValueContains benchmarking with LookupCoin's approach while accounting for its multi-lookup nature (m × log(n) complexity vs single log(n)).
* feat(bench): improve ValueContains sample distribution with uniform spacing
Replace power-of-2 clustering with uniform linear spacing for contained
value sizes to achieve better benchmark coverage in the 0-1000 range.
## Changes
- Use uniform linear spacing (10 samples) instead of power-of-2 distribution
- Small containers (<10 entries) test all possible sizes
- Larger containers sample uniformly from 1 to min(1000, totalEntries)
- Maintains 10×10 container grid for BST depth variety
- Total benchmarks: ~1023 (close to 1000 target)
## Distribution Improvements
- Before: Power-of-2 clustering (2, 4, 8, 16, 32, 64, 128, 256, 512)
- After: Uniform spacing appropriate to container size
- Log size 10: ~25 unit spacing
- Log size 20: ~100 unit spacing
- Achieves smooth, uniform distribution across 0-1000 range
## Worst-Case Properties Maintained
- Container generated with worst-case BST structure
- Subset relationship: contained ⊆ container (all lookups succeed)
- Deepest BST entry included in each test (maximum lookup depth)
- No early exit conditions (comprehensive cost measurement)
* feat(cost): correct ValueContains model to multiplied_sizes
The previous linear_in_y model incorrectly ignored container size, only considering the contained value size. This was wrong because ValueContains iterates through every coin in the contained value and performs a lookupCoin on the container for each one, resulting in O(y * log(x)) complexity.
The multiplied_sizes model properly accounts for both parameters:
- x: log(outer_size) + log(max_inner_size) of container (BST depth)
- y: total_size of contained value
Cost formula changed from "1000 + 94269 × y" to "1000 + 6548 × (x × y)" picoseconds, reflecting the actual computational complexity.
Includes 1023 fresh systematic worst-case benchmark measurements (up from 100 entries) covering full parameter space using power-of-2 grid with uniform spacing, run on GitHub Actions self-hosted runners.
0 commit comments