Skip to content

Efficiency: every vote rewrites votes.json and meta.json in full; round_summaries grows unbounded #33

Description

@laceyp99

Where

arena/app.py_append_vote_record_unlocked(), _update_meta_log_unlocked() (line ~435), _write_json_file().

Problem

Per submitted vote, the persistence path:

  1. Reads all of votes.json into memory, appends one record, and rewrites the entire file (_append_vote_record_unlocked), with fsync + atomic replace.
  2. Reads all of arena_logs/meta.json, appends to round_summaries, and rewrites the whole file.

Both files grow without bound (round_summaries duplicates data already persisted per-session in arena_logs/sessions/<...>/round.json, and the repo's own sample votes.json was already 75 KB). Cost per vote is O(total history), so submissions get progressively slower and the read-modify-write window (even with the file locks) grows.

Additionally, _leaderboard_view_data() re-reads and re-parses the full meta.json on every page load and every vote submission just to rebuild the same rows.

Suggested fix (pick pragmatically)

  • Store votes as JSON Lines (votes.jsonl): appending a vote becomes an O(1) append of one line, still crash-tolerant, no read-modify-write.
  • In meta.json, keep only the aggregates (model_totals, total_rounds) and drop round_summaries — the per-session round.json/vote.json files already contain everything a summary would need, and nothing in the app reads round_summaries.
  • (Optional) Cache the parsed leaderboard and invalidate on vote submission instead of re-reading the file on every demo.load.

This is a local-first app so none of this is urgent, but the current design has a built-in slowdown curve and stores every round in three places.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:lowUseful cleanup or guardrail work

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions