[Python-Dev] Tagged integers
James Y Knight
foom at fuhm.net
Thu Jul 15 00:46:43 CEST 2004
On Jul 14, 2004, at 12:28 PM, Jeff Epler wrote:
> I tried this back in 2002.
> http://mail.python.org/pipermail/python-dev/2002-August/027685.html
Interesting that I somehow missed that in my search. I had thought
surely someone must've tried it already. Ah well. :) But, I'm glad I
did it, because I do have somewhat different results.
1) No segfaults or other weird behavior (all tests pass)
2) With tagged integers does actually benchmark faster than without
(although, not by all that much).
The version of the patch I sent earlier was indeed slightly slower at
pystone than standard python. However, I have made a few changes that
have since made it faster, instead:
1) made Py_tagged_types a const array.
2) removed inlining of creation of small ints for PyInt_FromLong. Turns
out that makes it go slower not faster.
Anyhow, current result is a 3% overall speedup of pystone. 35791
pystones/second (standard python 2.3.3), vs. 36900 pystones/second
(tagged integers).
I also tried running pybench -w 5. Here's the results, compared to
standard python 2.3.3. Overall speedup of 7.19%. I must admit I find
these results quite puzzling, as I certainly didn't expect it to affect
list slicing that much. Also, that Compare* are so much slower seems
strange as well. Perhaps there's something that can be done about that.
Tests: per run per oper. diff *)
------------------------------------------------------------------------
BuiltinFunctionCalls: 227.75 ms 0.45 us -3.72%
BuiltinMethodLookup: 386.30 ms 0.18 us +3.33%
CompareFloats: 283.50 ms 0.16 us +57.46%
CompareFloatsIntegers: 343.35 ms 0.19 us -1.07%
CompareIntegers: 261.90 ms 0.07 us -0.44%
CompareInternedStrings: 210.10 ms 0.11 us +19.68%
CompareLongs: 244.45 ms 0.14 us +30.65%
CompareStrings: 338.05 ms 0.17 us +11.73%
CompareUnicode: 265.35 ms 0.18 us +17.70%
ConcatStrings: 456.20 ms 0.76 us -3.31%
ConcatUnicode: 564.00 ms 0.94 us -2.92%
CreateInstances: 300.30 ms 1.79 us -2.52%
CreateStringsWithConcat: 178.35 ms 0.22 us +4.54%
CreateUnicodeWithConcat: 559.35 ms 0.70 us +3.84%
DictCreation: 230.50 ms 0.38 us -12.02%
DictWithFloatKeys: 504.20 ms 0.21 us -5.86%
DictWithIntegerKeys: 225.10 ms 0.09 us -22.82%
DictWithStringKeys: 247.20 ms 0.10 us -7.98%
ForLoops: 183.85 ms 4.60 us -18.97%
IfThenElse: 211.60 ms 0.08 us -2.78%
ListSlicing: 81.70 ms 5.84 us -60.64%
NestedForLoops: 141.95 ms 0.09 us -12.38%
NormalClassAttribute: 296.05 ms 0.12 us -4.25%
NormalInstanceAttribute: 266.15 ms 0.11 us -10.51%
PythonFunctionCalls: 336.45 ms 0.51 us -10.05%
PythonMethodCalls: 277.80 ms 0.93 us -1.35%
Recursion: 233.50 ms 4.67 us -18.99%
SecondImport: 191.85 ms 1.92 us +4.44%
SecondPackageImport: 205.75 ms 2.06 us +3.03%
SecondSubmoduleImport: 255.75 ms 2.56 us +3.67%
SimpleComplexArithmetic: 206.70 ms 0.23 us +4.21%
SimpleDictManipulation: 172.50 ms 0.14 us -14.22%
SimpleFloatArithmetic: 296.15 ms 0.13 us +8.32%
SimpleIntFloatArithmetic: 183.85 ms 0.07 us -33.65%
SimpleIntegerArithmetic: 182.00 ms 0.07 us -32.62%
SimpleListManipulation: 217.50 ms 0.20 us -10.12%
SimpleLongArithmetic: 161.70 ms 0.25 us +6.73%
SmallLists: 562.85 ms 0.55 us +13.40%
SmallTuples: 468.30 ms 0.49 us +15.70%
SpecialClassAttribute: 289.00 ms 0.12 us -5.97%
SpecialInstanceAttribute: 460.00 ms 0.19 us -1.33%
StringMappings: 319.10 ms 0.63 us -0.17%
StringPredicates: 297.50 ms 0.27 us -0.77%
StringSlicing: 270.00 ms 0.39 us -1.93%
TryExcept: 203.20 ms 0.03 us +0.15%
TryRaiseExcept: 217.40 ms 3.62 us -28.71%
TupleSlicing: 223.55 ms 0.53 us -42.15%
UnicodeMappings: 250.10 ms 3.47 us +0.44%
UnicodePredicates: 257.60 ms 0.29 us +2.79%
UnicodeProperties: 398.55 ms 0.50 us +6.69%
UnicodeSlicing: 395.95 ms 0.57 us +1.71%
------------------------------------------------------------------------
Average round time: 15663.00 ms -7.19%
For comparison, here's the results from standard python:
Tests: per run per oper. overhead
------------------------------------------------------------------------
BuiltinFunctionCalls: 236.55 ms 0.46 us 0.50 ms
BuiltinMethodLookup: 373.85 ms 0.18 us 1.00 ms
CompareFloats: 180.05 ms 0.10 us 1.00 ms
CompareFloatsIntegers: 347.05 ms 0.19 us 1.00 ms
CompareIntegers: 263.05 ms 0.07 us 2.00 ms
CompareInternedStrings: 175.55 ms 0.09 us 3.50 ms
CompareLongs: 187.10 ms 0.10 us 1.00 ms
CompareStrings: 302.55 ms 0.15 us 3.50 ms
CompareUnicode: 225.45 ms 0.15 us 2.50 ms
ConcatStrings: 471.80 ms 0.79 us 1.00 ms
ConcatUnicode: 580.95 ms 0.97 us 1.00 ms
CreateInstances: 308.05 ms 1.83 us 1.00 ms
CreateStringsWithConcat: 170.60 ms 0.21 us 1.00 ms
CreateUnicodeWithConcat: 538.65 ms 0.67 us 1.00 ms
DictCreation: 262.00 ms 0.44 us 1.00 ms
DictWithFloatKeys: 535.60 ms 0.22 us 3.50 ms
DictWithIntegerKeys: 291.65 ms 0.12 us 3.50 ms
DictWithStringKeys: 268.65 ms 0.11 us 3.00 ms
ForLoops: 226.90 ms 5.67 us 0.50 ms
IfThenElse: 217.65 ms 0.08 us 2.50 ms
ListSlicing: 207.55 ms 14.83 us 0.50 ms
NestedForLoops: 162.00 ms 0.11 us 0.00 ms
NormalClassAttribute: 309.20 ms 0.13 us 1.50 ms
NormalInstanceAttribute: 297.40 ms 0.12 us 1.50 ms
PythonFunctionCalls: 374.05 ms 0.57 us 1.00 ms
PythonMethodCalls: 281.60 ms 0.94 us 0.50 ms
Recursion: 288.25 ms 5.77 us 0.50 ms
SecondImport: 183.70 ms 1.84 us 0.50 ms
SecondPackageImport: 199.70 ms 2.00 us 0.50 ms
SecondSubmoduleImport: 246.70 ms 2.47 us 0.50 ms
SimpleComplexArithmetic: 198.35 ms 0.23 us 1.00 ms
SimpleDictManipulation: 201.10 ms 0.17 us 0.50 ms
SimpleFloatArithmetic: 273.40 ms 0.12 us 2.00 ms
SimpleIntFloatArithmetic: 277.10 ms 0.10 us 2.00 ms
SimpleIntegerArithmetic: 270.10 ms 0.10 us 2.00 ms
SimpleListManipulation: 242.00 ms 0.22 us 1.00 ms
SimpleLongArithmetic: 151.50 ms 0.23 us 0.50 ms
SmallLists: 496.35 ms 0.49 us 2.50 ms
SmallTuples: 404.75 ms 0.42 us 1.50 ms
SpecialClassAttribute: 307.35 ms 0.13 us 2.00 ms
SpecialInstanceAttribute: 466.20 ms 0.19 us 2.00 ms
StringMappings: 319.65 ms 0.63 us 1.50 ms
StringPredicates: 299.80 ms 0.27 us 5.00 ms
StringSlicing: 275.30 ms 0.39 us 1.50 ms
TryExcept: 202.90 ms 0.03 us 3.00 ms
TryRaiseExcept: 304.95 ms 5.08 us 1.00 ms
TupleSlicing: 386.40 ms 0.92 us 0.50 ms
UnicodeMappings: 249.00 ms 3.46 us 1.00 ms
UnicodePredicates: 250.60 ms 0.28 us 6.50 ms
UnicodeProperties: 373.55 ms 0.47 us 6.50 ms
UnicodeSlicing: 389.30 ms 0.56 us 2.00 ms
------------------------------------------------------------------------
Average round time: 16876.00 ms
James
More information about the Python-Dev
mailing list