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
python3Packages.twisted: remove dropin.cache files #174239
base: staging
Are you sure you want to change the base?
Conversation
I don't know much about twisted. Maybe magic-wormhole-transit-relay shouldn't put its twisted plugins in |
d7a1a12
to
301b82a
Compare
They can lead to conflicts in python3.withPackages environments.
301b82a
to
26e87ed
Compare
Good question. I don't know much about twisted either, but FWIW the Arch packaging does the same. IIRC Twisted has some kind of plugin path lookup mechanism, so we could leverage that to make it find the plugin on some custom path, but not sure if this is a good idea. |
@dotlambda Thanks for pushing this up! I think this seems reasonable but I'll look at this a bit deeper later today. |
nixpkgs' python environments are complex and I'm not sure I understand them completely, however if these dropin.cache files are removed, every application that tries to load Twisted plugins will have to re-discover them all at runtime (each time) and then emit a warning about how it cannot write out a new dropin.cache file. It seems to me that, instead, the dropin.cache files should be merged into the resulting environment. Maybe this means it's actually |
(btw, I am a Twisted upstream dev, if nixpkgs wants Twisted's plugin cache to work differently so it works better in nixpkgs, feel free to talk to me about it) |
That's definitely something we could consider doing in the future. The same could happen when e.g. |
One idea that immediately comes to mind is having a cache file per package, e.g. I'm also interested in knowing how much of a slowdown not having the cache files actually is. |
It's probably more of a slowdown to not have and not be allowed to write it than just to not have it. I don't think anyone has ever tried to benchmark the Twisted plugin system in a nixpkgs-like Python environment (which is very different from most non-nixpkgs Python environments - eg those created by Debian for system Python or by using virtualenv). So - dunno. It could well be that the best thing for nixpkgs would be a way to just turn off the caching completely. |
This sounds like how it already works in Twisted for the dropins themselves. For example, Twisted contributes a dropin named "twisted_web" by distributing Only when we get to the dropin cache file is there a conflict - and the conflict is by design. By putting the information for both "twisted_web" and "magic_wormhole_transit_relay" into "dropin.cache", the plugin system only has to read "dropin.cache" - not all of the other dropins in the directory. If you namespaced the cache then I think the result would undo any possible gain you could receive from the cache existing in the first place. |
Maybe the best option for Nixpkgs is having something like |
How important is that cache in terms of performance? Are we loosing seconds or a few ms? Does it actually matter when people run magic-wormhole or just for the tests? Can we make the hook so that it only runs in the final env? Would it make sense to invest time into building a hook which combines the different caches from different files which we before separated? Something like:
|
@dotlambda this builds successfully for me given the following use case:
Other thoughts on the thread:
Could we make a hook for the final env that generates a new
Good questions, I'm not particularly sure either. There's some hints from the docs around performance impacts, see below: From the docs 1: Footnotes |
Motivation for changes
They can lead to conflicts in python3.withPackages environments.
fixes #164775
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notesShould this be backported?
cc @NixOS/release-engineers