-
-
Notifications
You must be signed in to change notification settings - Fork 192
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(blame): general improvements #878
Conversation
f6546d1
to
d15bbad
Compare
24ec1e3
to
2af115b
Compare
This keeps a single CPU at 100% while scrolling around (which is an improvement over keeping all CPUs at 100%). However, after completing a motion, it can take several seconds for a blame to show up (I assume that this is because the previous execution needs to exit before another instance of |
Yes that's exactly right. I can't do anything about 100% CPU utilisation as we can't make git magically more efficient. Note though that the results are cached. |
Fetching a single line: Fetching the entire file: I think that fetching the entire file and keeping that in memory pays of as soon as the cursor switches line at least once. That said, there are other considerations to take into account. Mostly, that changes would need to be tracked to understand when the in-memory blame data is stale. I definitely think that it's an option worth exploring, but I also understand that it might be a huge scope growth for the issue at hand (and for this plugin in general). |
This is definitely an improvement, thanks. My computer fans no longer jump to the maximum when I scroll through a file in a large repository. |
Thanks for looking into this. If it's only 2x slowdown then just blaming the whole file will probably be worth it like you said. Currently we invalidate the cache on any buffer change so we shouldn't need to track anything... for now, but tracking the changes would be a nice future improvement. I'll run a couple of benchmarks my end and look into changing the PR to blaming the whole file. |
2845a84
to
05cb146
Compare
e6e6138
to
30c57f0
Compare
30c57f0
to
48282c5
Compare
Previously current_line_blame would run a git-blame process per line (via the `-L` flag) in an attempt to be more efficient. However after some investigation it seems that running git-blame for the entire file rarely exceeds 2x the time it takes to run for a single line, even for large files. This change alters current_line_blame to run git-blame for the entire file after each buffer edit and caches that in memory. This makes the first git-blame after an edit ~2x slower, but makes any cursor movements after that instant. A follow-up to this would be for current_line_blame to track buffer updates to avoid the cache needing to be invalidated on every edit.
48282c5
to
8558382
Compare
Thanks again for this! The different in large repositories in incredible: my fans are a lot less noisy and the |
No problem happy to help! |
fix(blame): do not run concurrent processes
Limits the amount of git-blame processes in the background to 1
perf(blame): run blame for entire file instead of per line
Previously current_line_blame would run a git-blame process per line
(via the
-L
flag) in an attempt to be more efficient. However aftersome investigation it seems that running git-blame for the entire file
rarely exceeds 2x the time it takes to run for a single line, even for
large files.
This change alters current_line_blame to run git-blame for the entire
file after each buffer edit and caches that in memory. This makes the
first git-blame after an edit ~2x slower, but makes any cursor movements
after that instant.
A follow-up to this would be for current_line_blame to track buffer
updates to avoid the cache needing to be invalidated on every edit.
Fixes #877