Dropping eBPF CPU Cost by About 90% with Memoization (Not AI Gen)

104 points - yesterday at 2:29 PM

Source

Comments

salviati today at 8:06 AM
Memoization trades compute time for memory: you reduce CPU cost by 90% _at the cost_ of some memory. The author measured one, but it doesn't look like they measured the other.

It's an important detail to take into account. I'm sure this optimization makes sense, and the size of additional memory is not that big, but I believe it's good to "measure, not assume" as some load bearing model might say.

danudey yesterday at 11:03 PM
Very confused by the article. Is memoization new to the eBPF world? Did the author only just learn about it and wanted to use it?

In reality, the article is about correctly caching a path:policy mapping while working within the limitations of eBPF and Linux filesystem semantics. If you read the article in that context rather than wondering 'what is new and interesting about memoization in eBPF?' it's a lot more interesting.

I probably would have titled this 'Calculating cache keys for filesystem paths in eBPF' or something, since that's the cool and interesting problem that was solved.

Allybag today at 3:35 AM
Seems like the 90% faster case is opening the same exact file every single time, which seems like a not super standard use case that will benefit the most from this caching. On an example where you never open the same file twice this will presumably be slightly slower than before, as you’re doing the same thing but writing to a cache. So you can make the headline “Drop performance cost by 90%!” or “Modestly increase performance cost” and be correct but I don’t think either is really a reasonable description of the change.
brookman64k today at 5:40 AM
How is the cache invalidated when: - The permissions change? - Directories are moved? - Hard-links are added? - Things are deleted? Also: Is the cache limited in size?
ComputerGuru today at 3:44 AM
How do your path-only rules handle the many approaches for loading a file but making it appear to have a different path, such as bind mounts for one example?
bawolff today at 1:49 AM
Umm, wouldn't this break if you moved a directory that is somewhere up the path? Seems like a security issue if you cache what policy applies but the policy could change by user action.
mrbluecoat yesterday at 10:59 PM
So you highlight "Not AI Gen" but you call the solution "Agent"? :D
youngtaff today at 6:36 AM
OT but… it’s nice to see someone use a legible font with good character height and line spacing

Makes the post a joy to read

yxhuvud today at 4:15 AM
And uh, what happens if the active user permission changes?
nirmeetimthebes today at 3:24 AM
[dead]
self_awareness today at 5:34 AM
TL;DR - use in-memory cache instead of expensive database lookups on every iteration
aaron695 today at 6:53 AM
[dead]
asdfman123 today at 12:16 AM
I don't know what any of these acronyms mean. With just a little more explanation the article could be accessible to a wider developer audience.
visarga today at 5:50 AM
> Not AI Gen

I am not sure how to react ... of course good thing it's human-gen, but I still like a few AI passes over it to tighten it up. LOL