salad: complete rewrite to be thread-based rather than select-based
The first version of SALAD was using a single thread to do all the
routing between the different consoles and clients. This was done
through heavy use of select()
which led to the following issues:
-
high CPU load due to the high setup cost of
select
, both on salad's side by computing the list of fds to wait on and on the kernel side which needs to monitor all these fds. -
hard to maintain: by having to deal with fds, we are at risk of fd leaks, and race conditions.
This commit brings a complete rewrite of SALAD to be thread-based, where every console, server, and client have their own thread. The SALAD class is now mostly used as a database for the routing and polling for the list of serial consoles.
Other notable changes are:
-
Consoles:
- Improve performance by:
- Using bytes.split() to split the consoles' lines
- Using re.search for both ping/machine_id
- Use os.read/write directly
- Use
serial.VTIMESerial
rather thanserial.Serial
so that read() could be blocking... for up to 200ms
- Improve performance by:
-
TCPServer: Deduplicate the 3 instances of TCP servers we had