memset is slow and lame with gcc

RESOLVED FIXED in mozilla11

Status

()

Core
JavaScript Engine
RESOLVED FIXED
7 years ago
5 years ago

People

(Reporter: gal, Assigned: froydnj)

Tracking

({perf})

Trunk
mozilla11
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
GCC optimizes memset with a constant N, i.e. memset(a, 0, sizeof(T))

GCC does not optimize memset with a constant element size, i.e. memset(a, 0, n * sizeof(T))

In general, the call into memset is really expensive for small n.

PodZero should be changed to only use memset with a constant T and loop around that. We also should have PodCompare that is a substite for memcmp.

Comment 1

7 years ago
PodCopy, too, to complete the trilogy.
Keywords: perf
Still a valid non-TM bug?
Andreas/bz/Luke, ping?
Yes.  This stuff is used all over the VM.  This bug needs an owner.....
Summary: TM: memset is slow and lame with gcc → memset is slow and lame with gcc
(Assignee)

Comment 5

5 years ago
Created attachment 580256 [details] [diff] [review]
patch

So this is the trivial patch with a possibly overly-long explanatory comment.  Luke, WDYT?

I didn't add PodCopy because we already have that.  PodCompare didn't seem worth it for the very small number of memcmps in the codebase.
Attachment #580256 - Flags: feedback?(luke)

Comment 6

5 years ago
Comment on attachment 580256 [details] [diff] [review]
patch

I was about to say "but this will lose the benefits of memset when nelem is large" but then I check and none of the uses of binary PodZero would seem to have big nelem.  So this looks great; if it ever matters, we'll just use memset directly.
Attachment #580256 - Flags: feedback?(luke) → feedback+
(Assignee)

Comment 7

5 years ago
Comment on attachment 580256 [details] [diff] [review]
patch

Converting luke's feedback+ into r+ for such a trivial patch.
Attachment #580256 - Flags: feedback+ → review+
(Assignee)

Updated

5 years ago
Keywords: checkin-needed

Updated

5 years ago
Assignee: general → nfroyd

Comment 8

5 years ago
In my queue with a few other checkin-neededs that are being sent to try first and then onto inbound :-)
https://tbpl.mozilla.org/?tree=Try&rev=fd440327d5e4
Keywords: checkin-needed

Comment 9

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/b9a619e265d5
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla11
https://hg.mozilla.org/mozilla-central/rev/b9a619e265d5
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.