Skip to content

perf: RTS test64 GC tests allocate 192MB per seed (should be much smaller) #6030

@ggreif

Description

@ggreif

Problem

The incremental GC unit tests (test64) allocate 3 * PARTITION_SIZE = 192 MB per GC test invocation, where PARTITION_SIZE is 64 MB (designed for production canisters). With 100 random heap seeds, this means ~19.2 GB of allocation for testing tiny heaps (~180 small objects each).

This makes test64 orders of magnitude slower than the wasm32 GC tests, which scale heap size proportionally to the actual object count.

Evidence

  • test32-non-incremental: runs 3 GC variants × 100 seeds in seconds
  • test64: runs 1 GC variant (incremental) × 100 seeds in ~40+ minutes
  • The difference is entirely due to heap_size_for_gc returning 3 * PARTITION_SIZE (192 MB) regardless of object count

Suggested fix

Use a smaller partition size for tests, e.g.:

#[cfg(test)]
pub const PARTITION_SIZE: usize = 256 * 1024; // 256 KB for tests

#[cfg(not(test))]
pub const PARTITION_SIZE: usize = 64 * 1024 * 1024; // 64 MB for production

Or parametrise heap_size_for_gc to scale with the actual heap content, similar to the non-incremental variants.

Context

Found while investigating RTS test parallelism (#6029). The parallel test framework works correctly, but the speedup is limited because test64 dominates wall clock time.

Relevant code:

  • rts/motoko-rts-tests/src/gc/heap.rs:345-349
  • rts/motoko-rts/src/gc/incremental/partitioned_heap.rs (PARTITION_SIZE)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions