Skip to content

feat: add client-side trace upload with prefix analysis#12

Open
stmatengss wants to merge 1 commit into
mainfrom
feat/trace-upload
Open

feat: add client-side trace upload with prefix analysis#12
stmatengss wants to merge 1 commit into
mainfrom
feat/trace-upload

Conversation

@stmatengss

Copy link
Copy Markdown
Collaborator

Summary

  • Add a Trace Analyzer card to the web calculator that lets users upload .jsonl trace files directly in the browser and get instant prefix sharing analysis without requiring the Python CLI
  • Parses JSONL traces line-by-line with progress feedback, builds a prefix trie to compute content upper bound hit rate and shared prefix length distribution
  • Auto-suggests heuristic calculator parameters (concurrent_agents, shared_prefix_tokens, avg_new_tokens_per_turn, avg_turns_per_session, private_window_tokens) derived from trace statistics, with an "Apply to Calculator" button

Features

Trace Statistics

  • Request count, time span, request rate (req/s)
  • Token distributions: avg, min, max, median, p95 tokens per request
  • Total unique blocks

Prefix Sharing Analysis

  • Builds a prefix trie from all hash_ids arrays
  • Computes content upper bound hit rate = reusable blocks / total blocks
  • Shows what % of requests share prefix blocks with other requests
  • Interactive histogram of shared prefix length distribution
  • Most common prefix lengths (median, average)

Auto-Suggest Parameters

  • Maps trace analysis to heuristic calculator parameters
  • concurrent_agents estimated from request rate and session length
  • shared_prefix_tokens = median shared prefix length * block_size
  • avg_new_tokens_per_turn = median unique (non-shared) tokens per request
  • avg_turns_per_session estimated via timestamp gap clustering
  • private_window_tokens = p95 request length * block_size

UI

  • Drag-and-drop upload zone with dashed border styling
  • Progress bar during file read and parse phases
  • Clean results display with stat boxes, histogram, and parameter table
  • "Apply to Calculator" button fills the heuristic form and recalculates
  • "Clear Trace" button to reset and upload a different file

Test plan

  • node tests/validate_js_parity.mjs passes all 178 checks (no regression to existing calculator logic)
  • JavaScript syntax validated via new Function() parsing
  • HTML parsing validated
  • Manual: upload a JSONL trace file (e.g., Mooncake trace) and verify statistics display correctly
  • Manual: click "Apply to Calculator" and verify heuristic form fields populate
  • Manual: verify drag-and-drop works
  • Manual: verify "Clear Trace" resets the upload zone

🤖 Generated with Claude Code

Add a Trace Analyzer card to the web calculator that lets users upload
JSONL trace files and get instant analysis without a Python backend:

- Trace statistics: request count, time span, request rate, token
  distributions (avg/min/max/median/p95), unique block count
- Prefix sharing analysis via trie: content upper bound hit rate,
  shared prefix length distribution histogram, sharing percentage
- Auto-suggested heuristic parameters derived from trace data
  (concurrent_agents, shared_prefix_tokens, avg_new_tokens_per_turn,
  avg_turns_per_session, private_window_tokens)
- "Apply to Calculator" button to populate the heuristic form fields
- Drag-and-drop file upload zone with progress feedback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant