Improve concurrency for logging arrays
commit7e0f846810bf3dca247f8d32c2c50a4935eff22b
authorMichael Colavita <mcolavita@fb.com>
Thu, 13 Aug 2020 16:18:41 +0000 (13 09:18 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 13 Aug 2020 16:20:32 +0000 (13 09:20 -0700)
treec5e6c1e28313e09d6c1aaa41be4053e76a45bca3
parent2f48cc11fd568a8ed2919a8d611817f1b2f33c15
Improve concurrency for logging arrays

Summary:
Improves concurrency for creation of logging arrays. Changes:

1) Create a `LoggingProfile` struct that is shared among all LoggingArrays created at the same SrcKey. This profile contains the SrcKey and a sampling counter used to determine whether a logging array should be emitted when a new array is created at that location.
2) In `maybeEnableLogging`, take a lock only when we are at a SrcKey that has not yet been encountered. The read path takes no locks thanks to ConcurrentHashMap.
3) In `makeFromStatic`, a lock is taken only when we are at a SrcKey that has not been previously encountered.
4) Migrate `makeFromStatic` and `makeFromVanilla` to be helpers in the unnamed namespace and accept a `LoggingProfile` instead of a SrcKey.

Differential Revision: D23053339

fbshipit-source-id: b43e0d4f7ee2c9c3f4e4c063abf9c92d4ee1fa91
hphp/runtime/base/bespoke/logging-array.cpp
hphp/runtime/base/bespoke/logging-array.h