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

[refactor] - Optimize memory usage for small chunks in readInChunks #3081

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented Jul 19, 2024

Description:

This PR introduces an optimization to reduce memory usage when processing
small chunks of data in the readInChunks function. Key changes include:

  1. Added a smallChunkThresholdRatio constant (set to 0.3) to define when
    a chunk is considered "small".
  2. Modified chunkReaderConfig to include a pre-calculated smallChunkThreshold.
  3. Updated readInChunks to create a new, optimized slice only for chunks
    smaller than the threshold.

This optimization aims to improve memory efficiency for smaller chunks
while maintaining performance for larger ones. It should reduce unnecessary
memory allocation and potentially improve the speed of downstream operations
like FindDetectorMatches for smaller data chunks.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@ahrav ahrav changed the title [refactor] - Optimize memory usage for small chunks in readInChunks function [refactor] - Optimize memory usage for small chunks in readInChunks Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant