Page MenuHomePhabricator

[services] Rust Integration - c++ - Add getNumberOfCores
ClosedPublic

Authored by karol on Sep 12 2022, 7:10 AM.
Tags
None
Referenced Files
F3536221: D5112.id16583.diff
Wed, Dec 25, 5:49 PM
F3534714: D5112.id16583.diff
Wed, Dec 25, 1:11 PM
Unknown Object (File)
Sat, Dec 21, 7:18 PM
Unknown Object (File)
Sat, Dec 14, 6:38 AM
Unknown Object (File)
Sat, Dec 14, 6:38 AM
Unknown Object (File)
Sat, Dec 14, 6:38 AM
Unknown Object (File)
Sat, Dec 14, 6:37 AM
Unknown Object (File)
Sat, Dec 14, 6:37 AM

Details

Summary

Depends on D5038

We need a thread pool to address the grpc's threading problem in c++. To decide what can be a limit for the threads in the thread pool, we should probably obtain a number of CPUs on the machine.

Test Plan

services build as usual

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

This revision is now accepted and ready to land.Sep 12 2022, 9:09 AM
tomek requested changes to this revision.Sep 13 2022, 11:01 AM
tomek added inline comments.
services/lib/src/GlobalTools.cpp
32 ↗(On Diff #16583)

This name is confusing: for the majority of devices the number of CPUs is simply 1. What you probably wanted to express here is the number of cores. I guess that due to features like multi-threading, the number of cores doesn't necessarily equals number of hardware threads, but still that name is a lot less misleading.

Returns the number of concurrent threads supported by the implementation.

33 ↗(On Diff #16583)

The docs https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency specify that the return value is

Number of concurrent threads supported. If the value is not well defined or not computable, returns ​0​.

But we're not handling the 0 in any way.

This revision now requires changes to proceed.Sep 13 2022, 11:01 AM

Thanks for the review. Addressed feedback.

tomek added inline comments.
services/lib/src/GlobalTools.cpp
34

Have you checked if u suffix works?

This revision is now accepted and ready to land.Sep 15 2022, 7:30 AM
karol retitled this revision from [services] Rust Integration - c++ - Add getNumberOfCpus to [services] Rust Integration - c++ - Add getNumberOfCores.Sep 16 2022, 1:47 AM
services/lib/src/GlobalTools.cpp
34

it works, thx

This revision was landed with ongoing or failed builds.Sep 16 2022, 1:55 AM
This revision was automatically updated to reflect the committed changes.