Closed
Bug 636402
Opened 13 years ago
Closed 13 years ago
Simplify Sync.js to avoid creating new objects
Categories
(Firefox :: Sync, defect)
Firefox
Sync
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
fennec | 2.0+ | --- |
People
(Reporter: philikon, Assigned: philikon)
References
Details
(Whiteboard: [fixed in fx-sync][fixed in services][qa-])
Attachments
(1 file)
23.53 KB,
patch
|
rnewman
:
review+
|
Details | Diff | Splinter Review |
Sync.js can be much simpler and thus avoid creating as many objects as it does now for one invocation: * expose a function to create a callback, e.g. Sync.makeCallback() * expose a function to spin the event loop, e.g. Sync.waitForCallback() * no longer call the async function, leave that up to the caller (func.apply(this, arguments) creates allocates new objects!) * Sync.sleep() can be replaced by custom nsITimer based solutions. It's only used in SyncEngine._processIncoming anyway. That way we can also avoid creating nsITimer instances over and over. I have a patch in the works.
Assignee | ||
Comment 1•13 years ago
|
||
This does basically what's described in comment 0: * Sync() and Sync.withCb() are replaced by two helpers: a) Utils.makeSyncCallback() for creating the special callback b) Utils.waitForSyncCallback(cb) for spinning the event loop The observant reader may have noticed that this way we no longer wrap the async function in a closure but instead leave it up to the caller to explicitly call it and these two helpers. The idea here is to avoid accessing the 'arguments' object (which instantiates it... bad bad bad) * Utils.makeSyncCallback() also creates less objects by stashing the state and return value directly onto the callback. * Sync.sleep() is replaced with nsITimer based solutions on each engine. The benefit here is that we don't create a new nsITimer object on every single record (SyncEngine._processIncoming calls Sync.sleep(0) after each record.) * Lots of places unnecessary imported Sync.js. Removed. Baibai Sync.js (though the saga is far from over)
Attachment #515014 -
Flags: review?(rnewman)
Assignee | ||
Comment 2•13 years ago
|
||
In my test profile with initially 4.5M created objects, this cuts the number of created objects by ca. 0.5M. Should block Fennec big time.
tracking-fennec: --- → ?
Whiteboard: [has patch][needs review rnewman]
Updated•13 years ago
|
tracking-fennec: ? → 2.0+
Comment 3•13 years ago
|
||
This is the first thing in my queue after breakfast. Starting the day right!
Comment 4•13 years ago
|
||
Comment on attachment 515014 [details] [diff] [review] v1 Beautiful.
Attachment #515014 -
Flags: review?(rnewman) → review+
Comment 5•13 years ago
|
||
Thumbs up from local crossweave, btw.
Status: NEW → ASSIGNED
Whiteboard: [has patch][needs review rnewman] → [has patch][has review]
Assignee | ||
Comment 6•13 years ago
|
||
Landed in fx-sync: https://hg.mozilla.org/services/fx-sync/rev/1fbce35f48a4
Whiteboard: [has patch][has review] → [fixed in fx-sync]
Assignee | ||
Comment 7•13 years ago
|
||
Merged to s-c: http://hg.mozilla.org/services/services-central/rev/0d03339c1895
Whiteboard: [fixed in fx-sync] → [fixed in fx-sync][fixed in services]
Assignee | ||
Comment 8•13 years ago
|
||
Merged to m-c: http://hg.mozilla.org/mozilla-central/rev/0d03339c1895
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Updated•13 years ago
|
Whiteboard: [fixed in fx-sync][fixed in services] → [fixed in fx-sync][fixed in services][qa-]
Updated•6 years ago
|
Component: Firefox Sync: Backend → Sync
Product: Cloud Services → Firefox
You need to log in
before you can comment on or make changes to this bug.
Description
•