Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Throttle new sources #4749

Merged
merged 3 commits into from
Nov 29, 2017
Merged

Conversation

jasonLaster
Copy link
Contributor

@jasonLaster jasonLaster commented Nov 20, 2017

Associated Issue: #4705

Summary of Changes

This throttles the firefox newSource event so that we fire at most one newSources action every 50ms.

  • Not sure if we need a test
  • Not sure if we want to debounce in the event or the actions. Events seem easier now

The performance savings is significant ⏲

No throttling, w/o the editor fix

~ 9 seconds. Lots of thrashing here :P

screen shot 2017-11-20 at 11 44 04 am

Throttling w/o the editor fix

3 seconds. The editor update holds up the main thread so we also do more newSources calls :) vicious cycle

screen shot 2017-11-20 at 11 47 12 am

Throttling w/ the editor fix

1.5 sec

screen shot 2017-11-20 at 11 48 40 am

Copy link
Contributor

@codehag codehag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really good work. i tried it out, quite an impressive improvement

let urls = null;
try {
urls = await sourceMaps.getOriginalURLs(generatedSource);
} catch (e) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be in its own PR probably. It can throw, and that breaks things

for (const source of filteredSources) {
await dispatch(newSource(source));
await dispatch(loadSourceMap(source));
Copy link
Contributor

@codehag codehag Nov 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can send the promises all at once using Promise.all? especially with the queue work. and if we move to sagas we can use forks

@codehag
Copy link
Contributor

codehag commented Nov 24, 2017

damp benchmark:

test result averages for 11dc3161e3e39159e9fa2520b76f5a5d0a0783b8:
    simple.jsdebugger.open.DAMP: 1719.7275000000045ms
    simple.jsdebugger.reload.DAMP: 409.27750000000015ms
    simple.jsdebugger.close.DAMP: 127.70750000000044ms
    complicated.jsdebugger.open.DAMP: 2556.3025000000016ms
    complicated.jsdebugger.reload.DAMP: 1324.5275000000038ms
    complicated.jsdebugger.close.DAMP: 4235.457499999997ms

test result averages for f59026d3d047fbbb984580ea2d01a9bc5cb11553:
    simple.jsdebugger.open.DAMP: 1530.5324999999975ms
    simple.jsdebugger.reload.DAMP: 361.75750000000335ms
    simple.jsdebugger.close.DAMP: 135.4349999999995ms
    complicated.jsdebugger.open.DAMP: 2409.629999999999ms
    complicated.jsdebugger.reload.DAMP: 1293.0750000000007ms
    complicated.jsdebugger.close.DAMP: 4672.5625ms

difference between 11dc3161e3e39159e9fa2520b76f5a5d0a0783b8 and  f59026d3d047fbbb984580ea2d01a9bc5cb11553:
    simple.jsdebugger.open.DAMP: -11.6418% difference
    simple.jsdebugger.reload.DAMP: -12.3263% difference
    simple.jsdebugger.close.DAMP: +5.87324% difference
    complicated.jsdebugger.open.DAMP: -5.90715% difference
    complicated.jsdebugger.reload.DAMP: -2.40315% difference
    complicated.jsdebugger.close.DAMP: +9.81374% difference

my computer was struggling a bit so some of the values are higher than normal

for (const source of filteredSources) {
await dispatch(newSource(source));
await dispatch(loadSourceMap(source));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I tried to break this work up a bit so that we can land it piecemeal. This logic will be touched in another PR

@jasonLaster
Copy link
Contributor Author

Just checked CI: two mochitests, and one lint error. This should be pretty close :)

@jasonLaster
Copy link
Contributor Author

browser_dbg-breakpoints-cond
browser_dbg-breaking

@jasonLaster
Copy link
Contributor Author

looks like it's failing because we're not selecting the source or waiting for the source to be selected..

diff --git a/src/actions/pause/paused.js b/src/actions/pause/paused.js
index c4c8b4e..7a29545 100644
--- a/src/actions/pause/paused.js
+++ b/src/actions/pause/paused.js
@@ -51,6 +51,7 @@ export function paused(pauseInfo: Pause) {
     }
 
     const { line, column } = frame.location;
+    debugger;
     await dispatch(
       selectSource(frame.location.sourceId, { location: { line, column } })
     );
diff --git a/src/actions/sources.js b/src/actions/sources.js
index ddb437b..44f656a 100644
--- a/src/actions/sources.js
+++ b/src/actions/sources.js
@@ -66,6 +66,12 @@ async function checkPendingBreakpoints(state, dispatch, sourceId) {
 
   // load the source text if there is a pending breakpoint for it
   await dispatch(loadSourceText(source));

 }
 
diff --git a/src/test/mochitest/browser_dbg-breaking.js b/src/test/mochitest/browser_dbg-breaking.js
index a4fdfa7..61263ee 100644
--- a/src/test/mochitest/browser_dbg-breaking.js
+++ b/src/test/mochitest/browser_dbg-breaking.js
@@ -13,7 +13,9 @@ add_task(async function() {
   reload(dbg);
   await waitForPaused(dbg);
 
-  await waitForLoadedSource(dbg, "doc-scripts.html");
+  await waitForSelectedSource(dbg, "doc-scripts.html");
+  debugger
+  // await waitForever()
   assertPausedLocation(dbg);
   await resume(dbg);
 

@jasonLaster
Copy link
Contributor Author

Got this working on the plane, turned out we had a sneaky timing w/ pause and sources. Now that we're throttling the newSources action, we need to flush it before firing the pause action.

There were also some small nits in there too. Should be ready to go!

Copy link
Contributor

@codehag codehag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks!

@codehag codehag merged commit a197a1e into firefox-devtools:master Nov 29, 2017
AnshulMalik pushed a commit to AnshulMalik/debugger.html that referenced this pull request Dec 2, 2017
* Throttle new source

* fixes

* fix lint error
jasonLaster added a commit to jasonLaster/debugger.html that referenced this pull request Dec 4, 2017
* Throttle new source

* fixes

* fix lint error
codehag added a commit to codehag/debugger.html that referenced this pull request Dec 13, 2017
jasonLaster pushed a commit to jasonLaster/debugger.html that referenced this pull request Dec 18, 2017
This reverts commit a197a1e.

# Conflicts:
#	src/actions/sources.js
codehag added a commit to codehag/debugger.html that referenced this pull request Dec 18, 2017
jasonLaster added a commit that referenced this pull request Dec 18, 2017
codehag added a commit to codehag/debugger.html that referenced this pull request Dec 19, 2017
codehag added a commit to codehag/debugger.html that referenced this pull request Dec 19, 2017
jasonLaster added a commit to jasonLaster/debugger.html that referenced this pull request Dec 21, 2017
…ls#4947)

This reverts commit a197a1e.

# Conflicts:
#	src/actions/sources.js
jasonLaster added a commit to jasonLaster/debugger.html that referenced this pull request Dec 21, 2017
nchevobbe pushed a commit to nchevobbe/debugger.html that referenced this pull request Dec 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants