Skip to content

fix: bound rayon parallelism in EditDelta::layout_delta to reduce peak memory (APP-4686)#12312

Draft
warp-dev-github-integration[bot] wants to merge 1 commit into
masterfrom
fix/memory-layout-delta-rayon-APP-4686
Draft

fix: bound rayon parallelism in EditDelta::layout_delta to reduce peak memory (APP-4686)#12312
warp-dev-github-integration[bot] wants to merge 1 commit into
masterfrom
fix/memory-layout-delta-rayon-APP-4686

Conversation

@warp-dev-github-integration
Copy link
Copy Markdown

Description

Bounds rayon parallelism in EditDelta::layout_delta and layout_temporary_blocks to reduce peak memory usage on large document edits.

Root cause: Both functions called into_par_iter() without any concurrency limit, running all text layout tasks simultaneously. On large documents (many blocks), this created 9+ GB peak memory usage from concurrent CoreText Glyph and CaretPosition Vec allocations across all rayon worker threads.

Fix: Pre-annotate each task with its BlockLocation (which requires the global index), then process tasks in sequential parallel chunks of MAX_PARALLEL_LAYOUT_TASKS (8). Each chunk runs in parallel, bounding peak concurrent CoreText allocations to 8 tasks at a time.

Also removes the now-unused parallel_util module (Last<T>), which was only ever used by the original unzip() pattern in these two functions.

Linear: APP-4686

Linked Issue

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

  • I have manually tested my changes locally with ./script/run

Automated tests: All 426 existing warp_editor tests pass. cargo check, cargo clippy, and ./script/format all pass cleanly.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Conversation: https://staging.warp.dev/conversation/e0a46d55-49e1-466b-ba50-bc291a24e1f1
Run: https://oz.staging.warp.dev/runs/019e9e88-6615-78c8-b94e-1241b6c69102

This PR was generated with Oz.

…k memory (APP-4686)

Previously, EditDelta::layout_delta ran all text layout tasks simultaneously
via into_par_iter(), which could cause 9+ GB memory spikes on large documents
from concurrent CoreText layout allocations across rayon worker threads.

This change processes layout tasks in sequential chunks of MAX_PARALLEL_LAYOUT_TASKS
(8 tasks), where each chunk runs in parallel. This bounds peak concurrent memory
to 8 text layout operations at once while preserving parallelism benefits for
each chunk.

The same fix is applied to layout_temporary_blocks.

The now-unused parallel_util module (Last<T>) has been removed.

Sentry: https://sentry.io/organizations/warpdotdev/issues/7259255054/

Co-Authored-By: Oz <oz-agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant