Skip to content
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

[Core] make StringIdMap thread safe #22893

Merged
merged 2 commits into from
Mar 8, 2022

Conversation

wumuzi520
Copy link
Contributor

@wumuzi520 wumuzi520 commented Mar 8, 2022

Why are these changes needed?

Another PR(#22817) refactoring the legacy resource data structure from ResourceSet to ResourceRequest and from SchedulingResources to Node, which depends on scheduling::ResourceID.

But, the StringIdMap is wrapped by ThreadPrivate inside BaseSchedulingID, which means the scheduling::ResourceID and scheduling::NodeID can only be visited in one single thread. However, many C++ UTs have such a scenario: restarting the GCS server multiple times in the same process, each restart will reset the GcsServer object and change a new thread, which will cause multiple threads to access StringIdMap in the different time.

Beside, the GCS may have multi-threads in the future, it is possible that in the future there will be multiple threads accessing the StringIdMap

So, this PR make StringIdMap thread safe.

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@wumuzi520 wumuzi520 changed the title make StringIdMap thread safe [WIP][Core] make StringIdMap thread safe Mar 8, 2022
@wumuzi520 wumuzi520 force-pushed the make_string_id_map_thread_safe branch 4 times, most recently from b21c836 to fd4d631 Compare March 8, 2022 05:55
@wumuzi520 wumuzi520 force-pushed the make_string_id_map_thread_safe branch 2 times, most recently from 8872efe to fc65966 Compare March 8, 2022 06:21
@wumuzi520 wumuzi520 changed the title [WIP][Core] make StringIdMap thread safe [Core] make StringIdMap thread safe Mar 8, 2022
@scv119
Copy link
Contributor

scv119 commented Mar 8, 2022

microbenchmark result:

{"single_client_get_calls_Plasma_Store": [5790.815519044334, 148.92260597977426], "single_client_put_calls_Plasma_Store": [4372.098618875549, 10.15471490167108], "multi_client_put_calls_Plasma_Store": [9563.76323784758, 57.94272163733077], "single_client_put_gigabytes": [13.943759252601867, 3.0471357661505576], "single_client_tasks_and_get_batch": [9.385313711279887, 0.04236935259512758], "multi_client_put_gigabytes": [7.10912756139562, 0.5594494022902039], "single_client_get_object_containing_10k_refs": [14.623165557495081, 0.02447091072593552], "single_client_tasks_sync": [1526.651648726323, 5.124436687275942], "single_client_tasks_async": [9206.257327530355, 65.87480980457345], "multi_client_tasks_async": [10324.538063949625, 143.88048299769758], "1_1_actor_calls_sync": [2637.0289698983574, 12.894607316293243], "1_1_actor_calls_async": [6021.686287261517, 91.8225147676578], "1_1_actor_calls_concurrent": [5018.253150418268, 39.80705381990989], "1_n_actor_calls_async": [8917.040924225807, 32.83275890958308], "n_n_actor_calls_async": [13154.73099778303, 76.71826591560907], "n_n_actor_calls_with_arg_async": [3056.814510257117, 80.7269314060778], "1_1_async_actor_calls_sync": [1767.362593685796, 9.017650518383183], "1_1_async_actor_calls_async": [3565.552973294091, 23.570889019867607], "1_1_async_actor_calls_with_args_async": [2391.7880544274262, 5.00107521063344], "1_n_async_actor_calls_async": [5997.456974780154, 42.930458124769906], "n_n_async_actor_calls_async": [8545.027368179746, 156.44482378594122], "placement_group_create/removal": [1099.906189057709, 6.568577829007929], "client__get_calls": [1518.3607888893844, 3.403318473128629], "client__put_calls": [718.9498605674409, 0.8193451515445498], "client__put_gigabytes": [0.04737091470473183, 0.00012889189344373155], "client__tasks_and_put_batch": [8973.351128895454, 66.93037447647836], "client__1_1_actor_calls_sync": [566.0864722140315, 0.9645521141581913], "client__1_1_actor_calls_async": [840.8236733302473, 7.550285579786444], "client__1_1_actor_calls_concurrent": [838.067122858635, 2.947284826728502], "client__tasks_and_get_batch": [0.7916935270820461, 0.007215860789810826], "perf_metrics": [{"perf_metric_name": "single_client_get_calls_Plasma_Store", "perf_metric_value": 5790.815519044334, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "single_client_put_calls_Plasma_Store", "perf_metric_value": 4372.098618875549, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "multi_client_put_calls_Plasma_Store", "perf_metric_value": 9563.76323784758, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "single_client_put_gigabytes", "perf_metric_value": 13.943759252601867, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "single_client_tasks_and_get_batch", "perf_metric_value": 9.385313711279887, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "multi_client_put_gigabytes", "perf_metric_value": 7.10912756139562, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "single_client_get_object_containing_10k_refs", "perf_metric_value": 14.623165557495081, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "single_client_tasks_sync", "perf_metric_value": 1526.651648726323, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "single_client_tasks_async", "perf_metric_value": 9206.257327530355, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "multi_client_tasks_async", "perf_metric_value": 10324.538063949625, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "1_1_actor_calls_sync", "perf_metric_value": 2637.0289698983574, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "1_1_actor_calls_async", "perf_metric_value": 6021.686287261517, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "1_1_actor_calls_concurrent", "perf_metric_value": 5018.253150418268, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "1_n_actor_calls_async", "perf_metric_value": 8917.040924225807, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "n_n_actor_calls_async", "perf_metric_value": 13154.73099778303, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "n_n_actor_calls_with_arg_async", "perf_metric_value": 3056.814510257117, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "1_1_async_actor_calls_sync", "perf_metric_value": 1767.362593685796, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "1_1_async_actor_calls_async", "perf_metric_value": 3565.552973294091, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "1_1_async_actor_calls_with_args_async", "perf_metric_value": 2391.7880544274262, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "1_n_async_actor_calls_async", "perf_metric_value": 5997.456974780154, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "n_n_async_actor_calls_async", "perf_metric_value": 8545.027368179746, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "placement_group_create/removal", "perf_metric_value": 1099.906189057709, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "client__get_calls", "perf_metric_value": 1518.3607888893844, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "client__put_calls", "perf_metric_value": 718.9498605674409, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "client__put_gigabytes", "perf_metric_value": 0.04737091470473183, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "client__tasks_and_put_batch", "perf_metric_value": 8973.351128895454, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "client__1_1_actor_calls_sync", "perf_metric_value": 566.0864722140315, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "client__1_1_actor_calls_async", "perf_metric_value": 840.8236733302473, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "client__1_1_actor_calls_concurrent", "perf_metric_value": 838.067122858635, "perf_metric_type": "THROUGHPUT"}, {"perf_metric_name": "client__tasks_and_get_batch", "perf_metric_value": 0.7916935270820461, "perf_metric_type": "THROUGHPUT"}]}

@scv119 scv119 merged commit 1e4d7bc into ray-project:master Mar 8, 2022
@jjyao
Copy link
Collaborator

jjyao commented Mar 8, 2022

What's C++ UT?

@scv119
Copy link
Contributor

scv119 commented Mar 8, 2022

ha C++ unit tests

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