nuke icon indicating copy to clipboard operation
nuke copied to clipboard

Feature Request: Support makeMap for GC-optimized map implementation

Open hanjk1234 opened this issue 1 year ago • 1 comments

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)

hanjk1234 avatar Jan 06 '25 09:01 hanjk1234

Is some progress about this?

someview avatar Jul 16 '25 07:07 someview