Skip to content

[Feature]: Memory Management and Performance Optimizations #152

@eneshoxha

Description

@eneshoxha

1.1 Object Pooling for High-Frequency Operators

// Recommendation: Implement object pooling for frequently allocated types
public class OperatorObjectPool<T>
{
    private readonly ConcurrentBag<T> _pool = new();
    private readonly Func<T> _objectFactory;
    
    public OperatorObjectPool(Func<T> objectFactory) => _objectFactory = objectFactory;
    
    public T Get() => _pool.TryTake(out T item) ? item : _objectFactory();
    public void Return(T item) => _pool.Add(item);
}

// Apply to operators like Filter, Map that process high volumes

1.2 Reduce Boxing/Unboxing in Operator Chains

// Current issue: IOperator.Process(object input) causes boxing
public interface IOperator<TInput, TOutput>
{
    void Process(TInput input);
    void SetNext(IOperator<TOutput, TNext> nextOperator);
}

// Benefits: Eliminates boxing overhead, improves type safety

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestfeatureThis label is in use for minor version increments

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions