Skip to content

lib: Handle case-insensitive filesystems - #6717

Merged
calmh merged 70 commits into
syncthing:mainfrom
imsodin:lib/tHEcASeSPreCIoUs
Jul 28, 2020
Merged

calmh merged 70 commits into
syncthing:mainfrom
imsodin:lib/tHEcASeSPreCIoUs

Conversation

@imsodin

@imsodin imsodin commented Jun 5, 2020 •

Copy link
Copy Markdown
Member

@imsodin
imsodin force-pushed the lib/tHEcASeSPreCIoUs branch 5 times, most recently from 3ae66e1 to 384deff Compare June 7, 2020 21:53
@imsodin imsodin changed the title [POC] lib: Handle path case on windows [POC] lib: Handle case-insensitive filesystems Jun 12, 2020
@imsodin imsodin changed the title [POC] lib: Handle case-insensitive filesystems [WIP] lib: Handle case-insensitive filesystems Jun 12, 2020
@imsodin
imsodin force-pushed the lib/tHEcASeSPreCIoUs branch 2 times, most recently from 032f70d to 0423678 Compare June 14, 2020 16:35
@imsodin

imsodin commented Jun 14, 2020 •

Copy link
Copy Markdown
Member Author

All the basic pieces for handling case-insensitivity are in place now. Disclaimer: I haven't done any testing, the DirNames approach to getting the right case might be super slow and there seems to be a problem on windows with osutil.IsDeleted (will investigate) unrelated, fixed.

@imsodin
imsodin force-pushed the lib/tHEcASeSPreCIoUs branch from 3317721 to fc1f58d Compare June 15, 2020 08:18
@imsodin

imsodin commented Jun 15, 2020

Copy link
Copy Markdown
Member Author

I ran the many files integration benchmark twice on master and this branch, and the results are all over the place. At least it's not obviously extremely much worse. However I'll run them later on an beefier, more idle machine than my laptop to hopefully get a bit more consistent results:

PR:

2020/06/15 13:06:09 Result: Wall time: 944.392072ms / MiB
2020/06/15 13:06:09 Result: 1.1e+03 KiB/s synced
2020/06/15 13:06:09 Receiver: Utime: 425.885258ms / MiB
2020/06/15 13:06:09 Receiver: Stime: 208.14287ms / MiB
2020/06/15 13:06:09 Receiver: MaxRSS: 98868 KiB
2020/06/15 13:06:09 Sender: Utime: 167.71058ms / MiB
2020/06/15 13:06:09 Sender: Stime: 44.580516ms / MiB
2020/06/15 13:06:09 Sender: MaxRSS: 101172 KiB

2020/06/15 14:02:21 Result: Wall time: 1.390849093s / MiB
2020/06/15 14:02:21 Result: 745 KiB/s synced
2020/06/15 14:02:21 Receiver: Utime: 716.717322ms / MiB
2020/06/15 14:02:21 Receiver: Stime: 391.476258ms / MiB
2020/06/15 14:02:21 Receiver: MaxRSS: 104944 KiB
2020/06/15 14:02:21 Sender: Utime: 222.357967ms / MiB
2020/06/15 14:02:21 Sender: Stime: 75.986225ms / MiB
2020/06/15 14:02:21 Sender: MaxRSS: 81760 KiB


master:

2020/06/15 13:20:16 Result: Wall time: 1.502113108s / MiB
2020/06/15 13:20:16 Result: 690 KiB/s synced
2020/06/15 13:20:16 Receiver: Utime: 478.989451ms / MiB
2020/06/15 13:20:16 Receiver: Stime: 242.398516ms / MiB
2020/06/15 13:20:16 Receiver: MaxRSS: 103960 KiB
2020/06/15 13:20:16 Sender: Utime: 184.897419ms / MiB
2020/06/15 13:20:16 Sender: Stime: 52.640032ms / MiB
2020/06/15 13:20:16 Sender: MaxRSS: 91844 KiB

2020/06/15 13:26:46 Result: Wall time: 1.375864329s / MiB
2020/06/15 13:26:46 Result: 754 KiB/s synced
2020/06/15 13:26:46 Receiver: Utime: 539.303741ms / MiB
2020/06/15 13:26:46 Receiver: Stime: 271.998967ms / MiB
2020/06/15 13:26:46 Receiver: MaxRSS: 97320 KiB
2020/06/15 13:26:46 Sender: Utime: 195.600322ms / MiB
2020/06/15 13:26:46 Sender: Stime: 56.701838ms / MiB
2020/06/15 13:26:46 Sender: MaxRSS: 96024 KiB

@calmh
calmh changed the base branch from master to main June 15, 2020 19:29
* main:
  lib/db: Update global meta even if unchanged (fixes syncthing#6850) (syncthing#6852)
@calmh

calmh commented Jul 27, 2020

Copy link
Copy Markdown
Member

Retesting this it now actually works for me. I don't know if this is because the cache changes or if I did something wrong last time or something is flaky. I'll however run it some more with the assumption that it's all good and get into some actual review from my side :)

@calmh

calmh commented Jul 27, 2020

Copy link
Copy Markdown
Member

I added a benchmark to do a scanner-like walk (first walk the filesystem, then stat each entry as if we already had them in the database);

jb@kvin:..ing/syncthing/lib/fs % go test -bench . -run none -benchtime 10s
goos: darwin
goarch: amd64
pkg: github.com/syncthing/syncthing/lib/fs
BenchmarkWalkCaseFakeFS10k/raw-8                     288          41836273 ns/op               602 B/entry               0.432 allocs/entry           2141 ns/entry     11771535 B/op     348491 allocs/op
BenchmarkWalkCaseFakeFS10k/case-8                    159          79047286 ns/op              1201 B/entry               0.781 allocs/entry           4045 ns/entry     23473706 B/op     602603 allocs/op

One "op" here is a complete double-walk over a 10k files fakefs. There's more than 10k things looked at because there's a directory structure based on the random file names, so somewhere between 10k and 30k actual filesystem entries in total. The "/entry" numbers are per such filesystem entry.

So this adds about 600 bytes and 4000 ns overhead to each entry inspected. The 4000 ns is about a factor two of the non-CaseFS benchmark, but we should keep in mind that this is doing zero actual I/O or hashing or database operations so we are measuring just FakeFS overhead vs FakeFS+CaseFS overhead.

I think we're good here, performance wise.

Comment thread lib/fs/casefs.go
return out, nil
}

func (r *defaultRealCaser) startCaseResetTimerLocked() {

@calmh calmh Jul 27, 2020 •

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.

This thing could be slightly simplified by not using a timer and a routine for the reset, instead recording the creation time of the cache. If it's too old or too large on entry into realCase we drop the cache. The downside would be that a cache is not automatically expired when we stop calling realCase -- it would stick around until next call. A workaround for that could be a permanent ticker routine that once every few seconds checks if the cache is expired and removes it. This is similar to what happens now except there would be a permanent routine and ticker instead of the selects and stuff.

I don't think the current implementation is necessarily bad, but it is a few things to take in.

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.

I avoided a persistent goroutine because a filesystem never gets closed, thus we'd leak a goroutine every time a filesystem is (re-)created.

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.

Good point

calmh
calmh previously approved these changes Jul 27, 2020
calmh
calmh previously approved these changes Jul 27, 2020
calmh added a commit to syncthing/docs that referenced this pull request Jul 28, 2020
@calmh
calmh merged commit 9e2e81b into syncthing:main Jul 28, 2020
@calmh calmh added this to the v1.9.0 milestone Jul 28, 2020
@imsodin
imsodin deleted the lib/tHEcASeSPreCIoUs branch July 28, 2020 09:26
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jul 29, 2021
@syncthing syncthing locked and limited conversation to collaborators Jul 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants