Page MenuHomePhabricator

[native] create bridge module and runtime
ClosedPublic

Authored by varun on Aug 1 2022, 2:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 8, 3:23 PM
Unknown Object (File)
Fri, Nov 8, 3:23 PM
Unknown Object (File)
Fri, Nov 8, 3:23 PM
Unknown Object (File)
Fri, Nov 8, 3:22 PM
Unknown Object (File)
Fri, Nov 8, 3:19 PM
Unknown Object (File)
Tue, Oct 22, 7:34 AM
Unknown Object (File)
Oct 7 2024, 3:36 PM
Unknown Object (File)
Sep 24 2024, 11:24 PM

Details

Summary

lazily create a static tokio runtime object that can be passed around for client calls. create the ffi module where library APIs will go.

Test Plan

cargo build

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.Aug 1 2022, 2:43 PM
tomek requested changes to this revision.Aug 2 2022, 2:40 AM

Seems like creating runtime and including FFI aren't related tasks - maybe they should be separated into two diffs?

native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs
11–12 ↗(On Diff #15181)

What is the reason behind setting these values?

worker_threads defaults to the number of cores - is there something wrong with this value?
max_blocking_threads has a default of 512. These threads are used for blocking operations - is it really a good idea to have such a low value?

This revision now requires changes to proceed.Aug 2 2022, 2:40 AM
In D4707#135267, @tomek wrote:

Seems like creating runtime and including FFI aren't related tasks - maybe they should be separated into two diffs?

I can move the FFI stuff to a subsequent diff

remove bridge module

native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs
11–12 ↗(On Diff #15181)

Since this library is for the native app, I think we should first make sure the runtime works on a single thread, and then we can look into using more

tomek added inline comments.
native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs
11–12 ↗(On Diff #15181)

Ah, ok, that makes sense. But at the same time, it might be a good idea to perform some testing to check if we can use more threads in the future. If it happens that iOS limits us significantly, the sooner we know about it the better.

This revision is now accepted and ready to land.Aug 2 2022, 9:17 AM
native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs
11–12 ↗(On Diff #15181)

One additional thing to consider is that we were trying to be able to respond to iOS notifications without using additional threads (before the app is started). The reason was that we believed that using more threads could make the notifications less likely to be delivered. If using gRPC always happens using separate thread, it could be a potential issue for us. CC @ashoat

This revision was automatically updated to reflect the committed changes.
native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs
11–12 ↗(On Diff #15181)

Agree we should use as few threads as possible. Not sure how easy it would be to have the main thread handle gRPC... assume it would require blocking calls, and would preclude the use of a separate runtime... so would probably have to be a custom codepath.

With that said, I do think we should make sure to keep the thread pool minimal in the background notif case as well as the Notification Service Extension case. Before we increase this number beyond 1, we should do some work to make it possible to detect the context, so we can keep it to 1 for the above cases.