hydra-queue-runner: More accurate memory accounting

We now take into account the memory necessary for compressing the NAR being exported to the binary cache, plus xz compression overhead.

Also, we now release the memory tokens for the NAR accessor after releasing the NAR accessor. Previously the memory for the NAR accessor might still be in use while another thread does an allocation, causing the maximum to be exceeded temporarily.

Also, use notify_all instead of notify_one to wake up memory token waiters. This is not very nice, but not every waiter is requesting the same number of tokens, so some might be able to proceed.

Created by  Eelco Dolstra  on November 16, 2016
YNO7CQ6P56YQP7UMGQFL4AZED7DBXE32U7TI6OMOKT6GMWZDMWWQC
Change contents