Page MenuHomePhabricator

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

Authored by karol on Sep 12 2022, 7:10 AM.
Tags
None
Referenced Files
F3210864: D5112.diff
Sun, Nov 10, 6:57 AM
Unknown Object (File)
Tue, Nov 5, 11:34 PM
Unknown Object (File)
Tue, Nov 5, 9:44 PM
Unknown Object (File)
Tue, Nov 5, 9:40 PM
Unknown Object (File)
Tue, Nov 5, 9:36 PM
Unknown Object (File)
Sun, Nov 3, 7:01 AM
Unknown Object (File)
Mon, Oct 28, 7:56 AM
Unknown Object (File)
Sun, Oct 27, 8:13 PM

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 ↗(On Diff #16653)

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 ↗(On Diff #16653)

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.