New issue
Advanced search Search tips

Issue 770405 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

-description method consumes 22ms on every call to -[BrowserCrApplication sendEvent:]

Project Member Reported by shrike@chromium.org, Sep 29 2017

Issue description

The Stack Sampler shows that the call to [event description] in -[BrowserCrApplication sendEvent:] (to build the crash key) takes 22ms. Is it possible to build the description by hand to avoid this overhead?

 
Is it really -description that's taking the time, or is it the setting of the crash key?
It's the -description method. That method calls -stringWithFormat: and -appendFormat: which in my experience are not very efficient.

Screen Shot 2017-10-02 at 12.21.34 PM.png
129 KB View Download
With https://chromium-review.googlesource.com/c/chromium/src/+/990155, some timings from typical events (mouse, key, kit-defined). The DescriptionForNSEvent() impl is more than 2x as fast.

 -[NSEvent description] = 8e-05 s
 DescriptionForNSEvent() = 2.3e-05 s
 -[NSEvent description] = 4.3e-05 s
 DescriptionForNSEvent() = 2e-05 s
 -[NSEvent description] = 4.4e-05 s
 DescriptionForNSEvent() = 2e-05 s
 -[NSEvent description] = 4.3e-05 s
 DescriptionForNSEvent() = 2.1e-05 s
 -[NSEvent description] = 5.5e-05 s
 DescriptionForNSEvent() = 1.9e-05 s
 -[NSEvent description] = 6.5e-05 s
 DescriptionForNSEvent() = 2.2e-05 s
 -[NSEvent description] = 5.8e-05 s
 DescriptionForNSEvent() = 2e-05 s
 -[NSEvent description] = 4.7e-05 s
 DescriptionForNSEvent() = 2.1e-05 s
 -[NSEvent description] = 4.2e-05 s
 DescriptionForNSEvent() = 2e-05 s
 -[NSEvent description] = 5.3e-05 s
 DescriptionForNSEvent() = 2e-05 s
 -[NSEvent description] = 0.000101 s
 DescriptionForNSEvent() = 2.2e-05 s
 -[NSEvent description] = 5.9e-05 s
 DescriptionForNSEvent() = 2e-05 s

(N.B. that was in a debug build, so release is probably faster)
Project Member

Comment 5 by bugdroid1@chromium.org, Apr 2 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/916a7194d0b74077d168417ef2ef2b77384bd5f4

commit 916a7194d0b74077d168417ef2ef2b77384bd5f4
Author: Robert Sesek <rsesek@chromium.org>
Date: Mon Apr 02 18:55:12 2018

[Mac] Speed up capturing the "nsevent" crash key.

Using -[NSEvent description] can be slow, so instead build a description
string manually. This contains just the information that is useful in
crash analysis, so it's faster.

Bug:  770405 
Change-Id: Ib4e0fd54daa0412f4f8c1e3d500d1f048f0940f8
Reviewed-on: https://chromium-review.googlesource.com/990155
Reviewed-by: Erik Chen <erikchen@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547476}
[modify] https://crrev.com/916a7194d0b74077d168417ef2ef2b77384bd5f4/chrome/browser/chrome_browser_application_mac.mm

Comment 6 by rsesek@chromium.org, Apr 10 2018

Labels: M-67
Status: Fixed (was: Assigned)
Looking at the sampling profiler now, the time spent in -sendEvent: has reduced by 
-0.276%. And formatting the crash key now ranks below the actual event handler.
67.0.3390.0.png
76.5 KB View Download
diff-67.0.3385.0-vs-67.0.3390.0.png
162 KB View Download

Sign in to add a comment