Skip to content

Wasm RAM - #274

Draft
tameware wants to merge 10 commits into
dds-bridge:developfrom
tameware:wasm-ram
Draft

Wasm RAM#274
tameware wants to merge 10 commits into
dds-bridge:developfrom
tameware:wasm-ram

Conversation

@tameware

@tameware tameware commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Do not request more than 2GB RAM from WASM, its limit. The messages generated on exceeding it are apparently harmless, but best to avoid them.

This change must be totally isolated from the native builds, otherwise it slows them down by ~5%. I'm still trying to figure out why.

tameware and others added 4 commits July 27, 2026 05:07
Uncapped auto thread counts allocate one Large TT per worker and OOM large WASM batches; clamp to a fixed memory budget instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep native thread counts uncapped so the WASM heap guard does not change host performance.

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid pulling api/dds.h into the native parallel_boards TU so host codegen of the hot path stays unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep native parallel_boards identical to develop so the heap guard cannot change host codegen of the hot path.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a WASM-specific cap on parallel worker count so DDS doesn’t request more than the practical wasm32 heap limit (~2 GiB), avoiding noisy (but apparently harmless) out-of-memory warnings on large WASM batches while keeping native builds unaffected.

Changes:

  • Introduces a small helper (clamp_workers_to_memory_budget) to cap worker count by a total heap budget and per-worker footprint.
  • Adds an Emscripten-only parallel_boards_wasm.cpp implementation that applies a worker cap based on THREADMEM_LARGE_DEF_MB and a fixed heap budget.
  • Extends system tests to validate the clamp behavior and ensure native builds do not apply the WASM cap.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
library/tests/system/worker_count_test.cpp Adds unit tests for the new memory-budget clamp and for WASM-vs-native worker count behavior.
library/src/system/worker_memory_budget.hpp Declares the helper used to cap worker counts by a memory budget (MB).
library/src/system/worker_memory_budget.cpp Implements the worker-count clamping logic.
library/src/system/parallel_boards_wasm.cpp WASM-specific parallel boards implementation that applies the heap-based worker cap.
library/src/system/BUILD.bazel Uses a select() to compile either the native or WASM parallel_boards implementation depending on the build platform.
Comments suppressed due to low confidence (1)

library/src/system/worker_memory_budget.hpp:22

  • The @return description currently omits that the result is also capped by the requested worker count; documenting the exact clamp makes the contract clearer.
 * @return workers clamped to max(1, budget_mb / per_worker_mb)

Comment thread library/src/system/BUILD.bazel Outdated
Comment thread library/tests/system/worker_count_test.cpp Outdated
Comment thread library/src/system/worker_memory_budget.hpp Outdated
tameware and others added 5 commits July 27, 2026 17:07
Bring in dtest WASM clean exit and board-pool shutdown so the wasm-only
parallel_boards TU can stay API-compatible with develop.
Rebuild it from the current board-pool implementation so shutdown_parallel_boards_pool links under Emscripten after merging dtest clean exit.

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid referring to the develop branch in the BUILD comment so the split reads as a host/Emscripten source choice.

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid hard-coding the Large TT default so the clamp tests stay aligned if that constant changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Note that the clamp lives in its own .cpp rather than referring to develop.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread library/src/system/parallel_boards_wasm.cpp
Call out that only resolve_worker_count should differ, reducing drift risk between the duplicated worker-pool implementations.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants