-
Notifications
You must be signed in to change notification settings - Fork 21
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
Replace GraphMap’s map with a moka::sync::Cache #1224
base: main
Are you sure you want to change the base?
Conversation
We should add some tests around the cache eviction edge cases:
|
… safe. Signed-off-by: Hiram Chirino <[email protected]>
This is needed since the graph map may evict an entry after it’s loaded. This allows The request to hold onto all the graphs need to process the current request. Signed-off-by: Hiram Chirino <[email protected]>
…tions. Signed-off-by: Hiram Chirino <[email protected]>
pub(crate) fn set_approximate_memory_size(&self) -> PackageNode { | ||
// Is there a better way to do this? | ||
let size = size_of::<PackageNode>() | ||
+ self.sbom_id.len() | ||
+ self.node_id.len() | ||
+ self.purl.iter().fold(0, |acc, purl| | ||
// use the json string length as an approximation of the memory size | ||
acc + serde_json::to_string(purl).unwrap_or_else(|_| "".to_string()).len()) | ||
+ self.cpe.iter().fold(0, |acc, cpe| | ||
// use the json string length as an approximation of the memory size | ||
acc + serde_json::to_string(cpe).unwrap_or_else(|_| "".to_string()).len()) | ||
+ self.name.len() | ||
+ self.version.len() | ||
+ self.published.len() | ||
+ self.document_id.len() | ||
+ self.product_name.len() | ||
+ self.product_version.len(); | ||
|
||
PackageNode { | ||
approximate_memory_size: size.try_into().unwrap_or(u32::MAX), | ||
..self.clone() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to estimate how much memory this thing uses up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda assuming that saving the approximate_memory_size will give us savings later, it might not.
This allows test results to be consistent. Signed-off-by: Hiram Chirino <[email protected]>
@JimFuller-RedHat I think I'm happy with this now. I'm going to keep it draft until #1217 goes in so you guys don't suffer the conflicts. But if you have idle time maybe worth a gander in case you think this went in the wrong direction. |
Fixes issue #1218