Repository navigation
Conversation
|
Should these two 2-second timing delays be shorter? What would be best? |
|
|
||
| func (basicFileInfo) InodeChangeTime() time.Time { | ||
| return time.Time{} | ||
| func inodeChangeTime(_ os.FileInfo, name string) time.Time { |
There was a problem hiding this comment.
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...)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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.
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
…rasa/syncthing into rs/feat-inodechangetime-windows
Yes, I think something like this, i.e. your first iteration. |
Purpose
Adds InodeChangeTime() support in Windows, and tests for
basicFileInfo.Testing
Tested on windows-latest, ubuntu-latest, and darwin-latest, and Windows 11 (locally).