Closed
Bug 863285
Opened 12 years ago
Closed 12 years ago
Cache the result of Ci.nsIMemory.isLowMemoryPlatform()
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 23
People
(Reporter: tetsuharu, Assigned: tetsuharu)
Details
Attachments
(1 file, 1 obsolete file)
2.66 KB,
patch
|
kats
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•12 years ago
|
||
This patch lazy loads Ci.nsIMemory as |Memory| in browser.js. But this name is very common. I seem we should name it |MemorySvc| or other good name. How do you think about it?
Attachment #739087 -
Flags: review?(margaret.leibovic)
Assignee | ||
Comment 2•12 years ago
|
||
And, Can we cache the result value of Ci.nsIMemory.isLowMemoryPlatform()? It may be risky. However, from nsIMemory.idl (http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIMemory.idl#102), this method will return the same value over the lifetime of the process. If we cache the value, we reduce its function call in the "pageshow" event handler and the initializing tabs.
Comment 3•12 years ago
|
||
(In reply to Tetsuharu OHZEKI [:saneyuki_s] from comment #2)
> And, Can we cache the result value of Ci.nsIMemory.isLowMemoryPlatform()? It
> may be risky. However, from nsIMemory.idl
> (http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIMemory.idl#102),
> this method will return the same value over the lifetime of the process. If
> we cache the value, we reduce its function call in the "pageshow" event
> handler and the initializing tabs.
This is a good thought, but the implementation already caches the value in a static. We do not read the proc file on each call:
http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsMemoryImpl.cpp#65
Comment 4•12 years ago
|
||
I also don't see the point of lazy-loading nsIMemory, because that code gets run unconditionally on startup anyway. With the other lazy-loading pieces, it is either potentially not run at all, or at least deferred from running on startup.
Assignee | ||
Comment 5•12 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #4)
> I also don't see the point of lazy-loading nsIMemory, because that code gets
> run unconditionally on startup anyway. With the other lazy-loading pieces,
> it is either potentially not run at all, or at least deferred from running
> on startup.
But the current code calls |CC[].getService()| unconditionally for each times firing "pageshow" events and initializing tabs. This is very inefficient...
I think lazy-loading is better than defining simply variable in this case. Or how about adding Ci.nsIMemory to Services.jsm?
Comment 6•12 years ago
|
||
Ah, in that case it might be better to just call isLowMemoryPlatform once at the beginning and cache that result. Then there's no need for the lazy loading code at all.
Assignee | ||
Comment 7•12 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #6)
> Ah, in that case it might be better to just call isLowMemoryPlatform once at
> the beginning and cache that result. Then there's no need for the lazy
> loading code at all.
Oh, I see. I'll re-make the patch like so it.
Assignee | ||
Comment 8•12 years ago
|
||
Attachment #739087 -
Attachment is obsolete: true
Attachment #739087 -
Flags: review?(margaret.leibovic)
Attachment #739642 -
Flags: review?(bugmail.mozilla)
Assignee | ||
Updated•12 years ago
|
Summary: Lazy load Ci.nsIMemory in browser.js → Cache the result of Ci.nsIMemory.isLowMemoryPlatform()
Comment 9•12 years ago
|
||
Comment on attachment 739642 [details] [diff] [review]
patch v2
Review of attachment 739642 [details] [diff] [review]:
-----------------------------------------------------------------
This works, thanks. Did you by any chance measure what sort of impact this has?
Attachment #739642 -
Flags: review?(bugmail.mozilla) → review+
Assignee | ||
Comment 10•12 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #9)
> This works, thanks. Did you by any chance measure what sort of impact this
> has?
No, I haven't yet. I pushed try-server just now: https://tbpl.mozilla.org/?tree=Try&rev=793379b9a8c6
Assignee | ||
Comment 11•12 years ago
|
||
Try was green: https://tbpl.mozilla.org/?tree=Try&rev=793379b9a8c6
Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Comment 12•12 years ago
|
||
Comment 13•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 23
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•