Skip to content

Implement efficient large object allocation sizing #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

gmorpheme
Copy link
Member

Summary

  • Replace extremely wasteful power-of-two sizing with efficient tiered allocation boundaries
  • Add comprehensive large object block recycling infrastructure with best-fit selection
  • Replace Block dependency with direct system allocator access for arbitrary-sized allocations

Performance Improvements

  • Reduces memory waste from up to 50% down to typically 6-12%
  • Implements smart recycling to avoid repeated system allocations
  • Uses page-aligned allocations for better cache performance
  • Maintains reasonable allocation granularity for memory overhead control

Technical Details

  • Tiered sizing strategy: 16KB boundaries (≤128KB), 64KB boundaries (≤1MB), 256KB boundaries (>1MB)
  • Direct system allocation: Bypasses Block power-of-two constraint for large objects
  • Best-fit recycling: Selects recycled blocks with minimal waste percentage
  • Memory safety: Proper Drop implementation with matching Layout for deallocation

Test Coverage

  • Comprehensive size calculation tests across all boundary ranges
  • Waste percentage validation and efficiency comparisons vs power-of-two
  • Block recycling and best-fit selection validation
  • Integration with existing heap management infrastructure

🤖 Generated with Claude Code

gmorpheme and others added 2 commits June 17, 2025 18:25
Replace extremely wasteful power-of-two sizing with tiered allocation boundaries:
- Up to 128KB: round to 16KB boundaries (max ~12% waste)
- Up to 1MB: round to 64KB boundaries (max ~6% waste)
- Above 1MB: round to 256KB boundaries (max ~25% waste, rare)

Replace power-of-two Block dependency with direct system allocator access
to support arbitrary-sized allocations with page-aligned memory layout.

Add comprehensive large object block recycling infrastructure with best-fit
selection to maximize reuse and minimize fragmentation.

Performance improvements:
- Reduces memory waste from up to 50% down to typically 6-12%
- Implements smart recycling to avoid repeated system allocations
- Uses page-aligned allocations for better cache performance
- Maintains allocation granularity for reasonable memory overhead

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@gmorpheme gmorpheme changed the title Implement efficient large object allocation sizing (Issue #60) Implement efficient large object allocation sizing Jun 17, 2025
@gmorpheme gmorpheme merged commit 7ebf314 into master Jun 17, 2025
16 checks passed
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.

1 participant