You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the grpc native node module in an Electron app. I expect similar roundtrip performance when sending gRPC messages in the main process vs. in the renderer process.
On macOS, performance is equivalent. On Windows, the roundtrip times for gRPC messages sent from the renderer process are, on average, ~200x slower than when sent from the main process.
$ git clone -b sr/electron-2.0 https://github.com/descriptinc/grpc-electron-test
$ cd grpc-electron-test
$ yarn install
# in one terminal
$ node example/greeter_server.js
# in another terminal
$ yarn start
It runs the same gRPC test in the main process and in the renderer process and then shows the results in the renderer BrowserWindow. It computes the average round-trip time for a simple gRPC message (200 messages, sent at an interval of 10 ms. The problem persists even if the interval is much greater).
On Windows I get a result like:
Average gRPC roundtrip (running in main): 0.62ms
Average gRPC roundtrip (running in renderer): 145.94ms
While on macOS I get a result like:
Average roundtrip (running in main): 1.29ms
Average roundtrip (running in renderer): 1.33ms
OS name, version and architecture: Windows 10 64 bit, Windows Server 2016 (on EC2) 64 bit
Node version: 8.11.3
Node installation method: yarn
Package name and version: gRPC@1.13.1
Additional context
I'm not sure if the real issue here is in Electron or in gRPC. I opened an issue there, too: electron/electron#14011
I'm guessing that this is somehow related to the different way that Windows and Mac/Linux implement the node.js runtime binding in the renderer process, i.e.,
As a sort of "if it hurts, don't do it", why not using the main process at all times to send RPCs? It's a bit less straightforward, but you could use electron's IPC from renderer to main in order to send and receive your messages. I've seen other electron apps doing this for the same reason, with other native modules than grpc.
Yeah, that’s certainly an option and probably the approach I’ll end up taking.
The main reason for “why not” is that we compute the gRPC messages based on model instances that we have access to in the renderer. So, there are a few ways to get that data (or the gRPC message data) to the main process, but they’re messier than sending those messages directly from the renderer.
I hope the existence of this bug report is useful for people using gRPC on Electron and Windows, even if there’s no plan on fixing it.
Problem description
I am using the
grpc
native node module in an Electron app. I expect similar roundtrip performance when sending gRPC messages in the main process vs. in the renderer process.On macOS, performance is equivalent. On Windows, the roundtrip times for gRPC messages sent from the renderer process are, on average, ~200x slower than when sent from the main process.
Reproduction steps
This repo shows the described behavior: https://github.com/descriptinc/grpc-electron-test/tree/sr/electron-2.0
It runs the same gRPC test in the main process and in the renderer process and then shows the results in the renderer BrowserWindow. It computes the average round-trip time for a simple gRPC message (200 messages, sent at an interval of 10 ms. The problem persists even if the interval is much greater).
On Windows I get a result like:
While on macOS I get a result like:
Note: I get the expected behavior in Windows if I switch to the alpha/experimental
@grpc/grpc-js
module. See: https://github.com/descriptinc/grpc-electron-test/tree/sr/electron-3.0-grpc-js (Electron 3 is required because@grpc/grpc-js
requires node >= 9.0.0).Environment
Additional context
I'm not sure if the real issue here is in Electron or in gRPC. I opened an issue there, too: electron/electron#14011
I'm guessing that this is somehow related to the different way that Windows and Mac/Linux implement the node.js runtime binding in the renderer process, i.e.,
The text was updated successfully, but these errors were encountered: