Optimize NodePath#113447
Conversation
co-authored-by: Ryan-000 <73148864+Ryan-000@users.noreply.github.com>
There was a problem hiding this comment.
Makes sense to me.
The if condition itself should be almost free1.
In contrast, many paths will probably pass the absolute check, and start comparing path parts. Each indirection could incur cache misses, which are very expensive in comparison2.
The only caveat i have is that I don't know how many NodePath instances have a valid hash cache, so I don't know how often this check will actually help in practice.
But this will be hard to estimate, and like I mentioned, the potential regression vs potential benefit is fairly large, so I think this is fine.
Footnotes
-
See the cost of comparisons and jumps, both of which are just a few cycles https://www.agner.org/optimize/optimizing_cpp.pdf ↩
-
See the cost of cache misses https://www.agner.org/optimize/optimizing_cpp.pdf ↩
|
Thanks! |
co-authored-by: @Ryan-000