-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Use two times less workers for better performance #3565
Conversation
I'd like to test out using a single worker everywhere. When I was testing startup time, using only a single worker was significantly faster (for startup performance) than using more than one. If the price of starting a worker is so high, and the marginal benefit even after it warms up is low, we may be better off with just one, even after startup. It would make stuff like cross-source label placement significantly easier. |
Sounds good to me, but can we benchmark this before merging? |
62fa709
to
c3dde59
Compare
Updated the formula to use @jfirebaugh I suggest reducing the number of workers for now (because they need to be reduced in any case), and following up with workerCount=1 experiments after, because this will need a dedicated non-trivial benchmark to measure reliably. |
I performed a very basic test were I load the full-screen debug page and then zoom out with a button 4 times (each time waiting for tile loads). Here are the results (the first number is the total tile loading times):
You can see that a single worker performs significantly worse than other numbers in this scenario. Too much workers (7) is also apparently not helping. The best number seems to be around 3 or 4 on my machine. I'll now try a more stressful test with a slow |
A 30s flyTo across the US:
Which seems to also support the conclusion that 1 worker is a bad idea (at least for the desktop), but there's not much sense in using more than 2-3. |
Made a more reliable benchmark by enabling browser caching (to exclude tile loading times), flying in 20s for more stressful test, and counting loaded tiles and aborted tiles separately (with aborted not being counted towards total):
Notice that 1 worker result has 3x the amount of aborted tiles. Same conclusion — 2-4 is good (3 seems best), 1 is bad, 7 is unnecessary. |
Nice tests! More tests on Firefox, safari would be more convincing. |
Firefox:
Safari:
|
c3dde59
to
5bd4377
Compare
Looking at benchmarks in all browsers, settled on |
@mourner The average numbers reported here assume that worker spent 0ms for aborted tiles. Is this a valid assumption? |
@mb12 the average numbers are calculated from non-aborted tile numbers + loading times. It doesn't make sense to calculate average for aborted and loaded tiles combined because lower average can be a consequence of more aborted tiles (which is the more important metric here). |
Thanks for the clarification. I misunderstood how 'loading times' were computed. |
Based on our conversation with Chrome engineers, using anything more than
num_cores / 2
actually makes things worse because those additional workers usually get heavily deprioritized to make room for other stuff (for Chrome and the system). You can see which workers are deprioritized based on their background color in the tracing profile, and also comparing the wall time to CPU time there.This may explain our earlier observations where worker messages would suddenly get deprioritized and start lagging heavily, such as on the point drag example.
Per further recommendations from the Chrome engineers, we need to follow-up with a PR that sets the worker count to
1
for mobile devices, although we first need to come up with a good way to detect a mobile phone (preferably not involving user agent parsing).cc @jfirebaugh @ansis @lucaswoj