-
Notifications
You must be signed in to change notification settings - Fork 318
Allow user to limit the number of threads that OpenMP spawns. #1362
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
Conversation
Managing GUC parameters in different places is hard to maintain. This patch organizes GUC definitions in a single place. Also, we use define_xxx_guc() APIs to define these parameters and it will allow us to manage GucContext, GucFlags in future. P.S., the test case test_trusted_model doesn't seem correct. I fixed it in this patch.
This patch introduces a new GUC parameter pgml.omp_num_threads to control control the number of threads that OpenMP can spawn. Co-authored-by: Xuebin Su <sxuebin@vmware.com> Co-authored-by: Xuebin Su (苏学斌) <12034000+xuebinsu@users.noreply.github.com>
pgml-extension/Cargo.toml
Outdated
@@ -49,6 +49,7 @@ serde = { version = "1.0" } | |||
serde_json = { version = "1.0", features = ["preserve_order"] } | |||
typetag = "0.2" | |||
xgboost = { git = "https://github.com/postgresml/rust-xgboost", branch = "master" } | |||
lazy_static = "1.4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the once_cell::sync::Lazy
since we already have that dependency, rather than adding a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
e909ac5
to
3768179
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the additional suggestions but I think we should be good after this.
pgml-extension/src/lib.rs
Outdated
#[cfg(not(feature = "use_as_lib"))] | ||
#[pg_guard] | ||
pub extern "C" fn _PG_init() { | ||
config::initialize_server_params(); | ||
let omp_num_threads = config::PGML_OMP_NUM_THREADS.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move this get/set into the config::initialize_server_params()
also. It's specifically configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the additional suggestions but I think we should be good after this.
Co-authored-by: kczimm <4733573+kczimm@users.noreply.github.com>
Co-authored-by: kczimm <4733573+kczimm@users.noreply.github.com>
- Set the minimum value of OMP_NUM_THREADS to 1. - Move PGML_OMP_NUM_THREADS.get() into initialize_server_params().
No problem! Glad to hear more suggestions from you :-) |
This patch introduces a new GUC parameter pgml.omp_num_threads to
control control the number of threads that OpenMP can spawn.
This PR contains 2 commits. The first one is refactoring the GUC parameters of pgml (#1360). The second one is for allowing user to control the number of threads that OpenMP can spawn.
Fixes #1161
Depends on #1360 which helps manage GUC parameters better.