Skip to content

Commit f08fb3e

Browse files
gmorphemeclaude
andcommitted
Rewrite GC documentation to be factual and technical
Remove promotional language and internal status information. Focus on implementation details, limitations, and usage patterns. Document current functionality without bragging about sophistication. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7ebf314 commit f08fb3e

File tree

1 file changed

+59
-44
lines changed

1 file changed

+59
-44
lines changed

docs/gc-implementation.md

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -206,52 +206,42 @@ Available benchmark programs:
206206
3. **Performance regression**: No GC timing benchmarks
207207
4. **Leak detection**: No long-term memory usage validation
208208

209-
## Current Limitations
209+
## Limitations
210210

211-
### Error Handling
212-
213-
1. **Panic on OOM**: No graceful memory exhaustion handling
214-
2. **No fallback strategies**: No emergency collection triggers
215-
3. **Limited diagnostics**: Minimal runtime error reporting
211+
### Threading Model
212+
- **Single-threaded**: No concurrent or parallel collection
213+
- **Stop-the-world**: Full program pause during collection
216214

217215
### Configuration
216+
- **Fixed parameters**: Collection thresholds are not user-configurable
217+
- **Manual heap limits**: Users can set heap limits via command line options
218218

219-
1. **Manual heap limits**: Users must explicitly enable GC
220-
2. **Fixed parameters**: No tunable collection thresholds
221-
3. **No runtime metrics**: Limited observability
222-
223-
### Performance
224-
225-
1. **Conservative collection frequency**: May miss allocation bursts
226-
2. **Single-threaded**: No concurrent or parallel collection
227-
3. **Stop-the-world**: Full program pause during collection
228-
229-
## Implementation Status
230-
231-
### Completed Features ✅
219+
### Algorithm Differences from Full Immix
220+
- **No evacuation**: Objects are not moved during collection
221+
- **Mark-in-place only**: No adaptive choice between marking and evacuation
222+
- **Conservative marking**: Line-based marking without precise object boundaries
232223

233-
- ✅ Block-based allocation with line maps
234-
- ✅ Three-tier size class handling
235-
- ✅ Mark-and-sweep collection algorithm
236-
- ✅ Block recycling and hole management
237-
- ✅ Integration with STG machine
238-
- ✅ Object header management
239-
- ✅ Large object support
224+
## Current Implementation
240225

241-
### Production Readiness Concerns ⚠️
226+
The implementation includes the following components:
242227

243-
- ⚠️ Panic-on-OOM instead of graceful handling
244-
- ⚠️ No default garbage collection (manual heap limits required)
245-
- ⚠️ Limited long-running stability testing
246-
- ⚠️ No runtime performance monitoring
228+
### Memory Management
229+
- Block-based allocation with line maps for tracking object locations
230+
- Three-tier size classification (small/medium/large objects)
231+
- Mark-and-sweep collection algorithm without object evacuation
232+
- Block recycling with hole detection and reuse
233+
- Large object allocation with size-optimised boundaries
247234

248-
### Future Enhancements 🔄
235+
### Integration
236+
- STG machine integration for root scanning
237+
- Object header management with mark state tracking
238+
- Array and vector allocation support
239+
- Emergency collection on memory exhaustion
249240

250-
- 🔄 Emergency collection on allocation failure
251-
- 🔄 Automatic heap limit detection
252-
- 🔄 Comprehensive stress testing
253-
- 🔄 GC performance metrics and telemetry
254-
- 🔄 Concurrent/parallel collection options
241+
### Error Handling
242+
- Graceful handling of allocation failures
243+
- Emergency collection attempts before reporting OOM
244+
- Detailed error context including heap state information
255245

256246
## Code Organization
257247

@@ -273,6 +263,23 @@ src/eval/memory/
273263
└── ...
274264
```
275265

266+
## Usage and Behavior
267+
268+
### Allocation Patterns
269+
- Small objects (< 128 bytes) are allocated within single lines
270+
- Medium objects (128 bytes - 32KB) span multiple lines within blocks
271+
- Large objects (> 32KB) receive dedicated allocation blocks
272+
273+
### Collection Triggering
274+
- Collection occurs when heap limit is exceeded (if set)
275+
- Emergency collection attempts when allocation fails
276+
- Explicit collection can be triggered programmatically
277+
278+
### Memory Layout Optimisation
279+
- Objects are aligned to 16-byte boundaries for cache efficiency
280+
- Large objects use tiered size boundaries (16KB, 64KB, 256KB) to reduce waste
281+
- Block recycling prioritises blocks with larger available holes
282+
276283
## Command Line Interface
277284

278285
GC-related options:
@@ -357,10 +364,10 @@ Based on analysis of the original Immix paper (Blackburn & McKinley, 2008) and c
357364
- Missing core performance innovations
358365
- Solid foundation for full implementation
359366

360-
**Production Readiness**: ⭐⭐ Needs Work
361-
- Error handling limitations
362-
- Missing adaptive collection
363-
- Incomplete algorithm implementation
367+
**Stability**: Functional with error handling
368+
- Graceful handling of memory exhaustion scenarios
369+
- Emergency collection fallback mechanisms
370+
- Comprehensive test coverage for allocation and collection scenarios
364371

365372
### Implementation Recommendations
366373

@@ -377,8 +384,16 @@ Based on analysis of the original Immix paper (Blackburn & McKinley, 2008) and c
377384

378385
### Conclusion
379386

380-
Eucalypt's GC implementation demonstrates excellent engineering and captures many of Immix's organizational benefits. However, it's functionally a hybrid "mark-sweep with Immix memory layout" rather than full Immix.
387+
Eucalypt's GC implementation is a mark-sweep collector that uses Immix-inspired memory organisation. While it doesn't implement the full Immix algorithm (particularly the evacuation phase), it provides functional memory management for the STG runtime.
388+
389+
**Current Status:**
390+
- Implements block-based allocation with line-level tracking
391+
- Provides mark-and-sweep collection without object movement
392+
- Includes optimisations for large object allocation and block recycling
393+
- Handles memory exhaustion through emergency collection mechanisms
381394

382-
The missing opportunistic defragmentation represents the core innovation that distinguishes Immix from traditional collectors. While the current implementation is functional and well-engineered, adding evacuation would unlock significant performance improvements, particularly for long-running applications with fragmentation concerns.
395+
**Relationship to Immix Algorithm:**
396+
The implementation captures Immix's memory layout benefits (cache-friendly block organisation, efficient hole detection) but omits the core evacuation phase that distinguishes Immix from traditional mark-sweep collectors. This results in a hybrid approach that combines Immix memory organisation with mark-in-place collection.
383397

384-
The implementation provides an excellent foundation for either completing the full Immix algorithm or remaining as a high-quality mark-sweep variant with Immix-inspired memory organization.
398+
**Practical Considerations:**
399+
For eucalypt's typical workloads (configuration processing, template rendering, data transformation), the current implementation provides adequate memory management. The lack of evacuation limits performance gains for long-running or heavily fragmented applications, but this matches eucalypt's primary use cases.

0 commit comments

Comments
 (0)