Microoptimisation 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

Review URL: https://codereview.chromium.org/1255293006

Cr-Commit-Position: refs/heads/master@{#342076}


CrOS-Libchrome-Original-Commit: 9ea8ee354b50ab621ea663636c5fc7a91c8e3226
2 files changed
tree: 9c4968ba26d45d1e9d45f72c7505bad41cfee3a2
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/