Skip to content

Draft: perf: use lazy file iteration for jsonl and env parsing in scripts - #733

Open
tteon wants to merge 2 commits into
mainfrom
bolt-lazy-file-iteration-16126754692762469381
Open

tteon wants to merge 2 commits into
mainfrom
bolt-lazy-file-iteration-16126754692762469381

Conversation

@tteon

@tteon tteon commented Oct 13, 2026

Copy link
Copy Markdown
Owner

What

Replaced eager path.read_text().splitlines() with lazy file iteration for line in f: within context managers across several scripts in the scripts/ directory, including benchmark reporting, cache simulation, e2e testing, and financial benchmark logging. Also updated .jules/bolt.md to document this performance learning.

Why

Reading entire large .jsonl trace files or .env files into a single string in memory, and then generating another large list of string lines via splitlines(), creates an avoidable memory bottleneck, especially for the high-volume benchmarks and trace parsing scripts. This optimization addresses the priority goal of reducing avoidable file I/O or JSONL overhead.

Expected Impact

Lower peak memory usage (O(1) vs O(N) line caching) during trace and log file parsing in the benchmark scripts and e2e test drivers.

Validation

Ran relevant script and benchmark unit tests: PYTHONPATH=. uv run pytest tests/seocho/test_cli_parser_contract.py tests/seocho/test_cli_ontology.py tests/seocho/test_benchmarking.py, which passed.

Risks

Low risk. Python's json.loads inherently ignores trailing whitespace, so retaining newlines at the end of each lazily yielded line does not affect parsing compared to splitlines() (which strips them). Explicit strip() calls were maintained or adjusted as needed for .env parsing scripts to ensure no configuration corruption.

Modified files:

  • scripts/benchmarks/inference_workbench.py
  • scripts/serve_track/smoke_plugin.py
  • scripts/cache_sim/h0_gate.py
  • scripts/finbench/results_log.py
  • scripts/agentos/e2e_axiom_ab.py
  • scripts/agentos/e2e_cold_start_ab.py
  • scripts/agentos/e2e_cross_model_intern.py
  • scripts/agentos/e2e_ontology_source_ab.py
  • .jules/bolt.md

PR created automatically by Jules for task 16126754692762469381 started by @tteon

Replaces eager read_text().splitlines() with lazy file iteration (for line in f:)
across various benchmarking, serving, and e2e scripts to reduce memory overhead
when processing large log and env files.

Co-authored-by: tteon <52625664+tteon@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T23:41:47.699858Z ea25d26 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added kind-maintenance Maintenance, chores, dependency hygiene, or repo cleanup. status-needs-triage Needs maintainer triage before work starts or merges. labels Oct 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea25d26f0f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .jules/bolt.md
@@ -0,0 +1 @@
- Use lazy file iteration `for line in f:` rather than `read_text().splitlines()` to parse .jsonl and .env files in `scripts/`. This reduces memory overhead for large traces and logs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the tracked Jules state

Adding this file under .jules/ makes scripts/ci/check-root-hierarchy-contract.sh fail on every checkout of this commit with Forbidden tracked root hierarchy path: .jules; remove the local Jules note instead of tracking it. The repository contract explicitly requires .jules/ to remain outside Git.

AGENTS.md reference: AGENTS.md:L53-L54

Useful? React with 👍 / 👎.

Replaces eager read_text().splitlines() with lazy file iteration (for line in f:)
across various benchmarking, serving, and e2e scripts to reduce memory overhead
when processing large log and env files.

Co-authored-by: tteon <52625664+tteon@users.noreply.github.com>
@github-actions github-actions Bot added area-ci GitHub Actions, CI scripts, release automation, or repo ops. kind-ci CI, repository automation, release automation, or labels. labels Oct 13, 2026

This branch has not been deployed

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

Labels

area-ci GitHub Actions, CI scripts, release automation, or repo ops. kind-ci CI, repository automation, release automation, or labels. kind-maintenance Maintenance, chores, dependency hygiene, or repo cleanup. status-needs-triage Needs maintainer triage before work starts or merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant