-
-
Notifications
You must be signed in to change notification settings - Fork 1
Heap-allocated HybridBigInt — macOS stack overflow fix #500
Copy link
Copy link
Closed
Description
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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels