Skip to content

perf(v8): reduce heap limits and remove optimize-for-size#4369

Merged
gregpriday merged 1 commit intodevelopfrom
feature/issue-4364-reduce-v8-heap-limits-remove
Mar 28, 2026
Merged

perf(v8): reduce heap limits and remove optimize-for-size#4369
gregpriday merged 1 commit intodevelopfrom
feature/issue-4364-reduce-v8-heap-limits-remove

Conversation

@gregpriday
Copy link
Copy Markdown
Collaborator

Summary

  • Reduces renderer JS heap limit from 4 GB to 1536 MB and adds --max-semi-space-size=64 to encourage earlier minor GC on short-lived React/Zustand allocations
  • Reduces pty-host heap limit from 4 GB to 512 MB — the pty-host is an I/O forwarding process; its ring buffers are off-heap so 512 MB is ample
  • Removes --optimize-for-size from both the renderer (js-flags in main.ts) and the main process (v8.setFlagsFromString in environment.ts) — this flag degrades JIT throughput and was designed for embedded environments, not desktop IDEs

Resolves #4364

Changes

  • electron/main.ts — updated js-flags switch: 1536 MB heap, added semi-space 64 MB, dropped --optimize-for-size
  • electron/services/PtyClient.tsmemoryLimitMb reduced from 4096 to 512
  • electron/setup/environment.ts — removed v8.setFlagsFromString('--optimize_for_size') and the now-unused v8 import
  • electron/setup/__tests__/environment.test.ts — updated test to confirm the flag is no longer set
  • electron/services/__tests__/PtyClient.handshake.test.ts — added test verifying the pty-host memory limit is 512 MB

Testing

  • Existing unit tests updated and passing
  • New handshake test added to cover pty-host memory limit value
  • npm run check passes clean (typecheck, lint, format)

- Renderer: 4096→1536 MB old-space, add --max-semi-space-size=64, remove --optimize-for-size
- Main process: remove nodeV8.setFlagsFromString("--optimize_for_size")
- PTY host: reduce default memoryLimitMb from 4096 to 512
- Update environment test to assert --optimize_for_size is no longer set
- Add PtyClient tests for default and custom memory limits
@gregpriday gregpriday force-pushed the feature/issue-4364-reduce-v8-heap-limits-remove branch from f36101c to 9c21f17 Compare March 28, 2026 00:43
@gregpriday gregpriday merged commit 22e70e2 into develop Mar 28, 2026
3 checks passed
@gregpriday gregpriday deleted the feature/issue-4364-reduce-v8-heap-limits-remove branch March 28, 2026 00:43
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.

Reduce V8 heap limits and remove optimize-for-size

1 participant