niv
niv copied to clipboard
Concurrency and sexy logging
Right now niv updates packages one after the other. This can be slow if the nix/sources.json contains lots of packages.
There's a branch somewhere that simply calls (something similar to) forConcurrently when iterating over the packages to upgrade. The main drawback is that all outputs get mangled.
I recently played with an idea for a logger (I unfortunately lost the niv branch):
- A single thread is responsible for rendering and has associated state. The state looks something like
TVar (Map Key [String])where eachKeyis allocated some screen space which can grow and shrink depending on the[String](the lines to display). This is made possible by the use of ANSI control codes. - There is one
Keyissued per thread. Whenever the code calls (an overriden version of)putStrln,myThreadIdis used to generate theKey. It then writes its new output to the global (TVar (Map Key [String])) rendering state.
Have you considered using concurrent-output?
That looks very promising!