Closed Bug 1429245 Opened 6 years ago Closed 6 years ago

Optimize CommonUtils.bytesAsHex

Categories

(Firefox :: Sync, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
Firefox 59
Tracking Status
firefox59 --- fixed

People

(Reporter: eoger, Assigned: eoger)

Details

Attachments

(1 file)

CommonUtils.bytesAsHex [0] shows up on profiles and could be faster [1] if we changed the algorithm to concatenate the hex values to a string directly instead of using a intermediate array.

[0] https://searchfox.org/mozilla-central/rev/03877052c151a8f062eea177f684a2743cd7b1d5/services/common/utils.js#216
[1] https://jsperf.com/bytesashex
https://jsperf.com/bytes-as-hex/1 has a slightly more optimized version, uses possibly more realistic strings, and makes more of an attempt to avoid the JIT optimizing away the bulk of the work.
Assignee: nobody → eoger
Status: NEW → ASSIGNED
Priority: -- → P1
Comment on attachment 8941628 [details]
Bug 1429245 - Optimize CommonUtils.bytesAsHex.

https://reviewboard.mozilla.org/r/211868/#review217798

Clearing review as discussed in IRC.
Attachment #8941628 - Flags: review?(tchiovoloni)
Comment on attachment 8941628 [details]
Bug 1429245 - Optimize CommonUtils.bytesAsHex.

https://reviewboard.mozilla.org/r/211868/#review217800

Looks good to me! Can you double-check that we have test coverage for this function already? I'm pretty sure we do.
Attachment #8941628 - Flags: review?(tchiovoloni) → review+
Pushed by eoger@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d7e62d039551
Optimize CommonUtils.bytesAsHex. r=tcsc
https://hg.mozilla.org/mozilla-central/rev/d7e62d039551
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 59
Why bytes[i].charCodeAt(0) and not bytes.charCodeAt(i) ?
I don't think there's a reason. We'd probably want to check that this is just as fast though (I mean, it seems very unlikely it matters), this function was at the top of most profiles during a sync.
To be clear, I probably should have caught that during the review :p
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: