Skip to content

Extension - Document High CPU Usage by Tokio Runtime with Default ThreadPool #108

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

Closed
huntharo opened this issue Jan 28, 2024 · 0 comments · Fixed by #119
Closed

Extension - Document High CPU Usage by Tokio Runtime with Default ThreadPool #108

huntharo opened this issue Jan 28, 2024 · 0 comments · Fixed by #119
Assignees

Comments

@huntharo
Copy link
Contributor

huntharo commented Jan 28, 2024

Motivations

  • This high CPU usage observed with the default runtime is likely a problem others are encountering and may not be aware of
  • There likely needs to be an improvement made to the Tokio work stealing algorithm to reduce stealing when there is not enough work to go around to all the threads

Video Review of High Rust Tokio Async Runtime CPU - YouTube

Click to view on YouTube

Review of Rust Tokio Async Runtime Efficiency

Links

Test Setup

  • 10 max concurrent requests from Router to Extension
    • DOTNET_ThreadPool_UnfairSemaphoreSpinLimit=5 LAMBDA_DISPATCH_ChannelCount=10 LAMBDA_DISPATCH_MaxConcurrentCount=10 LAMBDA_DISPATCH_AllowInsecureControlChannel=true LAMBDA_DISPATCH_PreferredControlChannelScheme=http LAMBDA_DISPATCH_FunctionName=dogs AWS_LAMBDA_SERVICE_URL=http://localhost:5051 AWS_REGION=us-east-2 AWS_ACCESS_KEY_ID=test-access-key-id AWS_SECRET_ACCESS_KEY=test-secret-access-key AWS_SESSION_TOKEN=test-session-token src/PwrDrvr.LambdaDispatch.Router/bin/Release/net8.0/PwrDrvr.LambdaDispatch.Router 2>&1 | tee router.log
  • 10 concurrent connections from oha
    • oha -c 10 -z 60s http://127.0.0.1:5001/ping

Test Cases

Rust Extension with Default Tokio Threading

  • 14,000 RPS
  • ❌ 270% CPU
  • Command line: LAMBDA_DISPATCH_RUNTIME=default_multi_thread LAMBDA_DISPATCH_FORCE_DEADLINE=60 AWS_LAMBDA_FUNCTION_VERSION=\$LATEST AWS_LAMBDA_FUNCTION_MEMORY_SIZE=512 AWS_LAMBDA_FUNCTION_NAME=dogs AWS_LAMBDA_RUNTIME_API=localhost:5051 AWS_REGION=us-east-2 AWS_ACCESS_KEY_ID=test-access-key-id AWS_SECRET_ACCESS_KEY=test-secret-access-key AWS_SESSION_TOKEN=test-session-token cargo run --release --bin extension 2>&1 | tee extension.log

Rust Extension with Current Thread Tokio Threading

  • 19,000 RPS
  • ✅ 90% CPU
  • Command line: LAMBDA_DISPATCH_RUNTIME=current_thread LAMBDA_DISPATCH_FORCE_DEADLINE=60 AWS_LAMBDA_FUNCTION_VERSION=\$LATEST AWS_LAMBDA_FUNCTION_MEMORY_SIZE=512 AWS_LAMBDA_FUNCTION_NAME=dogs AWS_LAMBDA_RUNTIME_API=localhost:5051 AWS_REGION=us-east-2 AWS_ACCESS_KEY_ID=test-access-key-id AWS_SECRET_ACCESS_KEY=test-secret-access-key AWS_SESSION_TOKEN=test-session-token cargo run --release --bin extension 2>&1 | tee extension.log

DotNet Extension

  • 14,000 RPS
  • ❌ 310% CPU
  • Command line: DOTNET_ThreadPool_UnfairSemaphoreSpinLimit=0 AWS_LAMBDA_RUNTIME_API=localhost:5051 AWS_REGION=us-east-2 AWS_ACCESS_KEY_ID=test-access-key-id AWS_SECRET_ACCESS_KEY=test-secret-access-key AWS_SESSION_TOKEN=test-session-token src/PwrDrvr.LambdaDispatch.Extension/bin/Release/net8.0/bootstrap 2>&1 | tee extension.log
@huntharo huntharo self-assigned this Jan 28, 2024
@huntharo huntharo changed the title General - Document High CPU Usage by Tokio Runtime General - Document High CPU Usage by Tokio Runtime with Default ThreadPool Jan 28, 2024
@huntharo huntharo changed the title General - Document High CPU Usage by Tokio Runtime with Default ThreadPool Extension - Document High CPU Usage by Tokio Runtime with Default ThreadPool Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant