-
Notifications
You must be signed in to change notification settings - Fork 409
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
Feature request: symlink/symbolic link for faster/smaller compiled site versions #786
Comments
Any feedback on this? I'd particularly like this upstreamed because my attempts to define it inside my own hakyll.hs have foundered on type issues with the deriving Binary & Item; they work inside |
Please submit this as PR, I'll merge it. |
…s, this can be a major speedup (see #786)
Thanks @gwern! |
So I happened to undo my local patch while doing a reinstall of my Pandoc toolchain to pull in a fix related to
That is what I was referring to in my discussion of hacking I thought when you committed you'd fixed that, but trying just now it seems that is not the case? |
My bad! I somehow overlooked your warning about relative links when I suggested to merge this.
From my reading of the code, that's exactly how it works. The problem is that relative symlinks are resolved relatively to the directory in which they reside, so "./docs/foo.pdf", when resolved from inside "_site/docs/", points to "_site/docs/docs/foo.pdf". One way to fix it would be to use The other option is to make We can write our own "relativization" function: 1) take Alternatively, use hard links. But that'll require separate code for *nix and Windows, I believe. I don't have the energy to work on this myself. If you want to push this to completion, I'm open to further discussions, you can bounce ideas off me if you want. Otherwise I can just revert the current version, re-open this issue, and wait until someone gets motivated to finish this off. |
Okay, the patch is now reverted. Sorry for the mess I've caused here >_< Let's wait until someone has energy to brush this up and submit a new one. |
If it's unclear which function to use, perhaps we can push it onto the user. Right now my hack is to add in a |
Sorry for such a delay replying, I got buried under some life stuff. Upon re-reading the thread, I think the easiest way forward is to use hard links, and implement them just for the OS that you, @gwern, are using. If somebody needs it on a different OS, they can submit a patch later. If somebody absolutely needs symbolic links (e.g. because their destination directory is on a different disk), they can re-visit this issue and see what they can come up with. What do you think of that? In case you're against that, I'll also comment on parameterising |
I have not tried using hardlinks before, but I'm willing to give it a try. |
Any update on this? Was there any hardlink patch I was supposed to test? |
Not from me; I didn't find the energy to write the hardlinking patch yet. |
I would like
symlinkCompiler
which does symbolic links (or hard links) as a dropin replacement for a standard static file copying routine like mylet static = route idRoute >> compile copyFileCompiler
, which would be a performance optimization for compiling many large static files.As gwern.net gets larger, particularly with audio/images/videos generated for my deep learning experiments, compiling it spends increasingly more time and disk space creating
_site/
. Even with a NVMe SSD, the time starts to add up; more problematically, I'm starting to run out of disk space for creating 40GB_site/
folders just to upload a few modified files & then delete it. Almost all of that disk space & IO is going to copying things like PDFs or MP4s from one folder to another. There's no particular reason those copies couldn't just be symbolic or hard links back to the original file and then I can use rsync with--copy-links
to have rsync follow the links when it syncs with my gwern.net server.Looking at the
File.hs
module which definescopyFileCompiler
, it seems to be mostly wrappers around a single call toSystem.Directory
'scopyFileWithMetadata
. Is there any reason a symbolic link version couldn't be defined by swapping out that forcreateFileLink
like below:The one part that puzzles me is that
createFileLink src dst
creates self-links. I can try something like prepending the absolute path like("/home/gwern/wiki/"++src)
but I don't understand where the correct relative/absolute path prefix comes from since I thoughtsrc dst
would look likedocs/foo.pdf _site/docs/foo.pdf
but that's obviously not how it works...(While a hack, prepending does work: I go from a
_site/
of 41GB to <0.2GB. A good 10 minutes faster too.)The text was updated successfully, but these errors were encountered: