Closed
Bug 1454792
Opened 5 years ago
Closed 5 years ago
protocol.js duplicates all arrays in identityWrite function
Categories
(DevTools :: Framework, enhancement)
DevTools
Framework
Tracking
(firefox61 fixed)
RESOLVED
FIXED
Firefox 61
Tracking | Status | |
---|---|---|
firefox61 | --- | fixed |
People
(Reporter: ochameau, Assigned: ochameau)
References
(Blocks 1 open bug)
Details
(Whiteboard: dt-fission)
Attachments
(3 files)
All arrays of primitives are currently duplicated if present in request or response. That because of `identifyWrite` method here, tries to convert iterators into arrays: https://searchfox.org/mozilla-central/rev/a30a60eadcff99d2a043241955d215dbeccad876/devtools/shared/protocol.js#111 // This has to handle iterator->array conversion because arrays of // primitive types pass through here. if (v && typeof (v) === "object" && Symbol.iterator in v) { return [...v]; } The issue is that Symbol.iterator is also present in arrays...
Assignee | ||
Updated•5 years ago
|
Assignee: nobody → poirot.alex
Assignee | ||
Comment 1•5 years ago
|
||
This patch doesn't trigger any improvement in existing DAMP tests, but we can see a small win in the benchmark I'm trying to write in bug 1454580: https://treeherder.mozilla.org/perf.html#/comparesubtest?originalProject=try&originalRevision=2e9629b25d9638a07581960f5e04e997f2d93f01&newProject=try&newRevision=e7ca143ede7848eba786a38f6b7671e4e64c096a&originalSignature=f79b6a4f1f8f53326d3056f6c8008c0ff4de0a94&newSignature=f79b6a4f1f8f53326d3056f6c8008c0ff4de0a94&showOnlyConfident=1&framework=1
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 4•5 years ago
|
||
Comment on attachment 8968679 [details] Bug 1454792 - Use arrow functions instead of bind in protocol.js. Would you mind bundling this another cleanup in this bug? This one doesn't report any improvement on DAMP, but I saw frames related to the writeError's bind in the profiler. Now, I hope that arrow functions aren't slower than bind?! (at least DAMP doesn't report a significant increase!)
Comment hidden (mozreview-request) |
Assignee | ||
Comment 6•5 years ago
|
||
Comment on attachment 8968681 [details] Bug 1454792 - Prevent duplicating arrays in Array type's read/write methods. Last patch for this bug. This time, very similar to the first one, but for arrays of non-primitive types. No particular report from DAMP as the benchmark test doesn't involve such arrays (it probably should)
Summary: protocol.js dupliates all arrays in identityWrite function → protocol.js duplicates all arrays in identityWrite function
Comment 7•5 years ago
|
||
mozreview-review |
Comment on attachment 8968677 [details] Bug 1454792 - Stop duplicating arrays in protocol.js's identifyWrite function. https://reviewboard.mozilla.org/r/237348/#review243174 Good catch! :) ::: devtools/shared/protocol.js:130 (Diff revision 1) > if (v === undefined) { > throw Error("undefined passed where a value is required"); > } > // This has to handle iterator->array conversion because arrays of > // primitive types pass through here. > - if (v && typeof (v) === "object" && Symbol.iterator in v) { > + if (v && typeof v === "object" && Symbol.iterator in v && !("length" in v)) { Could we use `!Array.isArray(v)`?
Attachment #8968677 -
Flags: review?(jryans) → review+
Comment 8•5 years ago
|
||
mozreview-review |
Comment on attachment 8968679 [details] Bug 1454792 - Use arrow functions instead of bind in protocol.js. https://reviewboard.mozilla.org/r/237350/#review243176
Attachment #8968679 -
Flags: review?(jryans) → review+
Comment 9•5 years ago
|
||
mozreview-review |
Comment on attachment 8968681 [details] Bug 1454792 - Prevent duplicating arrays in Array type's read/write methods. https://reviewboard.mozilla.org/r/237356/#review243178 ::: devtools/shared/protocol.js:219 (Diff revision 1) > return types.addType(name); > } > return types.addType(name, { > category: "array", > - read: (v, ctx) => [...v].map(i => subtype.read(i, ctx)), > - write: (v, ctx) => [...v].map(i => subtype.write(i, ctx)) > + read: (v, ctx) => { > + if (v && typeof v === "object" && Symbol.iterator in v && !("length" in v)) { Could this condition move to a function shared with `identifyWrite`? Also, as with that location, what about `!Array.isArray(v)`?
Attachment #8968681 -
Flags: review?(jryans) → review+
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 13•5 years ago
|
||
(In reply to J. Ryan Stinnett [:jryans] (use ni?) from comment #9) > Comment on attachment 8968681 [details] > Bug 1454792 - Prevent duplicating arrays in Array type's read/write methods. > > https://reviewboard.mozilla.org/r/237356/#review243178 > > ::: devtools/shared/protocol.js:219 > (Diff revision 1) > > return types.addType(name); > > } > > return types.addType(name, { > > category: "array", > > - read: (v, ctx) => [...v].map(i => subtype.read(i, ctx)), > > - write: (v, ctx) => [...v].map(i => subtype.write(i, ctx)) > > + read: (v, ctx) => { > > + if (v && typeof v === "object" && Symbol.iterator in v && !("length" in v)) { > > Could this condition move to a function shared with `identifyWrite`? Done => isIterator helper function. > Also, as with that location, what about `!Array.isArray(v)`? Yes, I imagine I was looking for something cheap, but DAMP reports no difference between the two versions, so I switched to Array.isArray.
Comment 14•5 years ago
|
||
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/84aa9286a031 Stop duplicating arrays in protocol.js's identifyWrite function. r=jryans https://hg.mozilla.org/integration/autoland/rev/88b340fcdc65 Use arrow functions instead of bind in protocol.js. r=jryans https://hg.mozilla.org/integration/autoland/rev/dd66dac690ad Prevent duplicating arrays in Array type's read/write methods. r=jryans
Comment 15•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/84aa9286a031 https://hg.mozilla.org/mozilla-central/rev/88b340fcdc65 https://hg.mozilla.org/mozilla-central/rev/dd66dac690ad
Status: NEW → RESOLVED
Closed: 5 years ago
status-firefox61:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 61
Updated•5 years ago
|
Product: Firefox → DevTools
Assignee | ||
Updated•5 years ago
|
Whiteboard: dt-fission
You need to log in
before you can comment on or make changes to this bug.
Description
•