debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[Frames] Simplify Redux call stacks

Open jasonLaster opened this issue 9 years ago • 13 comments

Here is a call stack from: perf.html running locally: link with a breakpoint in profile-view.js:97 I think there are a couple of things we could do to simplify it:

  1. group frames 2 - 9: action dispatch
  2. group frames 11 - 13: action dispatch
  3. group frames 14 - 21: resolve promise

In terms of algorithms:

  1. group frames that match redux or thread-middleware.
  2. group frames that match regenerator-runtime, core-js, or babel
  3. label frame groups action dispatch if you see combineReducers or createStore
  4. label frame groups resolve promise if you see es6.promise in the group

Curious to see what others with more knowledge think.

Call Stack

1 - webpack:///src/content/reducers/profile-view.js
2 - webpack:///~/redux/es/combineReducers.js
3 - webpack:///~/redux/es/combineReducers.js
4 - webpack:///~/redux/es/combineReducers.js
5 - webpack:///~/redux/es/createStore.js
6 - webpack:///~/redux-logger/lib/index.js
7 - webpack:///src/common/thread-middleware.js
8 - webpack:///~/redux-thunk/lib/index.js
9 - webpack:///~/redux/es/applyMiddleware.js
10 - webpack:///src/content/actions/receive-profile.js
11 - webpack:///~/redux-thunk/lib/index.js
12 - webpack:///~/redux/es/applyMiddleware.js
13 - webpack:///src/content/actions/receive-profile.js
14 - webpack:///~/regenerator-runtime/runtime.js
15 - webpack:///~/regenerator-runtime/runtime.js
16 - webpack:///~/regenerator-runtime/runtime.js
17 - webpack:///~/babel-runtime/helpers/asyncToGenerator.js
18 - webpack:///~/babel-runtime/helpers/asyncToGenerator.js
19 - webpack:///~/core-js/library/modules/es6.promise.js
20 - webpack:///~/core-js/library/modules/es6.promise.js
21 - webpack:///~/core-js/library/modules/_microtask.js

Screenshot

Steps to get started

  1. go to https://github.com/devtools-html/perf.html/
  2. git clone, npm install, npm start
  3. add a breakpoint in reducers/profile-view.js

jasonLaster avatar Jul 19 '17 18:07 jasonLaster

I'm not sure where _callee7$ is specifically coming from, somewhere in the thunk. It would be nice to have a clear stack showing receiveProfileFromAddon with the Redux pseudo stacks in there. The general principle would be nice to only show me what I really care about.

gregtatum avatar Jul 19 '17 18:07 gregtatum

hmm - i know what you're saying. I bet we can do something with function names and babel... Like go up and get the real name...

jasonLaster avatar Jul 19 '17 19:07 jasonLaster

/claim

ahuth avatar Nov 01 '17 14:11 ahuth

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Nov 01 '17 14:11 claim

/unclaim

ahuth avatar Nov 13 '17 18:11 ahuth

Done :+1:

claim avatar Nov 13 '17 18:11 claim

Here are two use cases

go to localhost:8000 select a tab and add breakpoints at reducers/ast.js#83 (set_symbols) and actions/ast.js#47 (setSymbols).

In both cases we have redux dispatch frames that can be grouped with this algorithm: group everything ending in dispatch w/ applyMiddleware and beginning with combination, thunk, or dispatch

Reducer Action
![red] ![act]
[act]:https://shipusercontent.com/6f1907e5efe2e216fe64f68622a6dfdd/Screen%20Shot%202018-03-27%20at%2010.05.20%20AM.png
[red]:https://shipusercontent.com/1a887ecd5d626dc6620c2f44660818f7/Screen%20Shot%202018-03-27%20at%2010.06.46%20AM.png

Here's an example:

Original

update (ast.js#83)
combination (combineReducers.js#120)
dispatch (createStore.js#165)
timing (timing.js#25)
waitUntilService (wait-service.js#62)
promiseMiddleware (promise.js#28)
thunk (thunk.js#25)
dispatch (applyMiddleware.js#35)
promiseMiddleware (promise.js#38)
thunk (thunk.js#25)
dispatch (applyMiddleware.js#35)
setSymbols (ast.js#57)
thunk (thunk.js#24)
dispatch (applyMiddleware.js#35)
selectLocation (select.js#137)

Groups

update (ast.js#83)
dispatch (10)       Redux
  combination (combineReducers.js#120)
  dispatch (createStore.js#165)
  timing (timing.js#25)
  waitUntilService (wait-service.js#62)
  promiseMiddleware (promise.js#28)
  thunk (thunk.js#25)
  dispatch (applyMiddleware.js#35)
  promiseMiddleware (promise.js#38)
  thunk (thunk.js#25)
  dispatch (applyMiddleware.js#35)
setSymbols (ast.js#57)
dispatch (2)      Redux
  thunk (thunk.js#24)
  dispatch (applyMiddleware.js#35)
selectLocation (select.js#137)

jasonLaster avatar Mar 27 '18 14:03 jasonLaster

/claim

iocalebs avatar Mar 27 '18 14:03 iocalebs

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Mar 27 '18 14:03 claim

I had a Jest test written up in this branch but I'm no longer sure how to go about this. How would we distinguish a regular app frame (e.g. setSymbols (ast.js#57) from custom middleware (e.g. promiseMiddleware?

iocalebs avatar Apr 05 '18 21:04 iocalebs

hmm, can you share an example stack?

jasonLaster avatar Apr 05 '18 22:04 jasonLaster

For sure! Take the one you gave above. Here's the Jest test case for it.

Lemme rephrase what I've been saying: It would be super easy to make the above test pass. The hard thing is doing it in a way that would make it scale to other use cases in projects other than our own. Actually... that got me thinking: maybe we just have the wrong test case... Or I'm looking at something the wrong way.

iocalebs avatar Apr 06 '18 13:04 iocalebs

I'm closing this issue and moving it to the icebox, because this is something I do not think we will bet to this quarter. We will review the icebox queue in the next quarter and possibly add it to the roadmap.

jasonLaster avatar Dec 20 '18 16:12 jasonLaster