Skip to content

Improve the debugger script cache#1958

Merged
devoncarew merged 3 commits intoflutter:masterfrom
devoncarew:improve_script_cache
May 14, 2020
Merged

Improve the debugger script cache#1958
devoncarew merged 3 commits intoflutter:masterfrom
devoncarew:improve_script_cache

Conversation

@devoncarew
Copy link
Copy Markdown
Contributor

@devoncarew devoncarew commented May 13, 2020

  • improve the debugger script cache; add entries to the cache for script requests that are in progress, as well as ones that we've already retreived
  • move the cache into its own class (ScriptCache) instead of using a map in the DebuggerController class, now that the cache has gotten more complicated
  • optimize frame display when we pause; we now use the pauseEvent.topFrame field, and display the pause immediately, while asynchronously populating the information about the other frames in the background. This will likely reduce the stepping latency a bit when debugging dart web apps (its currently expensive for package:dwds calculate the frame info)

Previously, when the script cache was empty, we were sending n requests for scripts when we paused, where n was the number of frames. I.e., the cache didn't handle multiple frames that referenced the same script, where that script was not yet populated in the cache. This issue was found using the new logging code in package:dwds - dart-lang/webdev#1011.

Copy link
Copy Markdown
Member

@kenzieschmoll kenzieschmoll left a comment

Choose a reason for hiding this comment

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

LGTM with a couple nits

}

Future<void> _pause(bool pause) async {
_isPaused.value = pause;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is there a reason setting the notifier was moved inside of the if and else statements respectively? Not a huge deal, but it turns what can be written as one line of code into 2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No really; this made it slightly more clear what the two branches do, but I don't think it's critical to do it this way.

if (_scripts[scriptRef.id] == null) {
_scripts[scriptRef.id] = scriptRef;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: not your fault, but I don't think these new lines add much value. Let's remove them to make this method more dense

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, thinking about this, it's not likely that we'll have gotten a Script object without having already gone through this caching code; removed.

@devoncarew
Copy link
Copy Markdown
Contributor Author

cc @grouma for FYI that we're now taking advantage of responsiveness improvements of pausing faster w/ just using the topFrame info.

@devoncarew devoncarew merged commit ab7f0b0 into flutter:master May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants