Problem
macOS gives background threads only 512 KB stack. HybridBigInt + VSAVM allocate ~460 KB on stack in single instance.
Changes
src/hybrid.zig
- Move unpacked_cache from 59KB stack array [MAX_TRITS]Trit to 8-byte heap pointer (?[]Trit)
- Add allocator field for heap operations
- Add deinit() method for cleanup
- Update ALL methods to accept allocator parameter and ensure heap allocation
src/vsa/core.zig
- Update bundleN() to allocate 115KB accumulator on heap
- Update all VSA operations to pass allocator parameter
- Use safe access patterns for unpacked_cache
Metrics
| Metric |
Before |
After |
| HybridBigInt × 1 |
69.2 KB |
11.6 KB |
| HybridBigInt × 4 (VSAVM registers) |
276.8 KB |
46.2 KB |
| bundleN() accum |
115.3 KB |
0 KB (heap) |
| Total VSAVM |
~460 KB |
~70 KB |
macOS thread stack = 512 KB → 7.3× safety margin (370 KB free)
Problem
macOS gives background threads only 512 KB stack. HybridBigInt + VSAVM allocate ~460 KB on stack in single instance.
Changes
src/hybrid.zig
src/vsa/core.zig
Metrics
macOS thread stack = 512 KB → 7.3× safety margin (370 KB free)