Fix busy waiting on stdin
When running an execution, Nomad continuously reads from the stdin reader. Because the readers we implemented (codeOceanToRawReader and nullReader) return zero if there is no input available, this leads to busy waiting and a high CPU load on Poseidon. By waiting indefinitely in case of the nullReader and for at least one byte on case of the codeOceanToRawReader before returning, we prevent this issue.
This commit is contained in:
@@ -292,7 +292,8 @@ func (a *APIClient) LoadEnvironmentJobs() ([]*nomadApi.Job, error) {
|
||||
type nullReader struct{}
|
||||
|
||||
func (r nullReader) Read(_ []byte) (int, error) {
|
||||
return 0, nil
|
||||
// An empty select blocks forever.
|
||||
select {}
|
||||
}
|
||||
|
||||
// ExecuteCommand executes the given command in the given allocation.
|
||||
|
Reference in New Issue
Block a user