-
Notifications
You must be signed in to change notification settings - Fork 31
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
fix: add support for symlinked files and dirs #68
Conversation
This change is very expensive. System fonts loading is up to 50% slower on macOS. I cannot accept it. We have to ignore duplicated fonts. Also, I don't know how Nix works, but can we follow symlinks only for files, ignoring directories? Or will it not work? |
@RazrFalcon Nix uses symlinks very heavily, so it needs full support. I'll think about how to optimize this more. |
818df07
to
b0423a5
Compare
@RazrFalcon, I have made the following changes:
Here are the results from my machine, your machine will likely/hopefully show almost no difference. BeforeTo test: make the second cargo run --example find-system-font --release
Loaded 464 font faces in 9ms (19μs per).
Error: 'Times New Roman' not found. cargo bench
load system fonts time: [15.849 µs 15.897 µs 15.947 µs] Without dir-symlinkcargo run --example find-system-font --release
Loaded 464 font faces in 10ms (23μs per). cargo bench
load system fonts time: [19.768 µs 19.841 µs 19.916 µs]
change: [+24.201% +24.807% +25.420%] (p = 0.00 < 0.05) With dir-symlinkcargo run --example find-system-font --release
Loaded 504 font faces in 13ms (27μs per). cargo bench
load system fonts time: [22.803 µs 22.822 µs 22.842 µs]
change: [+14.579% +15.025% +15.461%] (p = 0.00 < 0.05) |
b0423a5
to
d0aec71
Compare
I just realized that canonicalization is not required when dir symlinks aren't being followed, changes pushed: vs previous commitload system fonts time: [25.457 µs 25.495 µs 25.536 µs]
change: [-20.722% -20.594% -20.454%] (p = 0.00 < 0.05) vs current code in masterload system fonts time: [25.978 µs 25.988 µs 25.998 µs]
change: [+8.4845% +8.7590% +9.0271%] (p = 0.00 < 0.05) |
d0aec71
to
f8d38d8
Compare
Fixed a bug which basically turned the file-only implementation into a noop. Results on my system: No changes
With file symlink support(and symlinked files). It's faster? I wonder if it's behaving favorably with some kernel cache. load system fonts time: [21.658 µs 21.673 µs 21.689 µs]
change: [-11.678% -11.599% -11.512%] (p = 0.00 < 0.05)
...
Loaded 122 font faces in 2ms (24μs per) With dir support
|
Hey, Nix and Typst user here! I'm looking for that fix too since my Typst build environment based on Nix manage fonts using symlinks, using Looking forward for the next |
f8d38d8
to
507aa96
Compare
Pushed changes to address PR comments. Before:
After:
I'm very confused as to why there is no performance difference, even though there are more syscalls and hashing the PathBuf (which I did encounter last night, maybe a 💩 implementation?). Still, no complaints. |
507aa96
to
bc1ed59
Compare
Symlinks were never supported. |
But it was working before 0.18, right? |
Only if Typst was handling them on its own before. |
It was working before because prior to #65, |
@EpicEricEE Interesting. I didn't know that. |
ffe9900
to
e5bf6f9
Compare
This adds support for searching through symlinked files and directories, the path is first canonicalized - which will resolve nested symlinks to the real path. Due to the nature of symlinks it's still possible for an infinitely recursive data structure to arise, or for the same canonical file to be repeated. Both cases are covered by keeping track of which canonical files have already been visited. These changes are required to correctly support some Nix scenarios, specifically installing fonts through home-manager.
e5bf6f9
to
f4d1534
Compare
Made some changes to get it to compile on MSRV: https://github.com/jcdickinson/fontdb/actions/runs/10259900356 |
Looks good now. I don't see any significant performance differences on macOS loading 1396 font faces. |
Looking forward for the new tag! Thanks for merging this! |
Published. |
This adds support for searching through symlinked files and directories, the path is first canonicalized - which will resolve nested symlinks to the real path. Due to the nature of symlinks it's still possible for an infinitely recursive data structure to arise, or for the same canonical file to be repeated. Both cases are covered by keeping track of which canonical files have already been visited.
These changes are required to correctly support some Nix scenarios, specifically installing fonts through home-manager.