Skip to content

Make Cache.Get allocation-free#162

Merged
davseby merged 3 commits intojellydator:v3from
yiftachkarkason:non-allocations-options
Feb 6, 2025
Merged

Make Cache.Get allocation-free#162
davseby merged 3 commits intojellydator:v3from
yiftachkarkason:non-allocations-options

Conversation

@yiftachkarkason
Copy link
Copy Markdown
Contributor

Changes

  • Changed applyOptions and the Option[K,V] to be non-allocating by avoiding pointers
  • Added the Test_Get_DoesNotAllocate to make sure that Get does not allocate (it fails before this commit)

Why
We encountered a performance issue when we heavily used the Cache, and narrowed it down to the allocation made by Cache.Get as part of the options processing.

Thank you for the great package!

Copy link
Copy Markdown
Contributor

@davseby davseby left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution.

Comment thread cache_test.go Outdated
Changed applyOptions and the Option[K,V] to be non-allocating by avoiding pointers

Added the Test_Get_DoesNotAllocate to make sure that Get does not allocate (it fails before this commit)
Copy link
Copy Markdown
Contributor

@swithek swithek left a comment

Choose a reason for hiding this comment

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

I think we can merge this? @davseby

Well done @yiftachkarkason

Comment thread cache_test.go Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented Feb 6, 2025

Pull Request Test Coverage Report for Build 13180247307

Details

  • 21 of 21 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 99.416%

Totals Coverage Status
Change from base Build 12845347580: 0.006%
Covered Lines: 681
Relevant Lines: 685

💛 - Coveralls

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.

4 participants