DescriptionMicrooptimisation for OnLibeventNotification.
OnLibeventNotification created a weak ptr to check that
OnFileCanWriteWithoutBlocking() has not deleted theFileDescriptorWatcher
object.
Creating a WeakPtr performs an allocation.
OnLibeventNotification is called often enough that it accounted for
roughly 5% of the allocations performed by the browser.
The allocation can be avoided by using a boolean variable to
flag whether or not the FileDescriptorWatcher object has been destroyed.
Furthermore, when only one of OnFileCanWriteWithoutBlocking() and
OnFileCanReadWithoutBlocking() is going to be called, it is not necessary to
check whether the FileDescriptorWatcher has been destroyed at all.
Results from running the IPCChannelPerfTest.ChannelPingPong performance
test with and without this change (all times in ms):
IPC_Channel_Perf_50000x_12: 542.8 (s = 6.1) to 524.5 (s = 4.0)
IPC_Channel_Perf_50000x_144: 552.8 (s = 6.8) to 537.2 (s = 5.1)
IPC_Channel_Perf_50000x_1728: 572.5 (s = 6.7) to 553.7 (s = 6.7)
IPC_Channel_Perf_12000x_20736: 305.7 (s = 4.2) to 305.1 (s = 3.2)
IPC_Channel_Perf_1000x_248832: 365.0 (s = 3.7) to 361.3 (s = 2.9)
My test environment was too noisy to demonstrate a statistically
significant improvement on the last two cases, but I think it should be
possible.
BUG=
TEST=base_unittests, net_unittests
Committed: https://crrev.com/9ea8ee354b50ab621ea663636c5fc7a91c8e3226
Cr-Commit-Position: refs/heads/master@{#342076}
Patch Set 1 #Patch Set 2 : Fix the logic for creating the weak pointer. #Patch Set 3 : Eliminate WeakPtr completely. #Patch Set 4 : Try to improve readability by separating the cases. #
Total comments: 6
Patch Set 5 : Minor changes requested by thestig@. #
Messages
Total messages: 25 (8 generated)
|