• Benedikt Meurer's avatar
    [stack-traces] Implement fast-path for JSFunction::GetDebugName(). · 6daff990
    Benedikt Meurer authored
    For stack traces, especially all stack traces exposed via the Inspector
    (i.e. for the purpose of async stack traces), JSFunction::GetDebugName()
    is still a bottleneck, even after the removal of "displayName" support.
    As outlined in https://bit.ly/devtools-function-displayName-removal a
    follow-up optimization here would be to improve the performance of the
    "name" lookup. Previously, it'd always use the LookupIterator combined
    with JSReceiver::GetDataProperty(), which in the common case would find
    the "name" property and the return undefined, since it doesn't invoke
    getters on AccessorInfos, and eventually fall through to the actual
    logic in SharedFunctionInfo::DebugName().
    
    Now we had a similar situation with Function.prototype.bind(), which
    also needs to lookup "name" on regular function objects quite often, and
    what we implemented there is to just look into the DescriptorArray of
    the incoming function object and see if the entry for the "name"
    descriptor is still untouched (key is "name" and value is an
    AccessorInfo), and if so completely bypass the slow-path lookup via the
    LookupIterator.
    
    With this CL (and the optimization in https://crrev.com/c/2695386), the
    cost of symbolization is now significantly lower than the cost of the
    actual stack trace capturing, for the async stack traces in the example
    from https://crbug.com/1077657 as indicated by the perf profile below:
    
    ```
    - 26.03% v8_inspector::AsyncStackTrace::capture
       + 17.34% v8::StackTrace::CurrentStackTrace
       - 7.27% v8_inspector::(anonymous namespace)::toFramesVector
          - 7.18% v8_inspector::V8Debugger::symbolize
             - 6.27% v8_inspector::StackFrame::StackFrame
                + 2.52% v8_inspector::toProtocolString
                + 1.88% v8::internal::StackFrameInfo::GetLineNumber
               0.78% operator new[]
         0.55% operator new[]
    ```
    
    Bug: chromium:1077657, v8:8742, chromium:1069425, chromium:1177685
    Change-Id: I38f23816295f4381f5109cc78e4856dc0b67b097
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2695593
    Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
    Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
    Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#72758}
    6daff990
Name
Last commit
Last update
.github 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...
.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...
.vpython Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS 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...
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...
codereview.settings Loading commit data...