Replies: 1 comment
-
|
We are going with the old api if you stumble upon this discussion and could optimize the claims struct please submit a pr! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I have a
Claimstruct that may contain additional claims, defined as follows:This works well for me. Now, I have another struct called
Claims, which is used to organize all claims, so we can quickly retrieve claims by a specific label. The current definition ofClaimsis:The claims can be grouped as follows:
We will have different methods to help get different sets of claims, as defined below:
The Problem
The problem is that I’m concerned about the heap allocations when storing claims by label, which I believe could be avoided by storing all claims together and filtering them by predicate when needed.
Currently, the
Claimsstruct uses aHashMap<String, Vec<Claim>>to partition the claims by label. However, I am considering an alternative approach where all claims are stored together and filtered by label and predicate as needed.Proposed Solution
I’m considering changing the Claims struct to:
This would avoid the need for a Vec for each label and would store all claims together. When retrieving claims, they would be recursively arranged as needed, based on the label and any predicates.
Considerations
Performance Concerns: By storing all claims together, we might reduce heap allocations, but retrieving claims could require more processing (i.e., recursively arranging claims).
Complexity: The new structure might add complexity when retrieving or managing claims, especially if they need to be filtered by label and predicate.
Over-engineering?: Am I over-engineering the problem by trying to optimize heap allocation at this stage, or is this a valid concern for improving performance and memory usage?
Beta Was this translation helpful? Give feedback.
All reactions