Open Bug 1866499 Opened 10 months ago Updated 10 months ago

camelCase() is 2.8x faster in V8 than SM

Categories

(Core :: JavaScript Engine: JIT, defect, P3)

defect

Tracking

()

People

(Reporter: jrmuizel, Unassigned)

References

(Depends on 2 open bugs, Blocks 2 open bugs)

Details

(Whiteboard: [sp3])

// Matches dashed string for camelizing
var rmsPrefix = /^-ms-/,
	rdashAlpha = /-([a-z])/g;

// Used by camelCase as callback to replace()
function fcamelCase( _all, letter ) {
	return letter.toUpperCase();
}

function camelCase( string ) {
	return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
}

Making Firefox as fast as Chrome on this function would reduce its time by 1.1% on TodoMVC-Backbone.

camelCase is called 714 times during TodoMVC-Backbone. It is called with these strings:
"focusout"
"events"
"display"

The time in the profiles does not include any time spent in fcamelCase (but there are no matches)

FF: https://share.firefox.dev/47qFM8Z
Chrome: https://share.firefox.dev/49KmQ73

Blocks: speedometer3

This has both functional (with a JS callback function) and non-functional replace calls.

I tried to rewrite the non-functional case in C++ in bug 1859521. It showed some small improvements on Speedometer 3 and it was definitely faster than the Baseline code we're executing here, but it was slower than the Ion-compiled version.

Here we spend more time in RegExpGlobalReplaceOptFunc and that will have to stay as self-hosted code because calling into JS is slow from C++. The simplest option for now might be to try to get some of these self-hosted functions into Ion faster.

Depends on: 1859521, 1828714

RegExpGlobalReplaceOptFunc gets a maximum warm up count value of ~1482 on Backbone, just short of the Ion threshold.

Summary: camelCase() is 2.8x faster in V8 then SM → camelCase() is 2.8x faster in V8 than SM
Whiteboard: [sp3]
Blocks: sm-opt-jits
Severity: -- → S4
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.