Repository navigation
btf: parse BTF types in a single pass during decoder initialization - #2082
DARSHANR007 wants to merge 1 commit into
Conversation
newDecoder currently scans the BTF buffer twice: once to count the number of types and a second time to parse them. Estimate the maximum number of types upfront from the buffer length and parse all types in a single pass instead. Signed-off-by: darsh <[email protected]>
|
I must say I am not super convinced. I ran the benchmark myself as well, getting the following result: So we speed up 4% on average, in exchange for a 227% increase in temporary memory usage. Likely due to now having to resize the fuzzy string index and decl tags index multiple times. This method also grossly overestimates the amount of offsets, leading to I don't think this tradeoff is worth. |
|
Yep, quadrupling allocs for a low-single digit % gain in wall clock time is typically not what our users ask for. On the contrary, memory consumption gets much more heavily scrutinized as it sticks around for longer in caches and throughout GC cycles. |
Fixes #2081
newDecoder()currently scans the raw BTF buffer twice: once to count the number of types and a second time to parse them into memory.Since every BTF type header is at least 12 bytes (
btfTypeSize), we can estimate the maximum possible number of types upfront (len(raw) / btfTypeSize) and parse all types in a single pass instead.