Skip to content

Reduce memcached allocations#4970

Merged
joe-elliott merged 10 commits intografana:mainfrom
joe-elliott:improve-cache-perf
Apr 9, 2025
Merged

Reduce memcached allocations#4970
joe-elliott merged 10 commits intografana:mainfrom
joe-elliott:improve-cache-perf

Conversation

@joe-elliott
Copy link
Copy Markdown
Collaborator

@joe-elliott joe-elliott commented Apr 8, 2025

What this PR does:
I discovered this opportunity while researching panics in the querier. This PR reduces allocations related to using memcached caching by pooling buffers.

  • Use the memcached allocator option to pull buffers from a pool on read
  • Return buffers to the pool in frontend and object storage cache
  • Moved the prealloc buffer pool to pkg/pool to be used by cache
  • Removed the logic to copy before setting in cache. This is synchronous in both memcached and redis so there is no reason to copy.
  • Added a changelog for Bugfix? Improve EOF handling in readers.go #4963 b/c I forgot!

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Copy link
Copy Markdown
Contributor

@javiermolinar javiermolinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean up

Comment thread pkg/cache/memcached.go Outdated
Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott joe-elliott merged commit 3338cbf into grafana:main Apr 9, 2025
15 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.

2 participants