JuliusBrussee/caveman · error

cachebench: corpus limits exceed hard resource ceilings

Error message

cachebench: corpus limits exceed hard resource ceilings

What it means

Raised in normalizedCorpusLimits when caller-supplied limits exceed hardcoded resource ceilings (MaxRows or MaxSessions over 1,000,000, MaxMessagesPerRequest over its cap, etc.). The library refuses resource-exhaustion configurations rather than attempting the read.

Solutions

  1. Reduce CorpusLimits values below the hard ceilings (e.g. MaxRows and MaxSessions <= 1,000,000)
  2. Zero-valued limits get safe defaults, so simply omit fields you do not need to raise
  3. Precompute limits from corpus size instead of passing maximal placeholders
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/corpus.go:193 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/954061027ffa4555. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/corpus.go:193

		limits.MaxSessions = defaults.MaxSessions
	}
	if limits.MaxMessagesPerRequest <= 0 {
		limits.MaxMessagesPerRequest = defaults.MaxMessagesPerRequest
	}
	if limits.MaxRowBytes <= 0 {
		limits.MaxRowBytes = defaults.MaxRowBytes
	}
	if limits.MaxMessageBytes <= 0 {
		limits.MaxMessageBytes = defaults.MaxMessageBytes
	}
	if limits.MaxRetainedBytes <= 0 {
		limits.MaxRetainedBytes = defaults.MaxRetainedBytes
	}
	if limits.MaxInputBytes <= 0 {
		limits.MaxInputBytes = limits.MaxRetainedBytes
	}
	if limits.MaxRows > 1_000_000 || limits.MaxSessions > 1_000_000 || limits.MaxMessagesPerRequest > 100_000 || limits.MaxRowBytes > 256<<20 || limits.MaxMessageBytes > 128<<20 || limits.MaxInputBytes > 16<<30 || limits.MaxRetainedBytes > 16<<30 {
		return CorpusLimits{}, errors.New("cachebench: corpus limits exceed hard resource ceilings")
	}
	return limits, nil
}

func readLMCacheJSONL(reader io.Reader, limits CorpusLimits) ([]CorpusRow, error) {
	scanner := bufio.NewScanner(reader)
	scanner.Buffer(make([]byte, 64*1024), limits.MaxRowBytes)
	rows := make([]CorpusRow, 0)
	sessions := map[string]bool{}
	var retainedBytes int64
	for line := 1; scanner.Scan(); line++ {
		raw := bytes.TrimSpace(scanner.Bytes())
		if len(raw) == 0 {
			continue
		}
		var wire lmcacheRowWire
		if err := decodeOneJSON(raw, &wire); err != nil {
			return nil, fmt.Errorf("cachebench: corpus line %d: %w", line, err)

View on GitHub (pinned to 766dce6b13)