Closed Bug 769504 Opened 13 years ago Closed 13 years ago

Atomize strings when adding to Map (as a key) or Set

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: jorendorff, Assigned: jorendorff)

References

Details

(Whiteboard: [js:t])

Attachments

(2 files)

HashableValue::setValue is a convenient place to do this. Tradeoffs: - Atomizing takes time. + Without atomizing, every hash table lookup with a string key must take time proportional to the length of the string. With atomizing, there are some cases where lookup can be much faster. + With atomizing, all comparisons are simple 64-bit comparisons. + With atomizing, HashableValue::hash() is always fast, so growing a table can be fast even if there are long string keys. + With atomizing, HashableValue::hash() is so fast that caching a hash code for each entry in the hash table is pointless. (We currently do not cache hash codes anyway; we're just slow.) - Atomizing can make extra copies of strings. + Atomizing can common up strings, saving memory. - Atomizing makes strings in the atom compartment that won't be collected until the next full (runtime-wide) GC. I think we should atomize. (At the same time--I think HashableValue::hash()'s last line can be a little simpler given the changes to ScrambleHashCode in bug 743107. Not sure.)
Depends on: 743107
Whiteboard: [js:t]
Assignee: general → jorendorff
Attachment #638357 - Flags: review?(luke)
Attachment #638358 - Flags: review?(luke)
Attachment #638357 - Flags: review?(luke) → review+
Comment on attachment 638358 [details] [diff] [review] part 1 - atomize, v1 Nice
Attachment #638358 - Flags: review?(luke) → review+
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla16
I was backing out a number of patches in the js land, and unfortunately this patch caused a number of merge conflicts which I did not trust myself to resolve. Therefore, I had to back it out. Please reland after fixing the conflicts resulting from the backouts. Thanks, and apologies for the inconvenience. Backout changeset: https://hg.mozilla.org/mozilla-central/rev/f6bdb7fc663f
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: mozilla16 → mozilla17
Status: REOPENED → RESOLVED
Closed: 13 years ago13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: