-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
perf: cache Document
s relative path
#12385
perf: cache Document
s relative path
#12385
Conversation
how do you generate this kind of graph? |
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.
Good catch!
I'm not sure if all of these should be labeled inline though, most of these functions are quite large (e.g. normalize
) and rust will already use it's own inlining heuristics, #[inline]
usually signals to inline across crate boundaries.
I'd only mark private functions in this package as inline.
If I recall correctly, it doesn't inline across crate boundaries without the attribute. Meaning these one spot usages that could very well be inlined wouldnt be able to without it. |
Also as far as improvement, its hard to say, but the samples for the |
I would prefer to drop the inlining for simplicity. From what I've read it seems like inlining can have unpredictable performance effects so it's always worth trying to measure the improvement from inlining. None of these functions should be called in a very tight loop so I would doubt that inlining has a significant impact in this case. |
Its not that it forces inlining, thats I can remove them if that's the final decision though. |
By "inlining" I mean |
Lol, I was a bit irritated, because I read However, in my opinion it isn't important how often a function is used, if the readability improves.
No, the compiler itself will inline code, if its heuristics approve it (assuming we are in release mode) even if you didn't explicitely apply the |
Not sure what adding an attribute has to do with naming of functions?
Yes, in the same crate. https://matklad.github.io/2021/07/09/inline-in-rust.html#Inlining-in-Rust |
Well I though you wanted to remove functions because they are only used once as described here: #12385 (comment) |
Ah, I see where that could have been mixed up. Yeah, I meant that because the functions were only used in one spot that it could have been something the optimizer could just inline if it had decided so, if it had the capability to do so with the attribute(cross crate: I do see another area where these could be improved though, particularly the larger functions. As they are generic over AsRef, the function could be generated more than once due to monomorphization, as it could take a &PathBuf, PathBuf, or even a String(or &str) for example. The function body could be lifted out to an impl function that just takes a Path and then have the generic |
3f11711
to
488c602
Compare
7b60c6d
to
0c89357
Compare
0c89357
to
c8ea857
Compare
Should I remove |
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.
Thanks! Nice to get better encapsulation alongside a performance improvement 👍
I think those are fine, the stdx path module is fairly new and I don't think is touched in any open PRs |
helix_stdx::path::get_relative_path
was always performed for the statusline render. This PR now caches the relative path inDocument
instead.(Highlighted in purple:
statusline::render
)Before:
After: