-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Asynchronous writes #12152
base: master
Are you sure you want to change the base?
Asynchronous writes #12152
Conversation
Updating repo
updating
@teto, all the commmits from my previous PR were also added, can this be avoided? EDIT: precious->previous |
prefix the pr with [WIP]. Yes you can create another branch and EDIT: and then force push this same branch with |
I will fix it and make another PR asap. EDIT: Also sorry for the mess earlier 😅 |
(cherry picked from commit df2cd42)
df2cd42
to
2b2ffdc
Compare
The code is working, I have to add the error display parts and fix the error messages, I can either add it to backup_utils or move those functions back to fileio.c |
There's another thing that needs to be done, since for restoring backups, we would need the backup name, I can make the backup global in the backup_utils.c file and use the restore function over there. That's what I have thought of for now. EDIT: But that might end up polluting the global namespace, just like the error variables are doing right now. I think I should do something else for it. |
@teto, Well, I will be working on the error reporting and the restore function now. What would then remain would be the final write function and calling them all asynchronously. PS: Also this isn't the final code that would be merged, this is just what's working for now, it requires cleanup for the unnecessary headers and the global namespace along with proper error reporting. I just wanted to get your views on the functions created and if something else is required. And thanks a lot for taking a look! :) |
// copy the file | ||
if (os_copy((char *)fname, (char *)backup, UV_FS_COPYFILE_FICLONE) | ||
!= 0) { | ||
SET_ERRMSG(_("E506: Can't write to backup file " | ||
"(add ! to override)")); | ||
} | ||
|
||
#ifdef UNIX | ||
os_file_settime((char *)backup, | ||
file_info_old.stat.st_atim.tv_sec, | ||
file_info_old.stat.st_mtim.tv_sec); | ||
#endif |
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.
@teto, A question:
Over here, if we fail copying the original file, we still try to set atime and mtime on the backup file. Is that intentional? What is the point of this if there is no file yet? If this isn't the case then I must have misunderstood something.
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.
It does seem weird. I tried a git blame on neovim source code but with little success. Checking against the vim source code (grep for buf_write), it seems to do the same (does not check against vim_rename success). This seems wrong.
@teto, for the async write, should I use an async flag in the IMO, just creating a wrapper around |
we can adjust the API later, make sure the behavior is correct first. |
@teto, a status update. I am making functions for asynchronous call right now. I will push as soon as a few of them are callable from a new thread. Also I am looking for better ways of implementing this if possible, since it still isn't too late for that. Upon trying to implement my approach of libuv work queues I realized that a huge baton would have to be passed around between multiple threads and the entire write function would be executed partly via the functions on a separate thread and partly via the callbacks passed to the work queue. Also I think I should use a new loop for this? EDIT: Breaking down the write function into such chunks is proving to be a rather daunting task, so it might take some more time before I push a commit. I hope that's not a problem. :) |
what do you mean a
Is the added complexity worth the gain ? we need to make sure what is saved is the content of the buffer when starting to save. Make sure to write some tests if needed and iterate while keeping the tests green. |
@teto, by the baton I mean the struct that must be maintained for transferring necessary values in
I'll make sure to write a few tests, also for the loop, in which loop should I queue these functions then? I thought having a separate loop for this would work better. I don't think it should be too complex. Just a EDIT: I think we should discuss the implementation details once again. Can I DM you? I'd like to discuss the current strategy and what better ways there could be if you're free? I will later comment the approach over here too for anyone else interested in following up. I believe that a discussion would be very helpful for the both of us, as in I'd have a better idea of how to do stuff without increasing the complexity too much, and reviewing this PR would be easier for you. :) |
@teto, here is a broad overview of the current implementation plan: This implementation plan requires a struct to pass things around in various threads. Which is what I referred to as the So I am open to any suggestions regarding the loop or even the implementation plan. EDIT: All the checks regarding the asynchronous calls would have to be done in their respective callbacks. Which mean that the write itself would be split into two parts, the functions executed asynchronously and the callbacks provided to them. So the synchronous write function would be a series of interleaved function and callback calls. |
Branch for implementing asynchronous writes in neovim.