• Benedikt Meurer's avatar
    [debug] Decouple async event delegate instrumentation from PromiseHooks. · b46d5ffb
    Benedikt Meurer authored
    As described in https://crbug.com/1287476, the fact that the
    AsyncEventDelegate is currently implemented on top of the PromiseHooks
    causes performance problems and makes it difficult to reason about the
    exact (observed) semantics; this is because for this we intercept every
    JSPromise creation (via PromiseHook::kInit) and walk the synchronous
    stack at that point to see if we find one of Promise#then(),
    Promise#catch() or Promise#finally() on the stack. And if we do so, we
    report that to the AsyncEventDelegate (which is implemented in the
    inspector and will then do the async stack/stepping logic on top).
    
    This CL introduces dedicated instrumentation for Promise#then(), which
    is also called from Promise#catch() and Promise#finally(), and uses that
    instrumentation for the purpose of the AsyncEventDelegate. It also
    adjusts the stack walk to not always walk the full stack (which might
    lead to wrong results when calls to Promise#then(), which itself can
    call back into user JavaScript, are found deeper in the stack), but
    instead only check the top-most builtin frames and whatever user
    JavaScript frame is underneath it.
    
    On the standalone.js (from https://crbug.com/1287476#c1), when run with
    the DevTools default of maxDepth=200, we go from around 4.00ms to around
    0.36ms. For everything that does not call Promise#then() - either
    explicitly or implicitly - or `await`s, there's now no observable
    performance impact of turning on the AsyncEventDelegate.
    
    Bug: chromium:1280519
    Fixed: chromium:1287476
    Change-Id: I4911bed146381fc46cfeefb763d6dfc32e8f6071
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3386379
    Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
    Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
    Commit-Queue: Leszek Swirski <leszeks@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#78640}
    b46d5ffb
Name
Last commit
Last update
.github Loading commit data...
bazel Loading commit data...
build_overrides Loading commit data...
custom_deps Loading commit data...
docs Loading commit data...
gni Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.bazelrc Loading commit data...
.clang-format Loading commit data...
.clang-tidy Loading commit data...
.editorconfig Loading commit data...
.flake8 Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.mailmap Loading commit data...
.vpython Loading commit data...
.vpython3 Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.bazel Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
COMMON_OWNERS Loading commit data...
DEPS Loading commit data...
DIR_METADATA Loading commit data...
ENG_REVIEW_OWNERS Loading commit data...
INFRA_OWNERS Loading commit data...
INTL_OWNERS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LOONG_OWNERS Loading commit data...
MIPS_OWNERS Loading commit data...
OWNERS Loading commit data...
PPC_OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
RISCV_OWNERS Loading commit data...
S390_OWNERS Loading commit data...
WATCHLISTS Loading commit data...
WORKSPACE Loading commit data...
codereview.settings Loading commit data...