Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create vmx_memchr() and use it (along with other JS string matching improvements) #406

Closed
classilla opened this issue Jun 18, 2017 · 7 comments

Comments

@classilla
Copy link
Owner

A la https://bugzilla.mozilla.org/show_bug.cgi?id=1371215 :

We should be using the unrolled version, not memchr(), which is apparently gross and slow on anything before 10.12 (see https://gist.github.com/nico/2624336 ). In particular the defined (__clang__) is wrong, so we need to correct the block in https://hg.mozilla.org/mozilla-central/rev/f4048987a5e3

Once that is done, we can take https://hg.mozilla.org/integration/mozilla-inbound/rev/fce84022f5e3 and https://hg.mozilla.org/integration/mozilla-inbound/rev/35b9efa24066 (minus the change above, of course).

@classilla
Copy link
Owner Author

Conceivably we could even vectorize it. Here is a fast memchr():

https://github.com/ridiculousfish/HexFiend/blob/4d5bcee5715f5f288649f7471d1da5bd06376f46/framework/sources/HFFastMemchr.m

@classilla
Copy link
Owner Author

classilla commented Jun 18, 2017

memchr() pops up a few other places, too. Maybe we should create a vmx_memchr() and start using it. In particular it's in netwerk/ nsprpub/ xpcom/ and even layout/ as well as ICU.

@classilla classilla changed the title Improve JS string matching Create vmx_memchr() and use it (along with other JS string matching improvements) Jun 18, 2017
@classilla
Copy link
Owner Author

This implies that for anything less than the size of stride (which I guess means at least one vector), a simple-minded routine is better.

https://sourceware.org/viewvc/src/newlib/libc/string/memchr.c?revision=1.4&view=markup

@classilla
Copy link
Owner Author

First pass, disabling memchr() and using the built-in unrolled FirstChar* matcher, improves V8 from a peak of 3001 (Quad in Reduced) to 3033 (same).

@classilla
Copy link
Owner Author

VMX version currently around 3050, though the biggest improvement is on regexp (as expected, since it matches against very long strings). There are still some possible improvements to be made, as well as the rest of the string matching changes.

@classilla
Copy link
Owner Author

No others to convert that make sense.

OlgaTPark added a commit to OlgaTPark/tenfourfox that referenced this issue Aug 18, 2019
Add a SSE2 optimized variant of `memchr`.  Results are mitigated on older Core 2 CPUs and more significant on newer ones.   
This uses code from <https://github.com/ridiculousfish/HexFiend/blob/184646d0a42a70b6a8015daeb510aca47714d863/framework/sources/HFFastMemchr.m> © 2005-2016 Peter Ammon, license: <https://github.com/ridiculousfish/HexFiend/blob/master/License.txt>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant