Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

perf(usage-store): loadUsageRecords reads the entire usage.jsonl into memory before filtering

Open
#72 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript

Research direction

Start in apps/desktop/src/main/usage/store.ts at loadUsageRecords, especially lines 176–193, and trace how fromTs, toTs, and agentId are applied. Measure a time-range query against a growing usage.jsonl; done means preserving those filters without loading and parsing discarded records.

Written by the indexing model from the issue text.

Description

performance

Problem

apps/desktop/src/main/usage/store.ts L176–193

const lines = readFileSync(USAGE_FILE, 'utf8').split('\n').filter(Boolean);
// then a for-loop applies fromTs/toTs/agentId filters

usage.jsonl grows over time (the comment notes ~1–2 MB per 10,000 requests), but every query reads the entire file into memory, parses all lines, then discards most of them. For time-range queries such as "today's usage," the vast majority of records are thrown away.

Suggested fix

Maintain an in-memory index sorted by timestamp (line offset → ts) and use binary search to locate the fromTs starting point, reading and parsing only the relevant segment. Alternatively, switch to streaming reads for large files.

Dominant language
TypeScript
Stars
120
Forks
14
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from unbug/tday

All issues in unbug/tday

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.