Bug 1513095 - Improve performance when loading breakpoints on pages with many scripts r=loganfsmyth
authorwartmanm <mattheww@skyward.com>
Thu, 10 Jan 2019 17:50:52 +0000
changeset 510416 957cc2dce89c9c93265bb24445792eb46fc24d4e
parent 510415 daf05866f9ddcd5a362b4d436477f3e01abd4234
child 510417 5841878be567b96228df063484120faaac21c76b
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1513095
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1513095 - Improve performance when loading breakpoints on pages with many scripts r=loganfsmyth Only attempt to add breakpoints for the current source in Thread._addSource(), reducing the number of costly Debugger::findScripts() calls made when loading a page. In addition, speed up findScripts() itself by moving the cheaper URL/source checks in commonFilter() ahead of the line number checks. Differential Revision: https://phabricator.services.mozilla.com/D15534
devtools/server/actors/thread.js
js/src/vm/Debugger.cpp
--- a/devtools/server/actors/thread.js
+++ b/devtools/server/actors/thread.js
@@ -1934,17 +1934,21 @@ const ThreadActor = ActorClassWithSpec(t
       if (!this.dbg.replaying) {
         return false;
       }
       sourceActor = this.sources.getSourceActor(source);
     } else {
       sourceActor = this.sources.createSourceActor(source);
     }
 
-    const bpActors = [...this.breakpointActorMap.findActors()];
+    const bpActors = [...this.breakpointActorMap.findActors()]
+    .filter((actor) => {
+      const bpSource = actor.generatedLocation.generatedSourceActor;
+      return bpSource.source ? bpSource.source === source : bpSource.url === source.url;
+    });
 
     // Bug 1225160: If addSource is called in response to a new script
     // notification, and this notification was triggered by loading a JSM from
     // chrome code, calling unsafeSynchronize could cause a debuggee timer to
     // fire. If this causes the JSM to be loaded a second time, the browser
     // will crash, because loading JSMS is not reentrant, and the first load
     // has not completed yet.
     //
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -4789,25 +4789,25 @@ class MOZ_STACK_CLASS Debugger::ScriptQu
   void consider(JSScript* script, const JS::AutoRequireNoGC& nogc) {
     if (oom || script->selfHosted()) {
       return;
     }
     Realm* realm = script->realm();
     if (!realms.has(realm)) {
       return;
     }
+    if (!commonFilter(script, nogc)) {
+      return;
+    }
     if (hasLine) {
       if (line < script->lineno() ||
           script->lineno() + GetScriptLineExtent(script) < line) {
         return;
       }
     }
-    if (!commonFilter(script, nogc)) {
-      return;
-    }
 
     if (innermost) {
       // For 'innermost' queries, we don't place scripts in
       // |scriptVector| right away; we may later find another script that
       // is nested inside this one. Instead, we record the innermost
       // script we've found so far for each realm in innermostForRealm,
       // and only populate |scriptVector| at the bottom of findScripts,
       // when we've traversed all the scripts.