[regexp] Add a histogram counter for # of backtracks
The new regexp_backtracks / V8.RegExpBacktracks counter tracks the number of backtracks performed per regexp execution. The results can help us prioritize related work. Note that we only count backtracks in the interpreter. Jitted code is ignored. With our current regexp tiering strategy, that means we count backtracks only in the first execution of each regexp. Chromium CL: https://crrev.com/c/1871601 Bug: v8:9892 Change-Id: I19146d6e9bc2355f210a050e93dd7e856ab066f3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873696 Auto-Submit: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Peter Marshall <petermarshall@chromium.org> Commit-Queue: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#64467}
This commit is contained in:
parent
3fb083fe59
commit
31e08912bb
@ -94,7 +94,10 @@ namespace internal {
|
||||
/* bailout reason if Liftoff failed, or {kSuccess} (per function) */ \
|
||||
HR(liftoff_bailout_reasons, V8.LiftoffBailoutReasons, 0, 20, 21) \
|
||||
/* Ticks observed in a single Turbofan compilation, in 1K */ \
|
||||
HR(turbofan_ticks, V8.TurboFan1KTicks, 0, 100000, 200)
|
||||
HR(turbofan_ticks, V8.TurboFan1KTicks, 0, 100000, 200) \
|
||||
/* Backtracks observed in a single regexp interpreter execution */ \
|
||||
/* The maximum of 100M backtracks takes roughly 2 seconds on my machine. */ \
|
||||
HR(regexp_backtracks, V8.RegExpBacktracks, 1, 100000000, 50)
|
||||
|
||||
#define HISTOGRAM_TIMER_LIST(HT) \
|
||||
/* Timer histograms, not thread safe: HT(name, caption, max, unit) */ \
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/base/small-vector.h"
|
||||
#include "src/logging/counters.h"
|
||||
#include "src/objects/js-regexp-inl.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "src/regexp/regexp-bytecodes.h"
|
||||
@ -456,8 +457,16 @@ IrregexpInterpreter::Result RawMatch(Isolate* isolate, ByteArray code_array,
|
||||
registers[insn >> BYTECODE_SHIFT] = backtrack_stack.pop();
|
||||
DISPATCH();
|
||||
}
|
||||
BYTECODE(FAIL) { return IrregexpInterpreter::FAILURE; }
|
||||
BYTECODE(SUCCEED) { return IrregexpInterpreter::SUCCESS; }
|
||||
BYTECODE(FAIL) {
|
||||
isolate->counters()->regexp_backtracks()->AddSample(
|
||||
static_cast<int>(backtrack_count));
|
||||
return IrregexpInterpreter::FAILURE;
|
||||
}
|
||||
BYTECODE(SUCCEED) {
|
||||
isolate->counters()->regexp_backtracks()->AddSample(
|
||||
static_cast<int>(backtrack_count));
|
||||
return IrregexpInterpreter::SUCCESS;
|
||||
}
|
||||
BYTECODE(ADVANCE_CP) {
|
||||
ADVANCE(ADVANCE_CP);
|
||||
current += insn >> BYTECODE_SHIFT;
|
||||
|
Loading…
Reference in New Issue
Block a user