Skip to content
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

Feature Request: Support makeMap for GC-optimized map implementation #26

Open
hanjk1234 opened this issue Jan 6, 2025 · 0 comments
Open

Comments

@hanjk1234
Copy link

Feature Request

Add support for creating GC-optimized maps via a makeMap function, similar to Go's built-in make function.

Background

When working with arena allocator in high-performance scenarios, maps remain a bottleneck as they are still subject to GC scanning even when other data structures are allocated in arena. This becomes particularly problematic in applications handling large amounts of data where GC pressure needs to be minimized.

Current Limitation

Currently, while nuke provides excellent support for arena allocation, maps cannot be allocated in arena memory. This means that even in code heavily optimized with arena allocations, maps still contribute to GC overhead.

Proposed Solution

Add a makeMap function that creates a map-like data structure optimized for minimal GC scanning. The implementation could:

  1. Use contiguous memory blocks for storage
  2. Avoid pointer types in the internal implementation
  3. Support basic map operations while minimizing GC overhead
  4. Potentially support type parameters for type safety

Example usage:

// Create a new GC-optimized map
m := nuke.MakeMap[uint64, uint64](initialSize)

// Basic operations
m.Put(key, value)
val, exists := m.Get(key)
m.Delete(key)
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

No branches or pull requests

1 participant