DescriptionCache vectors to avoid heap allocations on each message pump iteration.
In Chrome, MessagePumpMojo::DoInternalWork causes ~50,000 heap
allocations when loading The Verge. This change drops that to ~5000,
measured on a debug build.
On each loop, WaitState has two vectors which are allocated, and resized
multiple times. Caching the WaitState between iterations largely
eliminates those allocations.
The story with |cloned_handlers| is a bit different. HandleToHandler is
a hash map, and GCC's implementation does a heap allocation for every
new element added. That means at least handlers_.size() allocations on
every iteration. This replaces that with a single allocaiton in a
vector.
Chrome's MojoChannelPerfTest doesn't show a significant improvement.
Showing (min/max/mean/median/stddev) in ms per run over 10 runs:
IPC_Channel_Perf_50000x_12
before
1016 1046 1030 1030 7.5
after
998 1032 1013 1011 10.3
IPC_ChannelProxy_Perf_50000x_12
before
1804 3809 2633 2486 637
after
2019 3690 2625 2413 489
And in case you're wondering, the remaining ~5000 heap allocations are
mostly in mojo::system::Core::WaitMany().
R=qsr@chromium.org
Committed: https://chromium.googlesource.com/external/mojo/+/ecf671725e139e27d8e07073e0722d10829e28c7
Patch Set 1 #
Total comments: 10
Patch Set 2 : Review comments. #Patch Set 3 : Review round 2. #Patch Set 4 : Rebase #
Messages
Total messages: 13 (3 generated)
|