JuliusBrussee/caveman · error

cacheengine: cache economics overflow

Error message

cacheengine: cache economics overflow

What it means

The breakpoint-economics computation produced a non-finite net-savings value (NaN/Inf) from cumulative tokens, calls, and the profile's write/read multipliers — the profit model refuses to rank candidates on non-finite economics.

Solutions

  1. Use finite multipliers and realistic token/call magnitudes in the profile
  2. Audit EconomicsKnown profiles for zero or overflowing multiplier values
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/engine.go:391 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/5752f9c2970ca22a. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/engine.go:391

		if calls == 0 {
			calls = defaultCalls
		}
		if calls > previousCalls {
			return nil, false, false, errors.New("cacheengine: longer prefix cannot have higher expected reuse")
		}
		previousCalls = calls
		if calls < 2 {
			continue
		}
		if cumulativeTokens > 0 && cumulativeTokens < profile.MinPrefixTokens {
			belowMinimum = true
			continue
		}
		net := 0.0
		if cumulativeTokens > 0 && profile.EconomicsKnown {
			rawNet := float64(cumulativeTokens) * (float64(calls) - profile.WriteMultiplier - float64(calls-1)*profile.ReadMultiplier)
			if math.IsNaN(rawNet) || math.IsInf(rawNet, 0) {
				return nil, false, false, errors.New("cacheengine: cache economics overflow")
			}
			net = roundUnits(rawNet)
			if net <= 0 {
				negative = true
				continue
			}
		}
		sum := sha256.Sum256(prefix)
		candidate := Breakpoint{
			AfterSegment:              segment.Name,
			PrefixSHA256:              hex.EncodeToString(sum[:]),
			PrefixTokens:              cumulativeTokens,
			ExpectedCalls:             calls,
			BreakEvenCalls:            breakEvenCalls(profile),
			ExpectedNetInputRateUnits: net,
			index:                     index,
		}
		if len(candidates) > 0 && candidates[len(candidates)-1].ExpectedCalls == calls {

View on GitHub (pinned to 766dce6b13)