Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a sleep in Shellout.executeStream to reduce spinning. #578

Merged
merged 1 commit into from Mar 18, 2017

Conversation

@rorygraves
Copy link
Contributor

@rorygraves rorygraves commented Mar 18, 2017

Whilst waiting for IO Shellout.executeStream was running a tight loop and consuming significant
amounts of CPU. Adding a small sleep when no input was seen reduces cpu usage significant.

Whilst waiting for IO Shellout.executeStream was running a tight loop and consuming significant
amounts of CPU.  Adding a small sleep when no input was seen reduces cpu usage significant.
@@ -65,14 +65,17 @@ object Shellout{
val stdout = process.getInputStream
val stderr = process.getErrorStream
val chunks = collection.mutable.Buffer.empty[Either[Bytes, Bytes]]
val sources = Seq(stdout -> (Left(_: Bytes)), stderr -> (Right(_: Bytes)))

This comment has been minimized.

@rorygraves

rorygraves Mar 18, 2017
Author Contributor

This prevents allocations during each cycle.

@@ -81,6 +84,9 @@ object Shellout{
))
}
}
// if we did not read anything sleep briefly to avoid spinning

This comment has been minimized.

@rorygraves

rorygraves Mar 18, 2017
Author Contributor

Only sleep if we have not seen input during this iteration. This means that for fast processes we do not add unnecessary pauses.

@rorygraves
Copy link
Contributor Author

@rorygraves rorygraves commented Mar 18, 2017

@lihaoyi CI build failure looks unrelated

@lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Mar 18, 2017

Thanks!

@lihaoyi lihaoyi merged commit fabce69 into com-lihaoyi:master Mar 18, 2017
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants