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
Specialize STORE_SUBSCR #105
Comments
Summary of data:
Unless someone has a different suggestion, I'll open a PR that does list[small_int], dict[object], and bytearray[int]. |
In django_template, |
Good start! My intuition was that dict[str] and list[small_int] would cover the overwhelming uses of this opcode. Your data seems to confirm that. IIRC Mark has typically produced a little table showing what fraction each potential specialization represents, and we'd focus on whatever gets us to around 90% specialized. It's also somewhat important to verify that per location the specialization stays valid -- e.g. a location that alternates between dict[str] and list[small_int] would be disastrous. Fortunately that feels unlikely (it would have to be rather weird code). However, I could imagine dict[str] and dict[some_other_object] occurring for the same location, in code that's generic over the key type, and that would be a likely worst-case scenario. Hopefully that's rare enough, it's unlikely to be represented in the benchmarks. (And the cost wouldn't be too terrible -- just frequent deoptimizations. IIRC there's also a counter that tracks this and eventually just stops trying to specialize that particular opcode. But I'm not sure.) |
Edit: included data for some stdlib tests |
I few array.array is less common in real code. Real scientific code would use numpy. |
I’m also skeptical about bytearray. Tha comes from having three benchmarks for regex compilation. |
I gathered a bunch of data from the test suite and the
STORE_SUBSCR
-heavy pyperformance benchmarks:https://gist.github.com/sweeneyde/f7c99f3620312f6f90cd0ff63a0d050e
From this, it looks like we should specialize
list[small_int]
anddict[object]
, with some potential opportunities forbytearray[small_int]
orlist[negative_int]
orlist[slice]
orarray[small_int]
as well.The text was updated successfully, but these errors were encountered: