-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Run :make, :grep, etc. asynchronously as a Job. #1241
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
Conversation
sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg, | ||
(char *)p_shq); | ||
if (*p_sp != NUL) | ||
append_redir(cmd, len, p_sp, fname); |
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.
The fastest output I ever got was by, instead of removing these, using NULL
for the callbacks and running mkfifo()
here, but that certainly isn't OS-independent.
Very nice. What happens if user initiates |
Far as I know, that can't happen because I call However, if the callback itself runs in parallel, we're in trouble. @tarruda, am I correct in my assumption that a job won't run the same callback twice in parallel? If not, is there a way to wait on the previous run to finish? |
When you call You might want to look if |
I was able to make this stop truncating lines due to the callback being sent partial reads, but lines greater than 1024 characters are being truncated still, whereas with the original code, newlines would be inserted, but I'm not sure why. (Perhaps that's a quirk of Also, the bytes seem to have been run through some conversion sort of because I get
That's where I stole this code from! :) |
Sounds like the encoding issue I was concerned about here: #1008 |
Not so sure any more. I had been copying the quick-fix window to a new buffer, saving as a file, then diffing that file against one generated by the master branch to ensure consistency. It looks right in the quick-fix window, and after yank/pasting into the new buffer--it's only upon loading the file that I see "ê" instead of "ê". |
f7f6ee7
to
4252198
Compare
Ok, all of my TODO items finished. Functionally, the Errors written to Lines above 1023 characters would be split up, previously, but that's because, when reading from a file, we call Output is no longer duplicated to stdout. This might be more a bad thing because on long |
I just discovered #473 and I think that implementing this in terms of a solution for that would be cleaner, so I'm marking this WIP until then. |
Thats great, thanks for giving it a shot. |
Replace the shell redirection pattern by spawning a job and sending qf_init_ext() the output through a callback instead of a file through qf_init(). This lets us build and update a quick-fix list while "make"/"grep" runs.
The "make error file" never gets used, running through a Job, but keep the option in place because a user may reference it with an old .vimrc.
Sometimes the RStream only contains part of a line because its buffer maxed out or it didn't get the whole message on the first read. Maintain partial line buffers to keep this data intact between calls and separate stdout from stdin.
:make and :grep do not write to an error file.
4252198
to
1d0668b
Compare
|
Not sure if this is the right way to do it, or even if it's a good thing to do, but these changes significantly improve the performance of the
:make
and:grep
families by running them asJob
s instead of redirecting to an outfile then reading from it. I used this tiny vim script to test the performance:and ran it with
$ build/bin/nvim -S grep.vim --cmd 'profile start grep.profile' --cmd 'profile! file grep.vim' -c 'DoIt'
The profiled time for the line
grep color **.c
:and with this PR:
Less than half the run time! Although I have found the gains vary with the size of the output, it's never slower.
TODO:
Doesn't seem to improve performance enough.qf_init_ext()
compiles several regex programs every time it's run. We can improve performance by saving the program and using it on the next run, but proving that skipping that massive code block is safe may be tricky.runtime/
.