Skip to content

feat(fs): add InodeChangeTime() support in Windows - #10172

Closed
rasa wants to merge 10 commits into
syncthing:mainfrom
rasa:rs/feat-inodechangetime-windows
Closed

rasa wants to merge 10 commits into
syncthing:mainfrom
rasa:rs/feat-inodechangetime-windows

Conversation

@rasa

@rasa rasa commented Jun 12, 2025 •

Copy link
Copy Markdown
Member

Purpose

Adds InodeChangeTime() support in Windows, and tests for basicFileInfo.

Testing

Tested on windows-latest, ubuntu-latest, and darwin-latest, and Windows 11 (locally).

@github-actions github-actions Bot added the enhancement New features or improvements of some kind, as opposed to a problem (bug) label Jun 12, 2025
@rasa

rasa commented Jun 12, 2025

Copy link
Copy Markdown
Member Author

Should these two 2-second timing delays be shorter? What would be best?

@calmh calmh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable

Comment thread lib/fs/basicfs_fileinfo_windows.go Resolved
Comment thread lib/fs/basicfs_fileinfo_test.go Resolved

func (basicFileInfo) InodeChangeTime() time.Time {
return time.Time{}
func inodeChangeTime(_ os.FileInfo, name string) time.Time {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much slower do the Lstat calls become on Windows with this addition? (We make a lot of them, sometimes on the order of tens per file operation as we do all the extra work for filename case verification...)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I'll run a benchmark and post here (in a couple days... travelling). If it's significant, we could defer the lookup until InodeChangeDate() is first called, and return that result from then on.

@rasa rasa Jun 21, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below are the benchmark results processing 1,788,242 files on an NTFS partition (0.0000813s vs 0.000133s per file).

For old.txt, I changed inodeChangeTime in
basicfs_fileinfo_windows.go to simply return time.Time{}.

goos: windows
goarch: amd64
pkg: github.com/syncthing/syncthing/lib/fs
cpu: 13th Gen Intel(R) Core(TM) i7-1370P
            │   old.txt   │            new.txt             │
            │   sec/op    │   sec/op     vs base           │
Stat/c:\-20   145.5 ± ∞ ¹   238.4 ± ∞ ¹  ~ (p=1.000 n=1) ²
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

            │    old.txt    │             new.txt              │
            │     B/op      │     B/op       vs base           │
Stat/c:\-20   2.039Gi ± ∞ ¹   2.532Gi ± ∞ ¹  ~ (p=1.000 n=1) ²
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

            │   old.txt    │             new.txt             │
            │  allocs/op   │  allocs/op    vs base           │
Stat/c:\-20   20.12M ± ∞ ¹   21.91M ± ∞ ¹  ~ (p=1.000 n=1) ²
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it increases scan time by 64%... That's not fantastic, but maybe not necessarily a show stopper if the change is necessary -- is it?

@rasa rasa Jun 26, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calmh Good question. Looking at the code, I would say it's not required. But I would suggest that to avoid platform-specific weirdness (now, or in the future, as the code evolves), each platform implements the same functionality, if possible.

Of course, if speed is important, we could defer the API calls until InodeChangeTime() is called. While that's not the exact same functionality, I can't imagine having a more recent change time than when Lstat() was called could cause an issue.

Or we hold this PR in our quiver, and merge it when an issue arises that requires it. Your call.

rasa added 3 commits June 21, 2025 10:22
Below are the benchmark results. For old, I changed inodeChangeTime in
basicfs_fileinfo_windows.go to simply return time.Time{}.

goos: windows
goarch: amd64
pkg: github.com/syncthing/syncthing/lib/fs
cpu: 13th Gen Intel(R) Core(TM) i7-1370P
            │   old.txt   │            new.txt             │
            │   sec/op    │   sec/op     vs base           │
Stat/c:\-20   145.5 ± ∞ ¹   238.4 ± ∞ ¹  ~ (p=1.000 n=1) ²
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

            │    old.txt    │             new.txt              │
            │     B/op      │     B/op       vs base           │
Stat/c:\-20   2.039Gi ± ∞ ¹   2.532Gi ± ∞ ¹  ~ (p=1.000 n=1) ²
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

            │   old.txt    │             new.txt             │
            │  allocs/op   │  allocs/op    vs base           │
Stat/c:\-20   20.12M ± ∞ ¹   21.91M ± ∞ ¹  ~ (p=1.000 n=1) ²
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
@calmh

calmh commented Jun 28, 2025

Copy link
Copy Markdown
Member

defer the API calls until InodeChangeTime() is called

Yes, I think something like this, i.e. your first iteration.

@calmh calmh closed this in #10579 Mar 23, 2026
@rasa
rasa deleted the rs/feat-inodechangetime-windows branch March 24, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New features or improvements of some kind, as opposed to a problem (bug)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants