🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@higuoxing
Copy link
Contributor

@higuoxing higuoxing commented Mar 8, 2024

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.

higuoxing and others added 5 commits March 8, 2024 07:59
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>
@montanalow montanalow requested a review from kczimm April 4, 2024 04:29
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"
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@higuoxing higuoxing force-pushed the set-omp-num-threads branch from e909ac5 to 3768179 Compare April 6, 2024 16:08
Copy link
Contributor

@kczimm kczimm left a 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.

#[pg_guard]
pub extern "C" fn _PG_init() {
config::initialize_server_params();
let omp_num_threads = config::PGML_OMP_NUM_THREADS.get();
Copy link
Contributor

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.

Copy link
Contributor

@kczimm kczimm left a 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.

higuoxing and others added 3 commits April 11, 2024 07:34
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().
@higuoxing
Copy link
Contributor Author

Sorry for the additional suggestions but I think we should be good after this.

No problem! Glad to hear more suggestions from you :-)

@kczimm kczimm merged commit f674f70 into postgresml:master Apr 11, 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 this pull request may close these issues.

PostgresML is spawning too many threads.

2 participants