| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| return (is_nonnegative_compactlong(lhs) && is_nonnegative_compactlong(rhs)); | ||
| } | ||
|
|
||
| #define NONNEGATIVE_LONGS_ACTION(NAME, OP) \ |
There was a problem hiding this comment.
Why restrict to nonnegative longs here? If we do restrict, then we can replace the calls _PyLong_CompactValue with direct access to op->long_value.ob_digit[0]
Sorry, something went wrong.
There was a problem hiding this comment.
Because negative ints need more work at runtime and I don't think they're common with bitwise logical ops.
Sorry, something went wrong.
There was a problem hiding this comment.
The extra work is already done by _PyLong_CompactValue or am missing something? The output of ls OP rhs might not be a compact int, but there are no guards for the output type.
Sorry, something went wrong.
There was a problem hiding this comment.
The extra work is already done by _PyLong_CompactValue or am missing something?
No, I think you're right. Good point.
The output of ls OP rhs might not be a compact int, but there are no guards for the output type.
For bitwise logical operators we should expect the results to have the same size as the inputs.
Sorry, something went wrong.
…e-100239.7_HpBU.rst Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
|
The stats are weird with this PR, lot of misses: https://github.com/faster-cpython/benchmarking-public/blob/main/results/bm-20250116-3.14.0a4%2B-c57fe46/bm-20250116-azure-x86_64-iritkatriel-binaryops-3.14.0a4%2B-c57fe46-pystats-vs-base.md
|
Sorry, something went wrong.
There was a problem hiding this comment.
I think non-negative should be dropped in the news entry now?
Sorry, something went wrong.
And maybe in the title of this pull request, too? |
Sorry, something went wrong.
There was a problem hiding this comment.
It looks like we are seeing a high proportion of specialization failures for non-compact ints with the & operator.
I don't know why that would be. My guess is that some of the benchmarks are using ints as bit vectors and using more than one digit.
Sorry, something went wrong.
|
|
||
| LOOKUP_SPEC(compactlong_float_specs, oparg); | ||
| LOOKUP_SPEC(float_compactlong_specs, oparg); | ||
| LOOKUP_SPEC(compactlongs_specs, oparg); |
There was a problem hiding this comment.
Why three tables, rather than one?
Sorry, something went wrong.
There was a problem hiding this comment.
A single table would need to have a list of (guard, action) pairs for each OP. So it's a table of tables. Same thing basically.
Sorry, something went wrong.
Just a wild guess: could those be from enums, which derive from int? Especially flag enums? |
Sorry, something went wrong.
I don't think so. We check for int with PyLong_CheckExact. |
Sorry, something went wrong.
|
I suspect the misses might be bm_pyflate: Other python constructions that would causes misses (but are not in pyperformance afaics) are uuid.uuid4 (and variants) and bitwise logical operations on the hash of python objects. |
Sorry, something went wrong.
|
(Would be nice if the report was rendered so that it's easy to see which benchmark contributed to a stat.) |
Sorry, something went wrong.
|
Do we have benchmarking numbers for this? |
Sorry, something went wrong.
(mdboom edited URL to the public one) |
Sorry, something went wrong.
|
Performance looks neutral within the noise. Were we expecting a speedup on any particular benchmark, or is there a micro-benchmark that shows a speedup? |
Sorry, something went wrong.
Here are some microbenchmark numbers: Old: >>> for i in range(5):
... timeit("for i in range(10000):\n\tb = a&i", number=10000, setup="a = 1")
...
2.517115215305239
2.476386756170541
2.484560175333172
2.4904085099697113
2.4953759447671473
New: >>> for i in range(5):
... timeit("for i in range(10000):\n\tb = a&i", number=10000, setup="a = 1")
...
2.2215038347058
2.1580611928366125
2.1611814140342176
2.154480631928891
2.1730910362675786
|
Sorry, something went wrong.
There was a problem hiding this comment.
My interpretation of the results is:
@iritkatriel do you agree?
If so, let's merge this.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This adds specialisations for bitwise |, &, ^ on non-negative ints.
I'm not adding more in the same PR so we can more easily bisect in the future if we need to.