Message ID | pull.1076.v2.git.git.1630108177.gitgitgadget@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | Implement a batched fsync option for core.fsyncObjectFiles | expand |
On Fri, Aug 27, 2021 at 4:49 PM Neeraj K. Singh via GitGitGadget <gitgitgadget@gmail.com> wrote: > > Thanks to everyone for review so far! I've responded to the previous > feedback and changed the patch series a bit. > > Changes since v1: > > * Switch from futimes(2) to futimens(2), which is in POSIX.1-2008. Contrary > to dscho's suggestion, I'm still implementing the Windows version in the > same patch and I'm not doing autoconf detection since this is a POSIX > function. > > * Introduce a separate preparatory patch to the bulk-checkin infrastructure > to separate the 'plugged' variable and rename the 'state' variable, as > suggested by dscho. > > * Add performance numbers to the commit message of the main bulk fsync > patch, as suggested by dscho. > > * Add a comment about the non-thread-safety of the bulk-checkin > infrastructure, as suggested by avarab. > > * Rename the experimental mode to core.fsyncobjectfiles=batch, as suggested > by dscho and avarab and others. > > * Add more details to Documentation/config/core.txt about the various > settings and their intended effects, as suggested by avarab. > > * Switch to the string-list API to hold the rename state, as suggested by > avarab. > > * Create a separate update-index patch to use bulk-checkin as suggested by > dscho. > > * Add Windows support in the upstream git. This is done in a way that > should not conflict with git-for-windows. > > * Add new performance tests that shows the delta based on fsync mode. > > NOTE: Based on Christoph Hellwig's comments, the 'batch' mode is not correct > on Linux, since sync_file_range does not provide data integrity guarantees. > There is currently no kernel interface suitable to achieve disk flush > batching as is, but he suggested that he might implement a 'syncfs' variant > on top of this patchset. This code is still useful on macOS and Windows, and > the config documentation makes that clear. > > Neeraj Singh (6): > object-file: use futimens rather than utime > bulk-checkin: rename 'state' variable and separate 'plugged' boolean > core.fsyncobjectfiles: batched disk flushes > core.fsyncobjectfiles: add windows support for batch mode > update-index: use the bulk-checkin infrastructure > core.fsyncobjectfiles: performance tests for add and stash > > Documentation/config/core.txt | 26 ++++++-- > Makefile | 6 ++ > builtin/add.c | 3 +- > builtin/update-index.c | 3 + > bulk-checkin.c | 92 +++++++++++++++++++++++++---- > bulk-checkin.h | 4 +- > cache.h | 8 ++- > compat/mingw.c | 53 +++++++++++------ > compat/mingw.h | 5 ++ > compat/win32/flush.c | 29 +++++++++ > config.c | 8 ++- > config.mak.uname | 4 ++ > configure.ac | 8 +++ > contrib/buildsystems/CMakeLists.txt | 3 +- > environment.c | 2 +- > git-compat-util.h | 7 +++ > object-file.c | 23 ++------ > t/perf/lib-unique-files.sh | 32 ++++++++++ > t/perf/p3700-add.sh | 43 ++++++++++++++ > t/perf/p3900-stash.sh | 46 +++++++++++++++ > wrapper.c | 40 +++++++++++++ > write-or-die.c | 2 +- > 22 files changed, 389 insertions(+), 58 deletions(-) > create mode 100644 compat/win32/flush.c > create mode 100644 t/perf/lib-unique-files.sh > create mode 100755 t/perf/p3700-add.sh > create mode 100755 t/perf/p3900-stash.sh > > > base-commit: 225bc32a989d7a22fa6addafd4ce7dcd04675dbf > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1076%2Fneerajsi-msft%2Fneerajsi%2Fbulk-fsync-object-files-v2 > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1076/neerajsi-msft/neerajsi/bulk-fsync-object-files-v2 > Pull-Request: https://github.com/git/git/pull/1076 Hello everyone, I'd like to bump this review up in people's inboxes since Patch V2 hasn't gotten any traction in over a week. Thanks in advance for taking a look, - Neeraj Singh Windows Core Filesystems Team
On Tue, Sep 07 2021, Neeraj Singh wrote: > On Fri, Aug 27, 2021 at 4:49 PM Neeraj K. Singh via GitGitGadget > <gitgitgadget@gmail.com> wrote: >> >> Thanks to everyone for review so far! I've responded to the previous >> feedback and changed the patch series a bit. >> >> Changes since v1: >> >> * Switch from futimes(2) to futimens(2), which is in POSIX.1-2008. Contrary >> to dscho's suggestion, I'm still implementing the Windows version in the >> same patch and I'm not doing autoconf detection since this is a POSIX >> function. >> >> * Introduce a separate preparatory patch to the bulk-checkin infrastructure >> to separate the 'plugged' variable and rename the 'state' variable, as >> suggested by dscho. >> >> * Add performance numbers to the commit message of the main bulk fsync >> patch, as suggested by dscho. >> >> * Add a comment about the non-thread-safety of the bulk-checkin >> infrastructure, as suggested by avarab. >> >> * Rename the experimental mode to core.fsyncobjectfiles=batch, as suggested >> by dscho and avarab and others. >> >> * Add more details to Documentation/config/core.txt about the various >> settings and their intended effects, as suggested by avarab. >> >> * Switch to the string-list API to hold the rename state, as suggested by >> avarab. >> >> * Create a separate update-index patch to use bulk-checkin as suggested by >> dscho. >> >> * Add Windows support in the upstream git. This is done in a way that >> should not conflict with git-for-windows. >> >> * Add new performance tests that shows the delta based on fsync mode. >> >> NOTE: Based on Christoph Hellwig's comments, the 'batch' mode is not correct >> on Linux, since sync_file_range does not provide data integrity guarantees. >> There is currently no kernel interface suitable to achieve disk flush >> batching as is, but he suggested that he might implement a 'syncfs' variant >> on top of this patchset. This code is still useful on macOS and Windows, and >> the config documentation makes that clear. >> >> Neeraj Singh (6): >> object-file: use futimens rather than utime >> bulk-checkin: rename 'state' variable and separate 'plugged' boolean >> core.fsyncobjectfiles: batched disk flushes >> core.fsyncobjectfiles: add windows support for batch mode >> update-index: use the bulk-checkin infrastructure >> core.fsyncobjectfiles: performance tests for add and stash >> >> Documentation/config/core.txt | 26 ++++++-- >> Makefile | 6 ++ >> builtin/add.c | 3 +- >> builtin/update-index.c | 3 + >> bulk-checkin.c | 92 +++++++++++++++++++++++++---- >> bulk-checkin.h | 4 +- >> cache.h | 8 ++- >> compat/mingw.c | 53 +++++++++++------ >> compat/mingw.h | 5 ++ >> compat/win32/flush.c | 29 +++++++++ >> config.c | 8 ++- >> config.mak.uname | 4 ++ >> configure.ac | 8 +++ >> contrib/buildsystems/CMakeLists.txt | 3 +- >> environment.c | 2 +- >> git-compat-util.h | 7 +++ >> object-file.c | 23 ++------ >> t/perf/lib-unique-files.sh | 32 ++++++++++ >> t/perf/p3700-add.sh | 43 ++++++++++++++ >> t/perf/p3900-stash.sh | 46 +++++++++++++++ >> wrapper.c | 40 +++++++++++++ >> write-or-die.c | 2 +- >> 22 files changed, 389 insertions(+), 58 deletions(-) >> create mode 100644 compat/win32/flush.c >> create mode 100644 t/perf/lib-unique-files.sh >> create mode 100755 t/perf/p3700-add.sh >> create mode 100755 t/perf/p3900-stash.sh >> >> >> base-commit: 225bc32a989d7a22fa6addafd4ce7dcd04675dbf >> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1076%2Fneerajsi-msft%2Fneerajsi%2Fbulk-fsync-object-files-v2 >> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1076/neerajsi-msft/neerajsi/bulk-fsync-object-files-v2 >> Pull-Request: https://github.com/git/git/pull/1076 > > Hello everyone, > I'd like to bump this review up in people's inboxes since Patch V2 > hasn't gotten any traction in over a week. > > Thanks in advance for taking a look, > - Neeraj Singh > Windows Core Filesystems Team Thanks, I've been meaning to take a look at this, and also as a note-to-self: check how this interacts with the fsync()-impacted race I noted in my just-sent: https://lore.kernel.org/git/cover-0.3-00000000000-20210907T193600Z-avarab@gmail.com/
On September 7, 2021 3:44 PM, Neeraj Singh wrote: >On Fri, Aug 27, 2021 at 4:49 PM Neeraj K. Singh via GitGitGadget <gitgitgadget@gmail.com> wrote: >> >> Thanks to everyone for review so far! I've responded to the previous >> feedback and changed the patch series a bit. >> >> Changes since v1: >> >> * Switch from futimes(2) to futimens(2), which is in POSIX.1-2008. Contrary >> to dscho's suggestion, I'm still implementing the Windows version in the >> same patch and I'm not doing autoconf detection since this is a POSIX >> function. While POSIX.1-2008, this function is not available on every single POSIX-compliant platform. Please make sure that the code will not cause a breakage on some platforms - the ones I maintain, in particular. Neither futimes nor futimens is available on either NonStop ia64 or x86. The platform only has utime, so this needs to be wrapped with an option in config.mak.uname. Thanks, Randall
On Tue, Sep 7, 2021 at 12:54 PM Randall S. Becker <rsbecker@nexbridge.com> wrote: > > On September 7, 2021 3:44 PM, Neeraj Singh wrote: > >On Fri, Aug 27, 2021 at 4:49 PM Neeraj K. Singh via GitGitGadget <gitgitgadget@gmail.com> wrote: > >> > >> Thanks to everyone for review so far! I've responded to the previous > >> feedback and changed the patch series a bit. > >> > >> Changes since v1: > >> > >> * Switch from futimes(2) to futimens(2), which is in POSIX.1-2008. Contrary > >> to dscho's suggestion, I'm still implementing the Windows version in the > >> same patch and I'm not doing autoconf detection since this is a POSIX > >> function. > > While POSIX.1-2008, this function is not available on every single POSIX-compliant platform. Please make sure that the code will not cause a breakage on some platforms - the ones I maintain, in particular. Neither futimes nor futimens is available on either NonStop ia64 or x86. The platform only has utime, so this needs to be wrapped with an option in config.mak.uname. > > Thanks, > Randall Ugh. Fair enough. How do other contributors feel about me moving back to utime, but instead just doing the utime over in builtins/pack-objects.c? The idea would be to eliminate the mtime logic entirely from write_loose_object and just do it at the top-level in loosen_unused_packed_objects. Thanks, Neeraj
On Tue, Sep 7, 2021 at 12:44 PM Neeraj Singh <nksingh85@gmail.com> wrote: > > Hello everyone, > I'd like to bump this review up in people's inboxes since Patch V2 > hasn't gotten any traction in over a week. > > Thanks in advance for taking a look, > - Neeraj Singh > Windows Core Filesystems Team BTW, I updated the github PR to enable batch mode everywhere, and all the tests passed, which is good news to me. Thanks, Neeraj
On Tue, Sep 07 2021, Neeraj Singh wrote: > On Tue, Sep 7, 2021 at 12:54 PM Randall S. Becker > <rsbecker@nexbridge.com> wrote: >> >> On September 7, 2021 3:44 PM, Neeraj Singh wrote: >> >On Fri, Aug 27, 2021 at 4:49 PM Neeraj K. Singh via GitGitGadget <gitgitgadget@gmail.com> wrote: >> >> >> >> Thanks to everyone for review so far! I've responded to the previous >> >> feedback and changed the patch series a bit. >> >> >> >> Changes since v1: >> >> >> >> * Switch from futimes(2) to futimens(2), which is in POSIX.1-2008. Contrary >> >> to dscho's suggestion, I'm still implementing the Windows version in the >> >> same patch and I'm not doing autoconf detection since this is a POSIX >> >> function. >> >> While POSIX.1-2008, this function is not available on every single >> POSIX-compliant platform. Please make sure that the code will not >> cause a breakage on some platforms - the ones I maintain, in >> particular. Neither futimes nor futimens is available on either >> NonStop ia64 or x86. The platform only has utime, so this needs to >> be wrapped with an option in config.mak.uname. >> >> Thanks, >> Randall > > Ugh. Fair enough. How do other contributors feel about me moving back > to utime, but instead just doing the utime over in > builtins/pack-objects.c? The idea would be to eliminate the mtime > logic entirely from write_loose_object and just do it at the top-level > in loosen_unused_packed_objects. Aside from where it lives, can't we just have a wrapper that takes both the filename & fd, and then on some platforms will need to dispatch to a slower filename-only version, but can hopefully use the new fd-accepting function?
Neeraj Singh <nksingh85@gmail.com> writes: > BTW, I updated the github PR to enable batch mode everywhere, and all > the tests passed, which is good news to me. I doubt that fsyncObjectFiles is something we can reliably test in CI, either with the new batched thing or with the original "when we close one, make sure the changes hit the disk platter" approach. So I am not sure what conclusion we should draw from such an experiment, other than "ok, it compiles cleanly." After all, unless we cause system crashes, what we thought we have written and close(2) would be seen by another process that we spawn after that, with or without sync, no?
On Tue, Sep 07, 2021 at 11:44:52PM -0700, Junio C Hamano wrote: > I doubt that fsyncObjectFiles is something we can reliably test in > CI, either with the new batched thing or with the original "when we > close one, make sure the changes hit the disk platter" approach. So > I am not sure what conclusion we should draw from such an experiment, > other than "ok, it compiles cleanly." After all, unless we cause > system crashes, what we thought we have written and close(2) would > be seen by another process that we spawn after that, with or without > sync, no? Basically yes. XFS on Linux has shutdown ioctls that allow to simulate that crash by shutting the file system down which really helps debugging that kind of code. A bunch of other file systems (ext4, f2fs) have also picked this up now (grep for {XFS,EXT4,F2FS}_IOC_SHUTDOWN).
On September 8, 2021 2:50 AM, Christoph Hellwig wrote: >To: Junio C Hamano <gitster@pobox.com> >Cc: Neeraj Singh <nksingh85@gmail.com>; Neeraj K. Singh via GitGitGadget <gitgitgadget@gmail.com>; Git List <git@vger.kernel.org>; >Johannes Schindelin <Johannes.Schindelin@gmx.de>; Jeff King <peff@peff.net>; Jeff Hostetler <jeffhost@microsoft.com>; Christoph >Hellwig <hch@lst.de>; Ævar Arnfjörð Bjarmason <avarab@gmail.com>; Neeraj K. Singh <neerajsi@microsoft.com> >Subject: Re: [PATCH v2 0/6] Implement a batched fsync option for core.fsyncObjectFiles > >On Tue, Sep 07, 2021 at 11:44:52PM -0700, Junio C Hamano wrote: >> I doubt that fsyncObjectFiles is something we can reliably test in CI, >> either with the new batched thing or with the original "when we close >> one, make sure the changes hit the disk platter" approach. So I am >> not sure what conclusion we should draw from such an experiment, other >> than "ok, it compiles cleanly." After all, unless we cause system >> crashes, what we thought we have written and close(2) would be seen by >> another process that we spawn after that, with or without sync, no? > >Basically yes. XFS on Linux has shutdown ioctls that allow to simulate that crash by shutting the file system down which really helps >debugging that kind of code. A bunch of other file systems (ext4, f2fs) have also picked this up now (grep for >{XFS,EXT4,F2FS}_IOC_SHUTDOWN). I strongly doubt this concept will work in an MPP architecture, particularly one where "shutting the file system down" is not possible. I know of at least 3 operating systems where that is a bad plan, and if you did, you would take the test suite down while you were at it. -Randall
On September 7, 2021 9:23 PM, Ævar Arnfjörð Bjarmason wrote: >Subject: Re: [PATCH v2 0/6] Implement a batched fsync option for core.fsyncObjectFiles > > >On Tue, Sep 07 2021, Neeraj Singh wrote: > >> On Tue, Sep 7, 2021 at 12:54 PM Randall S. Becker >> <rsbecker@nexbridge.com> wrote: >>> >>> On September 7, 2021 3:44 PM, Neeraj Singh wrote: >>> >On Fri, Aug 27, 2021 at 4:49 PM Neeraj K. Singh via GitGitGadget <gitgitgadget@gmail.com> wrote: >>> >> >>> >> Thanks to everyone for review so far! I've responded to the >>> >> previous feedback and changed the patch series a bit. >>> >> >>> >> Changes since v1: >>> >> >>> >> * Switch from futimes(2) to futimens(2), which is in POSIX.1-2008. Contrary >>> >> to dscho's suggestion, I'm still implementing the Windows version in the >>> >> same patch and I'm not doing autoconf detection since this is a POSIX >>> >> function. >>> >>> While POSIX.1-2008, this function is not available on every single >>> POSIX-compliant platform. Please make sure that the code will not >>> cause a breakage on some platforms - the ones I maintain, in >>> particular. Neither futimes nor futimens is available on either >>> NonStop ia64 or x86. The platform only has utime, so this needs to be >>> wrapped with an option in config.mak.uname. >>> >>> Thanks, >>> Randall >> >> Ugh. Fair enough. How do other contributors feel about me moving back >> to utime, but instead just doing the utime over in >> builtins/pack-objects.c? The idea would be to eliminate the mtime >> logic entirely from write_loose_object and just do it at the top-level >> in loosen_unused_packed_objects. > >Aside from where it lives, can't we just have a wrapper that takes both the filename & fd, and then on some platforms will need to >dispatch to a slower filename-only version, but can hopefully use the new fd-accepting function? I'm not really enamoured with this direction at all. It means that any platform would have to potentially skip a version of git (resulting from the broken build from a wrapper that is not compilable) after the patches were applied, unless the patches for all of those platforms are included. Even adding a Makefile option would be similar. This should be an "Enable if supported" feature, not a default-or-broken, feature. At best, I'd have to monitor for the time where the patch is applied and hope I can figure out the wrapper changes (around my $DAYJOB) in time to make the same release. This seems a bit counter to a "keeping things compatible" philosophy. Maybe there's something I'm missing here. -Randall
On Wed, Sep 08, 2021 at 09:57:34AM -0400, Randall S. Becker wrote: > possible. I know of at least 3 operating systems where that is a bad plan, and if you did, you would take the test suite down while > you were at it. I've just mentioned a good way to write a test for this feature on a specific platform. This is absolutely no judgement if that is a good plan on other platforms.
On September 8, 2021 10:13 AM, Christoph Hellwig wrote: >Subject: Re: [PATCH v2 0/6] Implement a batched fsync option for core.fsyncObjectFiles > >On Wed, Sep 08, 2021 at 09:57:34AM -0400, Randall S. Becker wrote: >> possible. I know of at least 3 operating systems where that is a bad >> plan, and if you did, you would take the test suite down while you were at it. > >I've just mentioned a good way to write a test for this feature on a specific platform. This is absolutely no judgement if that is a good plan >on other platforms. Thank you for the clarification. I do appreciate it. -Randall
On Tue, Sep 7, 2021 at 11:44 PM Junio C Hamano <gitster@pobox.com> wrote: > > Neeraj Singh <nksingh85@gmail.com> writes: > > > BTW, I updated the github PR to enable batch mode everywhere, and all > > the tests passed, which is good news to me. > > I doubt that fsyncObjectFiles is something we can reliably test in > CI, either with the new batched thing or with the original "when we > close one, make sure the changes hit the disk platter" approach. So > I am not sure what conclusion we should draw from such an experiment, > other than "ok, it compiles cleanly." After all, unless we cause > system crashes, what we thought we have written and close(2) would > be seen by another process that we spawn after that, with or without > sync, no? The main failure mode I was worried about is that some test or other part of Git is relying on a loose object being immediately available after it is added to the ODB. With batch mode, the loose objects aren't actually available until the bulk checkin is unplugged. I agree that it is not easy to test whether the data is actually going to durable storage at the expected time. FWIW, I did take a disk IO trace on Windows to verify that we are issuing disk writes and flushes at the right time. But that's a one-time test that would be hard to make automated.
On Tue, Sep 7, 2021 at 6:23 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote: > > > On Tue, Sep 07 2021, Neeraj Singh wrote: > > > On Tue, Sep 7, 2021 at 12:54 PM Randall S. Becker > > <rsbecker@nexbridge.com> wrote: > >> > >> On September 7, 2021 3:44 PM, Neeraj Singh wrote: > >> >On Fri, Aug 27, 2021 at 4:49 PM Neeraj K. Singh via GitGitGadget <gitgitgadget@gmail.com> wrote: > >> >> > >> >> Thanks to everyone for review so far! I've responded to the previous > >> >> feedback and changed the patch series a bit. > >> >> > >> >> Changes since v1: > >> >> > >> >> * Switch from futimes(2) to futimens(2), which is in POSIX.1-2008. Contrary > >> >> to dscho's suggestion, I'm still implementing the Windows version in the > >> >> same patch and I'm not doing autoconf detection since this is a POSIX > >> >> function. > >> > >> While POSIX.1-2008, this function is not available on every single > >> POSIX-compliant platform. Please make sure that the code will not > >> cause a breakage on some platforms - the ones I maintain, in > >> particular. Neither futimes nor futimens is available on either > >> NonStop ia64 or x86. The platform only has utime, so this needs to > >> be wrapped with an option in config.mak.uname. > >> > >> Thanks, > >> Randall > > > > Ugh. Fair enough. How do other contributors feel about me moving back > > to utime, but instead just doing the utime over in > > builtins/pack-objects.c? The idea would be to eliminate the mtime > > logic entirely from write_loose_object and just do it at the top-level > > in loosen_unused_packed_objects. > > Aside from where it lives, can't we just have a wrapper that takes both > the filename & fd, and then on some platforms will need to dispatch to a > slower filename-only version, but can hopefully use the new fd-accepting > function? I had some concerns around using utime() while a file descriptor is open. There's some risk of sharing violation on Windows (doesn't matter since we'd be using futimens), but I was also concerned that there might be some OSes that update the mtime on close(fd), thus overwriting the effects of utime. Maybe that's an unwarranted concern, but it's part of why I didn't want to have different call sequences on different OSes. I'd be happy to implement your suggestion though and see what happens. But I also feel that this time update thing is pretty ancillary to the real goal of my change. I'm only doing it because it's in the same area. The effects of getting mtime wrong would be pretty subtle -- I think we'd just not be deleting some unpacked unreachable objects as soon as expected. Do you have a strong objection to lifting the time update logic out?
Neeraj Singh <nksingh85@gmail.com> writes: > On Tue, Sep 7, 2021 at 11:44 PM Junio C Hamano <gitster@pobox.com> wrote: >> >> Neeraj Singh <nksingh85@gmail.com> writes: >> >> > BTW, I updated the github PR to enable batch mode everywhere, and all >> > the tests passed, which is good news to me. >> >> I doubt that fsyncObjectFiles is something we can reliably test in >> CI, either with the new batched thing or with the original "when we >> close one, make sure the changes hit the disk platter" approach. So >> I am not sure what conclusion we should draw from such an experiment, >> other than "ok, it compiles cleanly." After all, unless we cause >> system crashes, what we thought we have written and close(2) would >> be seen by another process that we spawn after that, with or without >> sync, no? > > The main failure mode I was worried about is that some test or other part > of Git is relying on a loose object being immediately available after it is > added to the ODB. With batch mode, the loose objects aren't actually > available until the bulk checkin is unplugged. Ah, I see. If there are two processes that communicate over pipes to decide whose turn it is (perhaps a producer of data that feeds fast-import may wait for fast-import to say "I gave this label to the object you requested" and goes ahead to use that object), and at the point that the "other" process takes its turn, if the objects are not "flushed" yet, things can break. That's a valid concern.
On Wed, Sep 8, 2021 at 12:12 PM Junio C Hamano <gitster@pobox.com> wrote: > > Neeraj Singh <nksingh85@gmail.com> writes: > > > On Tue, Sep 7, 2021 at 11:44 PM Junio C Hamano <gitster@pobox.com> wrote: > >> > >> Neeraj Singh <nksingh85@gmail.com> writes: > >> > >> > BTW, I updated the github PR to enable batch mode everywhere, and all > >> > the tests passed, which is good news to me. > >> > >> I doubt that fsyncObjectFiles is something we can reliably test in > >> CI, either with the new batched thing or with the original "when we > >> close one, make sure the changes hit the disk platter" approach. So > >> I am not sure what conclusion we should draw from such an experiment, > >> other than "ok, it compiles cleanly." After all, unless we cause > >> system crashes, what we thought we have written and close(2) would > >> be seen by another process that we spawn after that, with or without > >> sync, no? > > > > The main failure mode I was worried about is that some test or other part > > of Git is relying on a loose object being immediately available after it is > > added to the ODB. With batch mode, the loose objects aren't actually > > available until the bulk checkin is unplugged. > > Ah, I see. If there are two processes that communicate over pipes > to decide whose turn it is (perhaps a producer of data that feeds > fast-import may wait for fast-import to say "I gave this label to > the object you requested" and goes ahead to use that object), and at > the point that the "other" process takes its turn, if the objects > are not "flushed" yet, things can break. That's a valid concern. That's right. This appears to be a possibility in the existing bulk checkin code that produces packfiles for large objects as well, but my change makes the situation much more common.
On Wed, Sep 08 2021, Neeraj Singh wrote: > On Tue, Sep 7, 2021 at 11:44 PM Junio C Hamano <gitster@pobox.com> wrote: >> >> Neeraj Singh <nksingh85@gmail.com> writes: >> >> > BTW, I updated the github PR to enable batch mode everywhere, and all >> > the tests passed, which is good news to me. >> >> I doubt that fsyncObjectFiles is something we can reliably test in >> CI, either with the new batched thing or with the original "when we >> close one, make sure the changes hit the disk platter" approach. So >> I am not sure what conclusion we should draw from such an experiment, >> other than "ok, it compiles cleanly." After all, unless we cause >> system crashes, what we thought we have written and close(2) would >> be seen by another process that we spawn after that, with or without >> sync, no? > > The main failure mode I was worried about is that some test or other part > of Git is relying on a loose object being immediately available after it is > added to the ODB. With batch mode, the loose objects aren't actually > available until the bulk checkin is unplugged. > > I agree that it is not easy to test whether the data is actually going > to durable > storage at the expected time. FWIW, I did take a disk IO trace on Windows to > verify that we are issuing disk writes and flushes at the right time. > But that's a > one-time test that would be hard to make automated. I have some semi-related patches I need to dig up and finish sometime which add a "git gc" test mode to the test suite, i.e. any time we call "git gc --auto" it will go ahead and actually run, and some adversarial options to run always, right away, prune with --expire=now. It found some false positives, but also some genuine races and bugs at the time. Similarly, I think a good longer term goal for better fsync() and data integrity in git is to refactor the various codepaths where we write to disk (grepping for fsync_or_die() is a good start to find those) to all live in one place, we could then easily instrument that code to run in a hostile test mode. E.g. make anything that expects to write out a "foo" file actually write out "foo.not-synced-yet" as long as fsync() etc. hasn't been called, or with signals/timers/atexit() handlers fake up known FS edge cases such as a write of "foo" only renaming "foo.not-synced-yet" to "foo" 1s after the last close() call not followed by an fsync, etc. Anyway, I expect given your occupation that you may have better ideas in that area, presumably needing to instrument and test behavior under I/O pressure, deferred syncs etc. is something mature FS's need to deal with as part of their own regression tests... 1. https://lore.kernel.org/git/cover-v2-0.4-0000000000-20210908T003631Z-avarab@gmail.com/