[issue21148] avoid memset in small tuple creation

2015-04-14 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I think this looks promising.

Don't worry too much about the modest timing improvement.  For the most part, 
we should almost always take steps to eliminate work that is known to be 
unnecessary.  The timings serve as a guide but it would be easy for us to get 
trapped in local minimums on a particular machine or compiler.

--
nosy: +rhettinger

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



[issue21148] avoid memset in small tuple creation

2015-04-14 Thread STINNER Victor

STINNER Victor added the comment:

 avoid memset in small tuple creation

I don't understand this title because there is no call to memset() in the patch.

Can you try to modify PyTuple_New() to use memset() instead of a dummy loop?

Adding a _PyTuple_New() which doesn't initialize the memory doesn't seem safe 
to me.

You may try to allocate the tuple with PyObject_Calloc(), but when I tried on 
other types, it was slower than PyObject_Malloc() for sizes smaller than 1 MB.

--
nosy: +haypo

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



[issue21148] avoid memset in small tuple creation

2015-04-13 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +serhiy.storchaka

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



[issue21148] avoid memset in small tuple creation

2014-04-03 Thread Julian Taylor

New submission from Julian Taylor:

attached a prototype patch that avoids the memset of ob_item in PyTuple_New 
which is not necessary for the BUILD_TUPLE bytecode and PyTuple_Pack as these 
overwrite every entry in ob_item anyway.
This improves small tuple creation by about 5%.

It does this by adding a new internal function that does not use the memset 
loop and wrapping that in PyTuple_New that does it. _Pack and ceval call the 
internal function.
The patch still needs cleanup I don't know where the signature for ceval.c 
would best go. Does the internal function need to be hidden from the DSO?

microbenchmark, compiled with gcc-4.8.2 on ubuntu 14.04 amd64, default 
configure options:

import timeit
print(min(timeit.repeat((a,), setup=a = 1; b = 1, repeat=5, number=10**7)))
print(min(timeit.repeat((a, b), setup=a = 1; b = 1, repeat=5, 
number=10**7)))

before:
0.45767
0.52926

after:
0.42652
0.50122

larger tuples do not profit much as the loading is more expensive in comparison.

--
components: Interpreter Core
files: avoid-memset.patch
keywords: patch
messages: 215461
nosy: jtaylor
priority: normal
severity: normal
status: open
title: avoid memset in small tuple creation
type: performance
versions: Python 3.5
Added file: http://bugs.python.org/file34715/avoid-memset.patch

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



[issue21148] avoid memset in small tuple creation

2014-04-03 Thread Antoine Pitrou

Antoine Pitrou added the comment:

A 5% improvement on a micro-benchmark probably means 0% on real workloads. You 
could try to run the benchmarks suite at http://hg.python.org/benchmarks

--
nosy: +pitrou

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