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

GatewayClient.bind() takes around 3 seconds #337

Open
gnarea opened this issue Sep 18, 2023 · 2 comments
Open

GatewayClient.bind() takes around 3 seconds #337

gnarea opened this issue Sep 18, 2023 · 2 comments

Comments

@gnarea
Copy link
Member

gnarea commented Sep 18, 2023

Using the logging from Letro, we can see that GatewayClient.bind() takes around 3 seconds on a Pixel 2 (Android 11):

2023-09-18 13:08:45.244  8799-8910  AwalaManager            tech.relaycorp.letro                 I  GatewayClient binding...
2023-09-18 13:08:47.218  8799-8799  d$2$serviceConnection$1 tech.relaycorp.letro                 I  Connected to service tech.relaycorp.gateway - tech.relaycorp.gateway.background.endpoint.GatewaySyncService
2023-09-18 13:08:48.221  8799-8910  AwalaManager            tech.relaycorp.letro                 I  GatewayClient bound

It's around 800ms on a Pixel 5 (Android 13).

@sdsantos
Copy link
Collaborator

Binding is composed of basically 2 steps:

  • A system call to bind with the Awala app
  • A hardcoded delay we introduced of 1 second to wait for the HTTP server to start on the Gateway app

We can play around with our 1-second delay, or try pinging the HTTP server directly to figure out if it's running. But we can't do much about the system call. I feel it can be extra slow if it's waking up the Gateway app.

@gnarea
Copy link
Member Author

gnarea commented Sep 21, 2023

Thanks @sdsantos!

There's a 1-second delay indeed. I must've done the math wrong for the Pixel 5. I've started Letro a few times on the Pixel 5 and GatewayClient.bind() takes at least 1.5 seconds, which makes sense.

I'm more interested in the system call, since that must be what's having the biggest impact on older devices where this can take 3 or so seconds. Looking at the stuff around ServiceInteractor I get the impression that we're waiting for the Awala app to start and be bound -- is this correct?

If so, it'd be interesting to explore what we can do speed this up in the Awala app. Especially if there's any low-hanging fruit there. But I wouldn't do that just yet as I'm more concerned about #336.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants