Skip to content

chore: reduce memory footprint#816

Open
avivkeller wants to merge 2 commits into
mainfrom
reduce-memory
Open

chore: reduce memory footprint#816
avivkeller wants to merge 2 commits into
mainfrom
reduce-memory

Conversation

@avivkeller
Copy link
Copy Markdown
Member

@avivkeller avivkeller commented May 30, 2026

Reduces the memory used by doc-kit by evicting cache after it is no longer needed, and avoiding cloning objects

Ref: #815

@avivkeller avivkeller requested a review from a team as a code owner May 30, 2026 20:08
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview May 30, 2026 8:14pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 30, 2026

PR Summary

Medium Risk
Pipeline caching and eviction change when intermediate AST/metadata is retained, and downstream generators now mutate shared content trees instead of clones—risk of subtle cross-generator side effects if ordering or concurrency assumptions differ from before.

Overview
Lowers doc-kit memory use by replacing the separate generator/stream caches with a single createCache in caching.mjs that dedupes async-generator collection and evicts each generator result after the last expected consumer reads it (consumer counts computed up front from the dependency closure).

The orchestrator in generators.mjs now routes dependency reads and final target collection through cache.consume, and streaming.mjs is removed; async detection moves to isAsyncIterable in utils/misc.mjs.

Several output generators stop deep-cloning metadata content (structuredClone / JSON.parse(JSON.stringify(...))) and instead mutate entry.content in place in json-simple, jsx-ast, legacy-html, and legacy-json.

Tests add caching.test.mjs and generators.test.mjs (mocked pipeline: shared deps run once, targets that are also dependencies are not re-run); streaming.test.mjs is deleted and isAsyncIterable coverage moves to misc.test.mjs.

Reviewed by Cursor Bugbot for commit 0005913. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

❌ Patch coverage is 97.23757% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.01%. Comparing base (a793466) to head (0005913).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/generators/json-simple/generate.mjs 0.00% 5 Missing ⚠️
src/generators/legacy-html/utils/buildContent.mjs 0.00% 4 Missing ⚠️
src/utils/__tests__/misc.test.mjs 93.75% 3 Missing ⚠️
src/__tests__/generators.test.mjs 99.28% 1 Missing ⚠️
src/generators.mjs 97.36% 1 Missing ⚠️
src/generators/legacy-json/utils/buildSection.mjs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #816      +/-   ##
==========================================
+ Coverage   82.85%   84.01%   +1.16%     
==========================================
  Files         170      172       +2     
  Lines       14732    15180     +448     
  Branches     1266     1345      +79     
==========================================
+ Hits        12206    12754     +548     
+ Misses       2520     2417     -103     
- Partials        6        9       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a082cae. Configure here.

Comment thread src/generators/json-simple/generate.mjs
Comment thread src/caching.mjs
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 30, 2026

orama-db Generator

File Base Head Diff
orama-db.json 8.83 MB 8.83 MB -1018.00 B (-0.01%)

@avivkeller avivkeller linked an issue May 30, 2026 that may be closed by this pull request
@avivkeller
Copy link
Copy Markdown
Member Author

cc @nodejs/web-infra

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