Closed
Bug 1425577
Opened 8 years ago
Closed 8 years ago
Do not create a new state for every message in a MESSAGES_ADD batch
Categories
(DevTools :: Console, enhancement, P1)
DevTools
Console
Tracking
(firefox59 wontfix, firefox60 fixed)
RESOLVED
FIXED
Firefox 60
People
(Reporter: nchevobbe, Assigned: nchevobbe)
References
(Blocks 1 open bug)
Details
(Whiteboard: [newconsole-mvp])
Attachments
(1 file, 7 obsolete files)
At the moment, we clone the state for each addMessage call, which is call by the MESSAGES_ADD action.
This is pointless since we have batching, and we should only clone the state once, and add all the message of the batch to it.
Assignee | ||
Updated•8 years ago
|
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Priority: P2 → P1
Assignee | ||
Comment 1•8 years ago
|
||
Okay, so I have a patch which I'll put up for review after this comment.
It adds a bit of complexity, and there was no improvement on DAMP.
However, I do have a case where we can see nice benefits.
So here is the test case :
```js
let i = 0;
function streamLogs() {
console.log(i++);
if (i < 500) {
requestAnimationFrame(streamLogs)
}
}
streamLogs();
```
in short, streaming logs (i.e. adding lots of messages in a short timespan).
Here's the profile without the patch :
- https://perfht.ml/2B82mUg
- 4% (366ms of 7756ms) of the total time is spent on the messages reducer
Here's the profile with the patch:
- https://perfht.ml/2B3VUNL
- 1% (125ms of 6966ms) of the total time is spent on the reducer.
So here, we are almost 3 times faster on reducer time.
The thing that we need to discuss is: is the added complexity to the code worth the gain ?
The overall gain is not stunning, but we do know that we don't spend most of the time in reducer. Still, this shaves off hundred ms on a high end laptop (so probably more on low end devices).
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 4•8 years ago
|
||
mozreview-review |
Comment on attachment 8942892 [details]
Bug 1425577 - Remove MESSAGE_ADD action;.
https://reviewboard.mozilla.org/r/213164/#review218976
Attachment #8942892 -
Flags: review?(bgrinstead) → review+
Comment 5•8 years ago
|
||
mozreview-review |
Comment on attachment 8942893 [details]
Bug 1425577 - Do not create a new state for each message of a batch;.
https://reviewboard.mozilla.org/r/213166/#review218980
Is there any way you could split this up so that the parts that aren't changing the behavior are in a separate changeset (i.e. test changes that pass without the rest of the patch, addMessages function, etc)? I think that would make it easier to review, but if that's going to be a pain or the parts can't effectively be split up then let me know and I'll go through it as-is.
::: devtools/client/webconsole/new-console-output/reducers/messages.js:60
(Diff revision 1)
> - // Map of the form {messageId : networkInformation}
> + // Map of the form {messageId : networkInformation}
> - // `networkInformation` holds request, response, totalTime, ...
> + // `networkInformation` holds request, response, totalTime, ...
> - networkMessagesUpdateById: {},
> + networkMessagesUpdateById: {},
> -}, overrides));
> + }, overrides);
>
> -function addMessage(state, filtersState, prefsState, newMessage) {
> + const wrap = freeze === true ? Object.freeze : (x) => x;
Nit: the `wrap` function makes it slightly more difficult for me to follow and adds an extra function call for the non freeze state. Something like `return (freeze === true) ? Object.freeze(state) : state;` (or the same but out of a ternary if you prefer) would help.
Attachment #8942893 -
Flags: review?(bgrinstead)
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 14•8 years ago
|
||
mozreview-review |
Comment on attachment 8943234 [details]
Bug 1425577 - Fix typo;.
https://reviewboard.mozilla.org/r/213492/#review219356
::: commit-message-7024c:4
(Diff revision 1)
> +Bug 1425577 - Fix typo;r=bgrins.
> +
> +currentGoup -> currentGroup.
> +The typo was in the function parameter so we did not had bug
Nit: 'not have a bug because of it'
Attachment #8943234 -
Flags: review?(bgrinstead) → review+
Comment 15•8 years ago
|
||
mozreview-review |
Comment on attachment 8943231 [details]
Bug 1425577 - Fix and enhance console mocha store tests; .
https://reviewboard.mozilla.org/r/213486/#review219374
Attachment #8943231 -
Flags: review?(bgrinstead) → review+
Assignee | ||
Updated•8 years ago
|
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Updated•8 years ago
|
Attachment #8942892 -
Attachment is obsolete: true
Assignee | ||
Updated•8 years ago
|
Attachment #8943231 -
Attachment is obsolete: true
Assignee | ||
Updated•8 years ago
|
Attachment #8943234 -
Attachment is obsolete: true
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 26•8 years ago
|
||
FYI, DAMP reports some wins on panelsInBackground. In this test, we call console.log while the webconsole is in background. React updates are paused, but not redux actions. So it quite well highlights your win here and ensure we will not regress it.
https://treeherder.mozilla.org/perf.html#/comparesubtest?originalProject=try&originalRevision=9f498fc6a1eaa0b77c61a947edd5d88eee2d5bc2&newProject=try&newRevision=e7cf09086077c91d40fb6ae3948184bde879da6d&originalSignature=edaec66500db21d37602c99daa61ac983f21a6ac&newSignature=edaec66500db21d37602c99daa61ac983f21a6ac&showOnlyConfident=1&framework=1
complicated.reload -2.8%
panelsInBackground.reload -10%
+ various other smaller win with medium confidence.
Comment hidden (mozreview-request) |
Assignee | ||
Updated•8 years ago
|
Attachment #8943233 -
Attachment is obsolete: true
Attachment #8943233 -
Flags: review?(bgrinstead)
Assignee | ||
Updated•8 years ago
|
Attachment #8943235 -
Attachment is obsolete: true
Attachment #8943235 -
Flags: review?(bgrinstead)
Assignee | ||
Updated•8 years ago
|
Attachment #8942893 -
Attachment is obsolete: true
Attachment #8942893 -
Flags: review?(bgrinstead)
Assignee | ||
Updated•8 years ago
|
Attachment #8943236 -
Attachment is obsolete: true
Attachment #8943236 -
Flags: review?(bgrinstead)
Assignee | ||
Comment 28•8 years ago
|
||
Brian, I changed things a bit in the last patch, and I think this looks much better.
What we do now is that we clone the state before adding the new messages, and then mutate the cloned state in the addMessage function.
Comment 29•8 years ago
|
||
mozreview-review |
Comment on attachment 8943232 [details]
Bug 1425577 - Do not clone the state for each message of a batch; .
https://reviewboard.mozilla.org/r/213488/#review220904
Nice!
::: devtools/client/webconsole/new-console-output/reducers/messages.js:135
(Diff revision 4)
> - } = getMessageVisibility(addedMessage, newState, filtersState);
> + } = getMessageVisibility(addedMessage, state, filtersState);
>
> if (visible) {
> - newState.visibleMessages = [...visibleMessages, newMessage.id];
> + state.visibleMessages.push(newMessage.id);
> } else if (DEFAULT_FILTERS.includes(cause)) {
> - newState.filteredMessagesCount = {
> + state.filteredMessagesCount = {
Nit: I believe this could be done without cloning filteredMessagesCount again - i.e. you could do something like:
```
state.filteredMessagesCount.global++; state.filteredMessages[cause]++;
```
Attachment #8943232 -
Flags: review?(bgrinstead) → review+
Comment hidden (mozreview-request) |
Comment 31•8 years ago
|
||
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9a6d7da2f9b1
Do not clone the state for each message of a batch; r=bgrins.
Comment 32•8 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox60:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
Comment 33•8 years ago
|
||
This patch improved by 28% the impact of the console when it is in background!
http://firefox-dev.tools/performance-dashboard/perfherder/?test=panelsInBackground.reload&days=7&filterstddev=true
Updated•8 years ago
|
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•