sg: refactor how commands are built & run, introduce semaphore
Created by: mrnugget
This refactors how sg
builds and then runs commands. It also introduces a semaphore to limit the number of concurrent build/install processes, which can often thrash the system.
I couldn't measure a noticeable speed different with the introduction of the semaphore, but it "feels" (yes, disclaimers apply) a bit lighter on the machine.
At the very least this cleans up the code a bit and makes the different parts easier to modify. We can still take out the semaphore if we don't notice any difference.
Ideally, I think, we'd use a proper build system to call out to and to handle the building of all the different binaries. I suspect a large part of the aggressive thrashing that sg
produces when starting up is the multiple go build
commands being invoked that compile the same things over and over again (gitserver
and repo-updater
depend on a lot of the same code, for example).
Test plan
- Existing integration tests