Skip to content

[c++] Refine concurrency configuration (soma.compute_concurrency_level)#2978

Merged
bkmartinjr merged 14 commits intomainfrom
bkmartinjr/54891-concurrency-config
Sep 12, 2024
Merged

[c++] Refine concurrency configuration (soma.compute_concurrency_level)#2978
bkmartinjr merged 14 commits intomainfrom
bkmartinjr/54891-concurrency-config

Conversation

@bkmartinjr
Copy link
Copy Markdown
Member

@bkmartinjr bkmartinjr commented Sep 11, 2024

Issue and/or context:

Introduces direct control over the native thread pool concurrency level in SOMA. Previously, it was indirectly controlled by the TileDB Core sm.compute_currency_control configuration, and would create a thread pool that was 1/2 the size of that value.

Changes:

This PR introduces a new context configuration setting: soma.compute_currency_level, which defaults to the host CPU count. It can be set with an numeric value,eg., in Python:

context = tiledbsoma.SOMATileDBContext(tiledb_config={"soma.compute_currency_level": "20"})

Notes for Reviewer:

sc-54891

the PR also adds:

  • improved error handling for malformed config values
  • bound the value between 1 and 1024

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 9.09091% with 10 lines in your changes missing coverage. Please review.

Project coverage is 61.23%. Comparing base (0cfb1bd) to head (e253b1a).
Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2978       +/-   ##
===========================================
- Coverage   89.73%   61.23%   -28.50%     
===========================================
  Files          39       94       +55     
  Lines        4080    12530     +8450     
  Branches        0      786      +786     
===========================================
+ Hits         3661     7673     +4012     
- Misses        419     4657     +4238     
- Partials        0      200      +200     
Flag Coverage Δ
libtiledbsoma 47.40% <9.09%> (?)
python 89.87% <ø> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
python_api 89.87% <ø> (+0.14%) ⬆️
libtiledbsoma 50.01% <9.09%> (∅)

@johnkerl johnkerl changed the title Refine concurrency configuration (soma.compute_concurrency_level) [c++] Refine concurrency configuration (soma.compute_concurrency_level) Sep 11, 2024
Comment thread apis/python/tests/test_context.py Outdated
import numpy as np

with pytest.raises(tiledbsoma.SOMAError):
with pytest.raises((tiledbsoma.SOMAError, RuntimeError)):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'll help you fix this -- already done on #2963

  • * We're aware of
    * https://pybind11.readthedocs.io/en/stable/advanced/exceptions.html
    * -- we find empirically that despite this translator, we still
    * find it necessary to do explicit catch-and-rethrow within our
    * pybind11 functions. See also
    * https://github.com/single-cell-data/TileDB-SOMA/pull/2963
    */
    py::register_exception_translator([](std::exception_ptr p) {
    auto tiledb_soma_error = (py::object)py::module::import("tiledbsoma")
    .attr("SOMAError");
  • try {
    array.set_dim_points(dim, points);
    } catch (const std::exception& e) {
    throw TileDBSOMAError(e.what());
    }
    (one example callsite)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Broader issue - filed as sc-54978

@bkmartinjr bkmartinjr marked this pull request as ready for review September 11, 2024 20:22
Copy link
Copy Markdown
Contributor

@johnkerl johnkerl left a comment

Choose a reason for hiding this comment

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

LGTM but I do defer to @nguyenv



def test_malformed_concurrency_config_value():
import numpy as np
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why import in the test instead of up top?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just trying to isolate test dependencies. But not a major issue either way....

@bkmartinjr bkmartinjr merged commit 16c9dff into main Sep 12, 2024
@bkmartinjr bkmartinjr deleted the bkmartinjr/54891-concurrency-config branch September 12, 2024 17:10
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.

3 participants