Mojo: Optimize random port name generation

Desktop / Chromium - Ken Rockot [chromium.org] - 10 August 2017 16:32 EDT

Maintain a thread-safe cache of randomly generated port names from which to draw when new names are needed. This amortizes the per-call cost of base::RandBytes, which is otherwise called at very high frequency when many pipes are being created.

MessagePipeTest.ClosePipesStressTest creates lots of pipes in a tight loop. On POSIX this change reduces the running time of that test by ~20%.

On Windows there is also a marginal reduction of about ~4%, so this caching behavior is used unconditionally on all platforms.

BUG=754004

Change-Id: I3ad0cdc2705dab29aa2cb8aaaab77e7416400eb4 Reviewed-on: https://chromium-review.googlesource.com/610444 Commit-Queue: Ken Rockot

1dae18b Mojo: Optimize random port name generation
mojo/edk/system/ports/node.cc | 47 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 42 insertions(+), 5 deletions(-)

Upstream: git.chromium.org


  • Share