-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fsync #6793
Fsync #6793
Conversation
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!
I knew fsync
but had to lookup the man page to understand fdatasync
. I wonder if we should have both syscalls as distinct methods, or if a single method, for example fsync(flush_metadata = true)
wouldn't be more explicit?
Ruby have them distinct (if that's any indicator), and the "closer to metal" the better i feel like at least. For anyone that knows what fdatasync is and want to do it, and search the docs and nothing come up might wonder why it's not implemented, unless they search the source code of course.
… On 26 Sep 2018, at 10:40, Julien Portalier ***@***.***> wrote:
@ysbaddaden commented on this pull request.
Thanks!
I wonder I knew fsync but had to lookup the man page to understand fdatasync. if we should have both syscalls as distinct methods, or if a single method, for example fsync(flush_metadata = true) wouldn't be more explicit?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#6793 (review)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAK_TlN871A0V55F3NdgjrmcJwzU4G9Tks5uez2VgaJpZM4W3-Ub>.
|
fdatasync isn't a thing in windows, so fdatasync would just call fsync. I'd be fine with having it as a parameter of fsync. |
That's true, but also "fsync" is not a thing in windows either so I don't know about that argument. Yes, we can call fsync if fdatasync is not supported by the OS (can be more than just windows). I for one very much appreciate closeness to the actual posix syscalls and less arbitrarily named flags. Is it a goal to minimise number of methods?
… On 26 Sep 2018, at 13:12, Chris Hobbs ***@***.***> wrote:
fdatasync isn't a thing in windows, so fdatasync would just call fsync. I'd be fine with having it as a parameter of fsync.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#6793 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAK_TnhNRyMo8biVlC0crrcg2B3rtxB8ks5ue2ECgaJpZM4W3-Ub>.
|
I also like being close to POSIX, but Crystal aims to be a little more intuitive and simplify such details —while still having them accessible when possible. A real thing is that we don't want aliases. Since |
anyone searching for fdatasync will quickly fall back to searching for fsync, and then find the parameter documented. |
Note that POSIX AIO has a single |
Updated with docs and a single method with a |
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.
Thank you!
Perhaps |
Don't you think it would be a bit confusing for a method called On another note, it's only when doing small rewrites of an existing file that fdatasync has an advantage over fsync (about 30% faster when doing 1KB rewrites). Doing append only writes or large rewrites (~1MB) makes fsync and fdatasync equally fast. |
Implementing fsync (and fdatasync) (fflush in windows) in the
File
class.The spec goes through even with a simple
File#flush
, suggestions on how to test it better are welcome.References:
https://linux.die.net/man/2/fsync
https://linux.die.net/man/2/fdatasync
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fflush?view=vs-2017
https://ruby-doc.org/core-2.5.1/IO.html#method-i-fsync