Mojo: Optimize random port name generation

Desktop / Chromium - Ken Rockot [] - 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.


Change-Id: I3ad0cdc2705dab29aa2cb8aaaab77e7416400eb4 Reviewed-on: Commit-Queue: Ken Rockot

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


  • Share