-
-
Notifications
You must be signed in to change notification settings - Fork 28
Using mtime.secs
for hash is incompatible with Nix managed configurations
#42
Comments
Sorry I don't understand why using the modified time for cache invalidation is wrong or why nix has issues with it? Can you elaborate more? Using a full file hash would probably nullify any benefits this plugin gives since it would require loading all the files it is caching in order to create a hash. There would just little point. Is the problem that nix has issues with libuv or something? And if so shouldn't that be fixed? |
Python has (and solved) this already in PEP552
|
It's not really anything to do with libuv specifically, just that any time-stamp based approach for caching anything being managed by nix is always going to be a cache-hit. Here's an example from my system:
That looks fine, but that timestamp is for the symlink. Here is the timestamp for the final file (in my case this is symlink -> symlink -> concrete file)
The SHA256 hash is the same:
The problem becomes when I do an update, the impatient cache will not invalidate because Nix sets all timestamps in /nix/store to 0 (this is a feature not a bug). I guess this is a long-winded way of trying to figure out if this is just meant to be good enough for the majority use-case. If so, I respect that decision and feel free to close the issue if you see no value in this 👍. |
We can take the same approach python has, where the current solution of using If you want to put forward a PR that allows an alternative way of validating the cache then I'm happy to review it. However, note that Neovim currently doesn't have any hashing functions available, so one would need to be added somehow; either implemented from scratch or imported from a third party library. |
mtime.secs
for hash is incompatible with Nix managed configurations
Meet the same problem, and use:
as a workaround. |
I've opened #50, so the hash uses the file size too. It doesn't completely fix this issue but it should mitigate it a bit since the cache will work, though with a much higher chance of a false-positive cache hit. |
Closing this. The hashing is now pretty similar to what pycache does, if that isn't good enough for nix, then that's nix's problem. |
I've migrated to using Nix to manage my dotfiles and system configuration which which sets all file timestamps to 0. After migrating my fledgling neovim configuration over, I noticed that none of my changes were taking after updating my configs unless I deleted
~/.cache/nvim/luacache
. This was not an issue before I migrated my configuration over to nix. After digging into the source, I see the hash function is as follows:For this to be more robust an actual file hash would need to be performed, though I imagine that would also slow things down. However, if the goal is for this plugin to eventually be merged into neovim core I think this would impact every Nix neovim user if it were merged with the hash function as-is.
The text was updated successfully, but these errors were encountered: