Baseline: Optimize intrinsics used in self-hosted functions




JavaScript Engine: JIT
a month ago
14 days ago


(Reporter: djvj, Unassigned)


(Depends on: 5 bugs, Blocks: 2 bugs)

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [qf:p1])


(2 attachments)



a month ago
After using rdtsc to measure time spent in intrinsics, and running the results against speedometer, I came up with a total measurement for time-spent in various intrinsics across the benchmark.

I ran it on speedometer, and once on a general browsing session that involved visiting gmail, gdocs, twitter frontpage, twitter search, cnn frontpage and article, frontpage and "deals" page, reddit front page and articles.

I'll just paste the top 20 intrinsics, in terms of time-spent, for each case:


std_Math_min => 28518554 ticks (count=413138)
RegExpInstanceOptimizable => 31105700 ticks (count=418403)
std_Math_max => 33540817 ticks (count=395139)
IsArray => 34312855 ticks (count=330131)
ToString => 36136290 ticks (count=912097)
StringReplaceString => 38208127 ticks (count=28218)
ToInteger => 44851095 ticks (count=535956)
IsPackedArray => 45654528 ticks (count=1414262)
GetElemBaseForLambda => 46164058 ticks (count=192145)
SubstringKernel => 61161206 ticks (count=270412)
RegExpGetSubstitution => 102270993 ticks (count=60778)
RegExpSearcher => 205811871 ticks (count=85808)
RegExpTester => 306156740 ticks (count=131025)
StringSplitStringLimit => 494954420 ticks (count=169360)
std_Array => 539239036 ticks (count=202579)
regexp_clone => 566546133 ticks (count=343155)
_FinishBoundFunctionInit => 1155262166 ticks (count=2322935)
_IsConstructing => 1271157593 ticks (count=2453737)
StringSplitString => 1538477812 ticks (count=788446)
RegExpMatcher => 2036433481 ticks (count=414165)

General browsing:

TypedArrayBuffer => 32183411 ticks (count=71061)
std_Set_iterator => 32347514 ticks (count=4579)
ToInteger => 37726105 ticks (count=439636)
GetElemBaseForLambda => 39114952 ticks (count=47771)
RegExpGetSubstitution => 40522762 ticks (count=18382)
intl_availableCalendars => 47658905 ticks (count=2)
std_Array_unshift => 55967512 ticks (count=1704)
NewArrayIterator => 60243392 ticks (count=44271)
intl_availableCollations => 61644663 ticks (count=8)
SubstringKernel => 76173240 ticks (count=199479)
_IsConstructing => 271923201 ticks (count=175464)
regexp_clone => 346393543 ticks (count=211026)
RegExpSearcher => 376314821 ticks (count=85419)
std_Array => 479490605 ticks (count=121695)
StringSplitString => 719726742 ticks (count=140479)
RegExpTester => 817476769 ticks (count=98545)
_FinishBoundFunctionInit => 874447924 ticks (count=90540)
RegExpMatcher => 2157427068 ticks (count=342273)
std_Math_max => 78983211736 ticks (count=410267)
std_Math_min => 139792616267 ticks (count=366073)

Comment 1

a month ago
Created attachment 8868238 [details]

Results for speedometer run.

Comment 2

a month ago
Created attachment 8868239 [details]

Results for general browsing run.

Comment 3

a month ago
The general browsing result has a bad output for ToString, due to bad data cleanup in my script.  Actual line should be:

ToString => 57046500 ticks (count=650918)
Depends on: 1365387
As mentioned on IRC, we could probably use |if (| now instead of |if (_IsConstructing())|. Worth measuring.

The call IC is the most complicated Baseline IC at this point. It would be nice to convert it to CacheIR - after that optimizing specific natives/intrinsics could be done with very little extra work. I can work on that in a few weeks if we think it's useful.

Comment 5

a month ago
Till noted that the numbers for min/max seem really off.  There might be outliers in the data caused by context switches in the middle of the function.  Reminder to modify analysis script to throw out outliers before proceeding.


a month ago
Depends on: 1365650

Comment 6

a month ago
After updating the measurement patch to also measure timings for Array and String builtins (both C++-native and self-hosted), and updating the analysis script to throw out outliers (bug 1357180), here are new numbers for speedometer (I've not included functions with a total tick count of <100MM).

array_shift                         => ticks=102220982 count=77806
std_Array_slice                     => ticks=106317754 count=4254
StringReplaceString                 => ticks=110791304 count=82614
std_Function_apply                  => ticks=117073692 count=4707
GetElemBaseForLambda                => ticks=124137568 count=1075279
array_pop                           => ticks=160722276 count=140350
String_slice                        => ticks=176774870 count=84595
String_substring                    => ticks=193600968 count=75892
String_substr                       => ticks=229778575 count=76086
RegExpSearcher                      => ticks=230758406 count=90718
array_isArray                       => ticks=272407559 count=8885200
ArrayValues                         => ticks=281930820 count=74746
str_indexOf                         => ticks=345024737 count=1488149
RegExpGetSubstitution               => ticks=347971536 count=193384
str_toLowerCase                     => ticks=357953923 count=1277959
RegExpTester                        => ticks=365266413 count=207379
array_slice                         => ticks=582474382 count=165662
std_Array                           => ticks=742882733 count=279016
StringSplitString                   => ticks=758041193 count=153176
array_sort                          => ticks=791836175 count=38533
_IsConstructing                     => ticks=806360192 count=1108003
_FinishBoundFunctionInit            => ticks=911459879 count=2068292
array_join                          => ticks=1003951216 count=133046
std_Object_propertyIsEnumerable     => ticks=1168704086 count=10379632
array_indexOf                       => ticks=1179345302 count=532043
regexp_clone                        => ticks=1191878032 count=1272803
String_split                        => ticks=1427541939 count=157076
OwnPropertyKeys                     => ticks=1978027088 count=2205082
RegExpMatcher                       => ticks=2802172819 count=1207792
array_push                          => ticks=3461368102 count=3132916

Comment 7

a month ago
Numbers from general browsing.  This browsing session lasted a while, across a number of top sites (gmail, google, youtube, linkedin, facebook, twitter, cnn, reddit).

Only including the numbers for ticks >100MM.

std_Set_iterator                    => ticks=110725296 count=17862
std_Object_propertyIsEnumerable     => ticks=112682723 count=263010
array_shift                         => ticks=125786592 count=70598
std_Function_apply                  => ticks=145469240 count=8750
String_slice                        => ticks=146129924 count=103430
str_toLowerCase                     => ticks=161173426 count=285030
array_splice                        => ticks=169108842 count=36109
String_substring                    => ticks=183796233 count=89195
String_substr                       => ticks=183904593 count=147892
str_indexOf                         => ticks=198504070 count=587945
std_Array_slice                     => ticks=222747012 count=12678
RegExpGetSubstitution               => ticks=242745744 count=132726
OwnPropertyKeys                     => ticks=314028362 count=74700
ArrayValues                         => ticks=333697458 count=93216
array_join                          => ticks=344194601 count=154238
_IsConstructing                     => ticks=378989490 count=229550
array_indexOf                       => ticks=410826994 count=496983
RegExpSearcher                      => ticks=444617019 count=234626
array_sort                          => ticks=606447899 count=39295
array_unshift                       => ticks=611621356 count=161320
regexp_clone                        => ticks=612977614 count=370586
RegExpTester                        => ticks=732315111 count=117129
std_Array                           => ticks=884810658 count=234193
_FinishBoundFunctionInit            => ticks=962056303 count=195800
array_slice                         => ticks=1120530487 count=461899
StringSplitString                   => ticks=1139177620 count=247124
array_push                          => ticks=1563841031 count=1405280
RegExpMatcher                       => ticks=2153891265 count=480151
String_split                        => ticks=2357659278 count=272309


a month ago
Depends on: 1366263


a month ago
Whiteboard: [qf]


a month ago
Depends on: 1366375


a month ago
Depends on: 1366377


a month ago
Depends on: 1366696


29 days ago
Depends on: 1367779
Depends on: 1368076
Blocks: 1339557
Whiteboard: [qf] → [qf:p1]
You need to log in before you can comment on or make changes to this bug.