2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2016 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/runtime/base/runtime-option.h"
19 #include <folly/Random.h>
24 void logPerfWarningImpl(folly::StringPiece event
, int64_t priority
,
25 int64_t rate
, F fillCols
) {
26 auto const effectiveRate
= rate
* RuntimeOption::EvalPerfWarningSampleRate
;
27 if (effectiveRate
> std::numeric_limits
<uint32_t>::max()) return;
28 if (!StructuredLog::coinflip(effectiveRate
)) return;
30 StructuredLogEntry cols
;
32 cols
.setStr("event_name", event
);
33 cols
.setInt("priority", priority
);
34 StructuredLog::log("hhvm_perf_warning", cols
);
38 void logPerfWarning(folly::StringPiece event
, F fillCols
) {
39 logPerfWarningImpl(event
, 1, kDefaultPerfWarningRate
, fillCols
);
42 void logPerfWarning(folly::StringPiece event
, int64_t rate
, F fillCols
) {
43 logPerfWarningImpl(event
, 1, rate
, fillCols
);
47 void logLowPriPerfWarning(folly::StringPiece event
, F fillCols
) {
48 logPerfWarningImpl(event
, 0, kDefaultPerfWarningRate
, fillCols
);
51 void logLowPriPerfWarning(folly::StringPiece event
, int64_t rate
, F fillCols
) {
52 logPerfWarningImpl(event
, 0, rate
, fillCols
);
55 template<typename AHM
>
56 void checkAHMSubMaps(const AHM
& map
, folly::StringPiece mapName
,
57 std::atomic
<bool>& done
) {
58 if (LIKELY(map
.numSubMaps() == 1) ||
59 done
.load(std::memory_order_acquire
) ||
60 done
.exchange(true, std::memory_order_acq_rel
)) {
64 logAHMSubMapWarning(mapName
);