You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2024/11/19 21:23:46 UTC
[PR] feat: Use global tokio runtime per executor [datafusion-comet]
andygrove opened a new pull request, #1104:
URL: https://github.com/apache/datafusion-comet/pull/1104
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
N/A
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
This was an experiment related to researching https://github.com/apache/datafusion-comet/issues/1098. I wondered if creating a new tokio runtime per task was causing overhead. It does not seem to matter too much but this PR does result in a small performance improvement for my benchmarking (2% faster for TPC-H @ 100 GB).
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
Create one global tokion runtime for the process.
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use global tokio runtime per executor [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #1104:
URL: https://github.com/apache/datafusion-comet/pull/1104#issuecomment-2514840362
> Wondering if the performance improvement comes from different numbers of threads? Are the default numbers are the same?
Tokio's defaults are to create one worker thread per core for async code (which can be overridden with the `TOKIO_WORKER_THREADS` env var) and an upper limit of 512 blocking threads (but they are created on demand, so they are unlikely to get this high).
I didn't make a note of the benchmark settings I used but it was likely 8 cores in 1 executor so that this PR would have changed worker threads from 32 to 8.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use global tokio runtime per executor [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #1104:
URL: https://github.com/apache/datafusion-comet/pull/1104#issuecomment-2540230510
I'll close this for now. Thanks for the feedback @kazuyukitanimura and @viirya
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use global tokio runtime per executor [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove closed pull request #1104: feat: Use global tokio runtime per executor
URL: https://github.com/apache/datafusion-comet/pull/1104
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use global tokio runtime per executor [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #1104:
URL: https://github.com/apache/datafusion-comet/pull/1104#issuecomment-2529573304
I ran more benchmarks and experimented with number of threads but I am seeing some variability in results. It is hard to tell how much difference this really makes.
Maybe I should just close this PR, but typically, there is one Tokio runtime per process, and I am not sure what the original reason was for creating a new runtime per native query. @viirya do you know why we do this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use global tokio runtime per executor [datafusion-comet]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on PR #1104:
URL: https://github.com/apache/datafusion-comet/pull/1104#issuecomment-2529664167
> Maybe I should just close this PR, but typically, there is one Tokio runtime per process, and I am not sure what the original reason was for creating a new runtime per native query. @viirya do you know why we do this?
No special reason. The original idea is to create Tokio runtime once going to run a query. And I think that one runtime per query can prevent one particular query to monopolize the runtime and starve another queries?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use global tokio runtime per executor [datafusion-comet]
Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #1104:
URL: https://github.com/apache/datafusion-comet/pull/1104#discussion_r1866463312
##########
native/core/src/execution/jni_api.rs:
##########
@@ -61,6 +61,20 @@ use tokio::runtime::Runtime;
use crate::execution::operators::ScanExec;
use log::info;
+use once_cell::sync::Lazy;
+
+static TOKIO_RUNTIME: Lazy<Runtime> = Lazy::new(|| {
Review Comment:
Perhaps this should be once per session (a user could modify the config in the session or run different queries in a single job that might require independent configuration)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use global tokio runtime per executor [datafusion-comet]
Posted by "kazuyukitanimura (via GitHub)" <gi...@apache.org>.
kazuyukitanimura commented on PR #1104:
URL: https://github.com/apache/datafusion-comet/pull/1104#issuecomment-2486923253
Wondering if the performance improvement comes from different numbers of threads? Are the default numbers are the same?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use global tokio runtime per executor [datafusion-comet]
Posted by "kazuyukitanimura (via GitHub)" <gi...@apache.org>.
kazuyukitanimura commented on PR #1104:
URL: https://github.com/apache/datafusion-comet/pull/1104#issuecomment-2518770663
> I didn't make a note of the benchmark settings I used but it was likely 8 cores in 1 executor so that this PR would have changed worker threads from 32 to 8.
If `COMET_WORKER_THREADS` is set to 1 with the existing local tokio runtime, do we still see the 2% gain? If yes, then we can say that is due to the reduced (less congested) threads. If no, we can say it is thanks to the global runtime?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org