[issue45880] Performance regression of Int object operators. (Python 3.11)

2021-11-23 Thread Guido van Rossum


Change by Guido van Rossum :


--
resolution:  -> works for me
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45880] Performance regression of Int object operators. (Python 3.11)

2021-11-23 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Reposting with more careful timing runs.  No regression was observed.

$ python3.10 --version
Python 3.10.0
$ python3.10 -m timeit -r 11 -s 'x=5' 'x^3'# Xor with variable
500 loops, best of 11: 41.7 nsec per loop
$ python3.10 -m timeit -r 11 -s 'x=5' 'x+3'# Add with variable
1000 loops, best of 11: 22.7 nsec per loop
$ python3.10 -m timeit -r 11 '5+3' # Constant folded
5000 loops, best of 11: 7.22 nsec per loop

$ python3.11 --version
Python 3.11.0a2
$ python3.11 -m timeit -r 11 -s 'x=5' 'x^3'# Xor with variable
2000 loops, best of 11: 19.4 nsec per loop
$ python3.11 -m timeit -r 11 -s 'x=5' 'x+3'# Add with variable
2000 loops, best of 11: 17 nsec per loop
$ python3.11 -m timeit -r 11 '5+3' # Constant folded
5000 loops, best of 11: 7.27 nsec per loop

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45880] Performance regression of Int object operators. (Python 3.11)

2021-11-23 Thread Mark Shannon


Mark Shannon  added the comment:

> I assume there's something wrong with the OP's methodology for profiling.

In a word "cProfile".
All cProfile is doing is measuring the overhead of cProfile.

That the overhead of cProfile has gone up is not surprising. That it has gone 
up so much, is a bit surprising.

My advice would be use a sampling profiling like Scalene.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45880] Performance regression of Int object operators. (Python 3.11)

2021-11-23 Thread Guido van Rossum


Guido van Rossum  added the comment:

I assume there's something wrong with the OP's methodology for profiling. 

(Raymond, in your last example there's a -s argument but nothing to run -- does 
timeit just use "pass" in that case?)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45880] Performance regression of Int object operators. (Python 3.11)

2021-11-23 Thread Irit Katriel


Irit Katriel  added the comment:

Raymond, your last two results look like 3.10 rather than 3.11.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45880] Performance regression of Int object operators. (Python 3.11)

2021-11-23 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +Mark.Shannon, gvanrossum, iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45880] Performance regression of Int object operators. (Python 3.11)

2021-11-23 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Here are timings from stock macOS builds from python.org:

$ python3.10 --version
Python 3.10.0
$ python3.10 -m timeit -r 11 -s 'x=5' 'x^3'  # Xor with variable
500 loops, best of 11: 41.4 nsec per loop
$ python3.10 -m timeit -r 11 -s 'x=5' 'x+3'  # Add with variable
1000 loops, best of 11: 22.7 nsec per loop
$ python3.10 -m timeit -r 11 -s '3 + 5'  # Constant folded
5000 loops, best of 11: 7.15 nsec per loop

$ python3.11 --version
Python 3.11.0a2
$ python3.11 -m timeit -r 11 -s 'x=5' 'x^3'
2000 loops, best of 11: 19.2 nsec per loop
$ python3.10 -m timeit -r 11 -s 'x=5' 'x+3'
1000 loops, best of 11: 22.5 nsec per loop
$ python3.10 -m timeit -r 11 -s '3 + 5'
5000 loops, best of 11: 7.16 nsec per loop

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45880] Performance regression of Int object operators. (Python 3.11)

2021-11-23 Thread Xinhang Xu


New submission from Xinhang Xu :

Hello.

I'm working on a compute-bound project recently, so I tested several Python 
versions on my PC (Windows 10 64-bit), about Python's performance on operating 
Int object. All Python binaries are official distributions.


Testcase #1 (simple xor op)

Source:

import cProfile as profile
profile.run('for _ in range(5): 5 ^ 6')

The given result:

   C:\Users\surface\Desktop\PythonTest>python-3.9.9-embed-amd64\python 
C:\Users\surface\python_test.py
 3 function calls in 24.398 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
1   24.398   24.398   24.398   24.398 :1()
10.0000.000   24.398   24.398 {built-in method builtins.exec}
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}



   C:\Users\surface\Desktop\PythonTest>python-3.10.0-embed-amd64\python 
C:\Users\surface\python_test.py
 3 function calls in 27.941 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
1   27.941   27.941   27.941   27.941 :1()
10.0000.000   27.941   27.941 {built-in method builtins.exec}
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}



   C:\Users\surface\Desktop\PythonTest>python-3.11.0a2-embed-amd64\python 
C:\Users\surface\python_test.py
 3 function calls in 42.209 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
1   42.209   42.209   42.209   42.209 :1()
10.0000.000   42.209   42.209 {built-in method builtins.exec}
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}



Testcase #2 (simple add op)

Source:

import cProfile as profile
profile.run('for _ in range(5): 5 + 6')

The given result:

   C:\Users\surface\Desktop\PythonTest>python-3.9.9-embed-amd64\python 
C:\Users\surface\python_test.py
 3 function calls in 24.599 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
1   24.599   24.599   24.599   24.599 :1()
10.0000.000   24.599   24.599 {built-in method builtins.exec}
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}



   C:\Users\surface\Desktop\PythonTest>python-3.10.0-embed-amd64\python 
C:\Users\surface\python_test.py
 3 function calls in 27.414 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
1   27.414   27.414   27.414   27.414 :1()
10.0000.000   27.414   27.414 {built-in method builtins.exec}
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}



   C:\Users\surface\Desktop\PythonTest>python-3.11.0a2-embed-amd64\python 
C:\Users\surface\python_test.py
 3 function calls in 43.675 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
1   43.675   43.675   43.675   43.675 :1()
10.0000.000   43.675   43.675 {built-in method builtins.exec}
10.0000.0000.0000.000 {method 'disable' of 
'_lsprof.Profiler' objects}



As you can see, Python 3.11 costs *much more* time to execute Int object 
operator. I have also tested the same cases on another Windows PC, the result 
shows the same.

Is it a common thing? What's the reason for this problem?


Thanks.

--
messages: 406849
nosy: xuxinhang
priority: normal
severity: normal
status: open
title: Performance regression of Int object operators. (Python 3.11)
type: performance
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com