v8/test/unittests/compiler
Seth Brenith 922983dfd3 Profile-guided optimization of builtins
Design doc:
https://docs.google.com/document/d/1szInbXZfaErWW70d30hJsOLL0Es-l5_g8d2rXm1ZBqI/edit?usp=sharing

V8 can already collect data about how many times each basic block in the
builtins is run. This change enables using that data for profile-guided
optimization. New comments in BUILD.gn describe how to use this feature.

A few implementation details worth mentioning, which aren't covered in
the design doc:

- BasicBlockProfilerData currently contains an array of RPO numbers.
  However, this array is always just [0, 1, 2, 3, ...], so this change
  removes that array. A new DCHECK in BasicBlockInstrumentor::Instrument
  ensures that the removal is valid.

- RPO numbers, while useful for printing data that matches with the
  stringified schedule, are not useful for matching profiling data with
  blocks that haven't been scheduled yet. This change adds a new array
  of block IDs in BasicBlockProfilerData, so that block counters can be
  used for PGO.

- Basic block counters need to be written to a file so that they can be
  provided to a subsequent run of mksnapshot, but the design doc doesn't
  specify the transfer format or what file is used. In this change, I
  propose using the existing v8.log file for that purpose. Block count
  records look like this:

  block,TestLessThanHandler,37,29405

  This line indicates that block ID 37 in TestLessThanHandler was run
  29405 times. If multiple lines refer to the same block, the reader
  adds them all together. I like this format because it's easy to use:
  - V8 already has robust logic for creating the log file, naming it to
    avoid conflicts in multi-process situations, etc.
  - Line order doesn't matter, and interleaved writes from various
    logging sources are fine, given that V8 writes each line atomically.
  - Combining multiple sources of profiling data is as simple as
    concatenating their v8.log files together.

- It is a good idea to avoid making any changes based on profiling data
  if the function being compiled doesn't match the one that was
  profiled, since it is common to use profiling data downloaded from a
  central lab which is updated only periodically. To check whether a
  function matches, I propose using a hash of the Graph state right
  before scheduling. This might be stricter than necessary, as some
  changes to the function might be small enough that the profile data is
  still relevant, but I'd rather err on the side of not making incorrect
  changes. This hash is also written to the v8.log file, in a line that
  looks like this:

  builtin_hash,LdaZeroHandler,3387822046

Bug: v8:10470
Change-Id: I429e5ce5efa94e01e7489deb3996012cf860cf13
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2220765
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69008}
2020-07-22 17:12:23 +00:00
..
arm Revert "Move branch inversion on ==0 into platform-agnostic reducer" 2020-03-25 16:47:48 +00:00
arm64 [turbofan] Add SIMD multiply-add/sub on arm64 2020-05-13 09:40:00 +00:00
backend [zone] Cleanup zone allocations in src/compiler and tests, pt.1 2020-07-10 12:09:05 +00:00
ia32 [interpreter,compiler] Remove CodeAssembler::LoadStackPointer 2019-08-12 14:49:47 +00:00
mips Move architecture dependent files 2019-05-28 14:02:15 +00:00
mips64 Move architecture dependent files 2019-05-28 14:02:15 +00:00
ppc Move code generation related files to src/codegen 2019-05-21 10:33:39 +00:00
regalloc [TurboProp] Add framework to pipeline.cc for a fast register allocator. 2020-07-14 20:38:34 +00:00
s390 Move architecture dependent files 2019-05-28 14:02:15 +00:00
x64 [interpreter,compiler] Remove CodeAssembler::LoadStackPointer 2019-08-12 14:49:47 +00:00
branch-elimination-unittest.cc [compiler]Use Phi in Branch if control flow is known 2019-08-28 19:12:03 +00:00
bytecode-analysis-unittest.cc [interpreter] Make IterationBody StackChecks implicit within JumpLoop 2020-03-20 13:22:41 +00:00
checkpoint-elimination-unittest.cc [cleanup] Refactor compiler to use default members. 2018-09-17 12:12:21 +00:00
common-operator-reducer-unittest.cc [compiler] Don't serialize BytecodeArrayData's source_positions_ 2020-07-14 11:01:44 +00:00
common-operator-unittest.cc [tests] Fix subobject-linkage error when building with GCC 2019-10-07 11:11:39 +00:00
compiler-test-utils.h [turbofan] Drop V8_TURBOFAN_BACKEND and V8_TURBOFAN_TARGET defines. 2015-08-10 07:17:34 +00:00
constant-folding-reducer-unittest.cc [compiler] Don't serialize BytecodeArrayData's source_positions_ 2020-07-14 11:01:44 +00:00
control-equivalence-unittest.cc Move utility code to src/utils 2019-05-23 14:13:34 +00:00
control-flow-optimizer-unittest.cc [turbofan] introduce a deterministic tick measurement and assert optimization doesn't take too long 2019-07-17 07:00:00 +00:00
dead-code-elimination-unittest.cc [cleanup] Refactor compiler to use default members. 2018-09-17 12:12:21 +00:00
decompression-optimizer-unittest.cc [zone] Cleanup zone allocations in src/compiler and tests, pt.3 2020-07-10 16:39:05 +00:00
diamond-unittest.cc [cleanup] [compiler] Fix (D)CHECK macros 2017-09-25 10:21:34 +00:00
effect-control-linearizer-unittest.cc [zone] Cleanup zone allocations in src/compiler and tests, pt.3 2020-07-10 16:39:05 +00:00
graph-reducer-unittest.cc [unittests] Convert to the new MOCK_METHOD macro. 2020-06-10 15:50:38 +00:00
graph-reducer-unittest.h [unittests] Convert to the new MOCK_METHOD macro. 2020-06-10 15:50:38 +00:00
graph-trimmer-unittest.cc [turbofan] Proper dead code elimination as regular reducer. 2015-06-19 12:07:26 +00:00
graph-unittest.cc [compiler] Don't serialize BytecodeArrayData's source_positions_ 2020-07-14 11:01:44 +00:00
graph-unittest.h [turbofan] introduce a deterministic tick measurement and assert optimization doesn't take too long 2019-07-17 07:00:00 +00:00
int64-lowering-unittest.cc Add bit left-rotation machine operator 2020-05-01 18:09:16 +00:00
js-call-reducer-unittest.cc [compiler] Make is_compiled_scope take an explicit Isolate 2020-07-06 15:49:55 +00:00
js-create-lowering-unittest.cc [objects] rename kSize to kHeaderSize for JSObject subclasses 2019-11-18 15:17:52 +00:00
js-intrinsic-lowering-unittest.cc [turbofan] Make broker own the is_concurrent_inlining flag 2020-01-22 15:21:55 +00:00
js-native-context-specialization-unittest.cc Move number related files to src/numbers 2019-05-15 19:34:44 +00:00
js-operator-unittest.cc [tests] Fix subobject-linkage error when building with GCC 2019-10-07 11:11:39 +00:00
js-typed-lowering-unittest.cc [nci] Add feedback input to remaining operators 2020-07-06 15:48:50 +00:00
linkage-tail-call-unittest.cc [zone] Cleanup zone allocations in src/compiler and tests, pt.3 2020-07-10 16:39:05 +00:00
load-elimination-unittest.cc Retire PretenureFlag and use AllocationType everywhere. 2019-03-12 08:10:44 +00:00
loop-peeling-unittest.cc [turbofan] introduce a deterministic tick measurement and assert optimization doesn't take too long 2019-07-17 07:00:00 +00:00
machine-operator-reducer-unittest.cc [torque] Generate better code when using & operator on bitfields 2020-05-22 21:59:06 +00:00
machine-operator-unittest.cc Reland "[compiler] Optionally apply an offset to stack checks" 2019-10-30 10:23:05 +00:00
node-cache-unittest.cc [turbofan] use ZoneUnorderedMap for NodeCache 2020-03-05 13:00:34 +00:00
node-matchers-unittest.cc [cleanup] Refactor compiler to use default members. 2018-09-17 12:12:21 +00:00
node-properties-unittest.cc [jumbo] add unittests jumbo support 2017-09-28 22:19:40 +00:00
node-test-utils.cc Reland "Reland "[turbofan][csa] optimize Smi untagging better"" 2020-04-29 07:30:11 +00:00
node-test-utils.h Reland "Reland "[turbofan][csa] optimize Smi untagging better"" 2020-04-29 07:30:11 +00:00
node-unittest.cc [cleanup] Replace simple typedefs by using 2019-05-27 12:39:49 +00:00
opcodes-unittest.cc [compiler] Refactor opcode macro lists 2020-06-23 07:54:14 +00:00
persistent-unittest.cc [ubsan] Fix numerical overflows in the compiler 2019-01-10 11:17:37 +00:00
redundancy-elimination-unittest.cc [compiler] Make is_compiled_scope take an explicit Isolate 2020-07-06 15:49:55 +00:00
schedule-unittest.cc [cleanup] Replace simple typedefs by using 2019-05-27 12:39:49 +00:00
scheduler-rpo-unittest.cc [cleanup] Refactor compiler to use default members. 2018-09-17 12:12:21 +00:00
scheduler-unittest.cc Profile-guided optimization of builtins 2020-07-22 17:12:23 +00:00
simplified-lowering-unittest.cc [turbofan] introduce a deterministic tick measurement and assert optimization doesn't take too long 2019-07-17 07:00:00 +00:00
simplified-operator-reducer-unittest.cc [compiler] Don't serialize BytecodeArrayData's source_positions_ 2020-07-14 11:01:44 +00:00
simplified-operator-unittest.cc [ptr-compr] Remove Compressed mentions from in the pipeline 2019-11-11 12:23:41 +00:00
state-values-utils-unittest.cc [compiler] Optimize AddInputsToFrameStateDescriptor 2020-03-05 11:45:15 +00:00
typed-optimization-unittest.cc [turbofan] introduce a deterministic tick measurement and assert optimization doesn't take too long 2019-07-17 07:00:00 +00:00
typer-unittest.cc [compiler] Don't serialize BytecodeArrayData's source_positions_ 2020-07-14 11:01:44 +00:00
value-numbering-reducer-unittest.cc [zone] Cleanup zone allocations in src/compiler and tests, pt.3 2020-07-10 16:39:05 +00:00
zone-stats-unittest.cc [zone] Cleanup zone allocations in src/compiler and tests, pt.3 2020-07-10 16:39:05 +00:00