fix(perf):excessive memory consumption in v3.4.x#8198
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (16)
🚧 Files skipped from review as they are similar to previous changes (15)
WalkthroughDispose QuickJS VM contexts, marshalled handles, and eval-result handles; add evalCodeAndDispose; update shims and execution paths to free QuickJS-managed handles; add a memory benchmark runner, CI step, and a profiling CLI to detect WASM/external memory growth. ChangesQuickJS Memory Leak Prevention and Benchmarking
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/memory-profile.js`:
- Around line 23-24: ITERATIONS and SAMPLE_EVERY are parsed from env but never
validated, which can produce NaN/Infinity during loop/modulo/division
operations; add a validation guard after their parsing to ensure both are finite
integers > 0 (fallback to sane defaults or exit with an error), and apply the
same validation where these values are used later (references: ITERATIONS,
SAMPLE_EVERY, and any logic computing sampling/reporting in the memory profiling
loop and summary code); if validation fails, either set safe defaults or
throw/exit with a clear message so subsequent modulo/division (sampling) logic
cannot operate on invalid numbers.
- Line 55: Replace the hardcoded pathname '/tmp/req.bru' with an OS-agnostic
temp path by using os.tmpdir() and path.join; import/require the os and path
modules if not already present and change the object's pathname property to
path.join(os.tmpdir(), 'req.bru') so the code works on Windows and POSIX
systems.
In `@tests/benchmarks/memory/runner-memory.js`:
- Around line 46-49: The comment describing threshold scaling is inconsistent
with the SCENARIOS array (which uses 100 and 500 iterations)—update the comment
in runner-memory.js to reference the actual iteration counts (100 and 500)
instead of 300, e.g. change "300-run limits (~25 MB at 300 -> 40 MB at 500)" to
something like "100-run limits (~25 MB at 100 -> 40 MB at 500)" so the prose
matches the SCENARIOS definition.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6f477778-eee4-446e-a7c9-db08b4704578
📒 Files selected for processing (16)
.github/actions/tests/run-benchmark-tests/action.ymlpackage.jsonpackages/bruno-js/src/sandbox/quickjs/index.jspackages/bruno-js/src/sandbox/quickjs/shims/bru.jspackages/bruno-js/src/sandbox/quickjs/shims/bruno-request.jspackages/bruno-js/src/sandbox/quickjs/shims/bruno-response.jspackages/bruno-js/src/sandbox/quickjs/shims/lib/axios.jspackages/bruno-js/src/sandbox/quickjs/shims/lib/crypto-utils.jspackages/bruno-js/src/sandbox/quickjs/shims/lib/jwt.jspackages/bruno-js/src/sandbox/quickjs/shims/lib/nanoid.jspackages/bruno-js/src/sandbox/quickjs/shims/lib/path.jspackages/bruno-js/src/sandbox/quickjs/shims/lib/uuid.jspackages/bruno-js/src/sandbox/quickjs/shims/test.jspackages/bruno-js/src/sandbox/quickjs/utils/index.jsscripts/memory-profile.jstests/benchmarks/memory/runner-memory.js
3c0caba to
729e94d
Compare
JIRA Link - https://usebruno.atlassian.net/browse/BRU-3509
Description
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
Bug Fixes
New Features
Tests