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

Eliminate allocation in Value.Find #7319

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

anderseknert
Copy link
Member

Mostly just some things I improved as I learnt more about how the storage system works. Reducing some allocations, and just general improvements.

  • Move some sync.Pool's to a common location
  • Allow object.Map to skip items when mapper returns nil key
  • Eliminate allocation in object.Find and array.Find when a scalar is encountered.
  • Use term pointer pool for temporary terms created only for the sake of calling object.Get in ptr.go

@@ -2375,15 +2376,18 @@ func (obj *object) Foreach(f func(*Term, *Term)) {
}

// Map returns a new Object constructed by mapping each element in the object
// using the function f.
// using the function f. If f returns an error, the error is returned by Map.
// If f return a nil key, the element is skipped.
Copy link
Member Author

Choose a reason for hiding this comment

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

This feature isn't used anywhere in this PR, but that will follow in the next one 😎

Mostly just some things I improved as I learnt more about how
the storage system works. Reducing some allocations, and just
general improvements.

- Move some sync.Pool's to a common location
- Allow object.Map to skip items when mapper returns nil key
- Eliminate allocation in object.Find and array.Find when a
  scalar is encountered.
- Use term pointer pool for temporary terms created only for
  the sake of calling object.Get in ptr.go

Signed-off-by: Anders Eknert <[email protected]>
@anderseknert anderseknert merged commit 34a7c93 into open-policy-agent:main Jan 28, 2025
28 checks passed
@anderseknert anderseknert deleted the store-perf branch February 11, 2025 19:11
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