Last Comment Bug 807896 - Reduce the initial size of SPS's strings hashtable
: Reduce the initial size of SPS's strings hashtable
Status: RESOLVED FIXED
[MemShrink]
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla19
Assigned To: Nicholas Nethercote [:njn]
:
:
Mentors:
Depends on:
Blocks: B2GDarkMatter
  Show dependency treegraph
 
Reported: 2012-11-01 21:47 PDT by Nicholas Nethercote [:njn]
Modified: 2012-11-07 18:54 PST (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
fixed
fixed


Attachments
Reduce the initial size of SPS's strings hashtable. (785 bytes, patch)
2012-11-01 21:48 PDT, Nicholas Nethercote [:njn]
u443197: review+
bajaj.bhavana: approval‑mozilla‑aurora+
Details | Diff | Splinter Review

Description Nicholas Nethercote [:njn] 2012-11-01 21:47:46 PDT
SPSProfiler::strings is initialized like this:

  strings.init(max)

and in Gecko |max| is 1,024.  This ends up giving us a hashtable with 2,048
entries, which takes up 24,576 bytes on 32-bit platforms, and 49,152 bytes on
64-bit platforms.  This is overkill.
Comment 1 Nicholas Nethercote [:njn] 2012-11-01 21:48:17 PDT
Created attachment 677659 [details] [diff] [review]
Reduce the initial size of SPS's strings hashtable.

This patch causes the hashtable to initialize to the default size (32 
entries), which results in a 512 byte table on 32-bit platforms and a 1,024 
byte table on 64-bit platforms.

This avoids wasting space when SPS isn't used, and when SPS is used the table
will quickly grow (with negligible overhead) to a suitable size (which may 
still be substantially less than 2,048 entries).

This is a tiny win, but hey!  It's a tiny patch.  And it saves me from having 
to see it come up in memory profiles all the time.
Comment 2 Nicholas Nethercote [:njn] 2012-11-04 14:58:43 PST
https://hg.mozilla.org/integration/mozilla-inbound/rev/52feef2d0c8e
Comment 3 Nicholas Nethercote [:njn] 2012-11-04 15:03:42 PST
Comment on attachment 677659 [details] [diff] [review]
Reduce the initial size of SPS's strings hashtable.

[Approval Request Comment]

Bug caused by (feature/regressing bug #):  N/A.

User impact if declined:  slightly higher memory consumption on B2G;  the patch saves 24 KiB per B2G process.

Testing completed (on m-c, etc.):  just landed on m-c.

Risk to taking this patch (and alternatives if risky):  negligible.  It just reduces the initial size of a hashtable that's only used if the SPS profiler is enabled.  (There's no functionality change;  the table will grow as needed if the SPS profiler is enabled.)

String or UUID changes made by this patch:
Comment 4 Ed Morley [:emorley] 2012-11-05 07:50:16 PST
https://hg.mozilla.org/mozilla-central/rev/52feef2d0c8e
Comment 5 Ryan VanderMeulen [:RyanVM] 2012-11-07 18:54:53 PST
https://hg.mozilla.org/releases/mozilla-aurora/rev/07bbdd455716

Note You need to log in before you can comment on or make changes to this bug.