classification
Title: Remove uses of the register keyword
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, mark.dickinson, martin.panter, pitrou, python-dev, rhettinger, serhiy.storchaka, skrah, vstinner
Priority: low Keywords: patch

Created on 2013-08-12 21:46 by pitrou, last changed 2016-03-28 05:28 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
remove_register.patch pitrou, 2013-08-12 21:46 review
Messages (13)
msg195024 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-12 21:46
Attached patch removes all uses of the C "register" keyword in the CPython sources.
msg195025 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-12 21:46
The benchmark suite doesn't show any significant speedup or slowdown generally:

Report on Linux fsol 3.8.0-27-generic #40-Ubuntu SMP Tue Jul 9 00:17:05 UTC 2013 x86_64 x86_64
Total CPU cores: 4

### django_v2 ###
Min: 0.672909 -> 0.659464: 1.02x faster
Avg: 0.673821 -> 0.660258: 1.02x faster
Significant (t=32.72)
Stddev: 0.00071 -> 0.00060: 1.1869x smaller

### fastunpickle ###
Min: 0.578535 -> 0.593218: 1.03x slower
Avg: 0.578700 -> 0.593440: 1.03x slower
Significant (t=-185.83)
Stddev: 0.00011 -> 0.00014: 1.1950x larger

### float ###
Min: 0.309679 -> 0.302615: 1.02x faster
Avg: 0.312457 -> 0.304713: 1.03x faster
Significant (t=4.33)
Stddev: 0.00326 -> 0.00232: 1.4039x smaller

### go ###
Min: 0.602035 -> 0.578129: 1.04x faster
Avg: 0.604634 -> 0.581584: 1.04x faster
Significant (t=12.50)
Stddev: 0.00253 -> 0.00325: 1.2855x larger

### nqueens ###
Min: 0.309602 -> 0.316767: 1.02x slower
Avg: 0.310222 -> 0.317734: 1.02x slower
Significant (t=-21.22)
Stddev: 0.00057 -> 0.00055: 1.0295x smaller

### richards ###
Min: 0.184306 -> 0.178887: 1.03x faster
Avg: 0.184969 -> 0.180215: 1.03x faster
Significant (t=8.40)
Stddev: 0.00076 -> 0.00101: 1.3380x larger

### silent_logging ###
Min: 0.080233 -> 0.073160: 1.10x faster
Avg: 0.080594 -> 0.073170: 1.10x faster
Significant (t=69.28)
Stddev: 0.00024 -> 0.00001: 21.7820x smaller

### threaded_count ###
Min: 0.234882 -> 0.226954: 1.03x faster
Avg: 0.241049 -> 0.231458: 1.04x faster
Significant (t=3.04)
Stddev: 0.00567 -> 0.00420: 1.3519x smaller

### unpack_sequence ###
Min: 0.000046 -> 0.000048: 1.05x slower
Avg: 0.000046 -> 0.000049: 1.06x slower
Significant (t=-299.85)
Stddev: 0.00000 -> 0.00000: 1.0256x larger

The following not significant results are hidden, use -v to show them:
call_method, call_method_slots, call_method_unknown, call_simple, chaos, fannkuch, fastpickle, formatted_logging, iterative_count, json_dump_v2, json_load, meteor_contest, nbody, normal_startup, pathlib, pidigits, raytrace, regex_compile, regex_effbot, regex_v8, simple_logging, spectral_norm, startup_nosite, telco.
msg195028 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-12 22:00
(amusingly, the two Python executables generated by gcc - with or without register - have exactly the same size, although their md5 hashes differ)
msg195029 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-08-12 22:05
+1 for removal of the register keyword.

I hope that nowadays, no compiler needs register hint to be able to optimize correctly a function. GCC knows better than me which variables must be "optimized".
msg195050 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2013-08-13 07:49
+1
msg195053 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-08-13 08:24
> have exactly the same size

Binaries contain paddings.

> although their md5 hashes differ

Timestamps.

I'm interesting if someone builds CPython with more simple compilers (i.e. PCC [1]).

[1] http://en.wikipedia.org/wiki/Portable_C_Compiler
msg195054 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-13 08:29
> Serhiy Storchaka added the comment:
> 
> > have exactly the same size
> 
> Binaries contain paddings.

I used the "size" command, which gives you the exact size of the various sections
(rather than the physical file size).
msg195084 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-08-13 16:08
+1  The era of "register" has passed.
msg195087 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-08-13 18:04
Is PCC used by any Linux or BSD distro? BSD prefers Clang.
msg195089 - (view) Author: Roundup Robot (python-dev) Date: 2013-08-13 18:20
New changeset e7f6cef7a4cc by Antoine Pitrou in branch 'default':
Issue #18722: Remove uses of the "register" keyword in C code.
http://hg.python.org/cpython/rev/e7f6cef7a4cc
msg195090 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-13 18:21
Committed. I don't think clang or MSVC would bother more than gcc does.
msg262554 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-03-28 05:14
I did a review of some of the changes in <https://bugs.python.org/issue26130#msg258346>. In particular, there are a couple of comments /* Help register allocation */ which were mangled to /* Help allocation */.

But it is not clear if the leftover variable copies are still helping (in which case the comments should be reverted), or if the copies and comments can be removed.
msg262556 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-28 05:28
Agree that comments like /* Help allocation */ are confused and misleading.
History
Date User Action Args
2016-03-28 05:28:11serhiy.storchakasetmessages: + msg262556
2016-03-28 05:14:51martin.pantersetnosy: + martin.panter
messages: + msg262554
2013-08-13 18:21:10pitrousetstatus: open -> closed
resolution: fixed
messages: + msg195090

stage: patch review -> resolved
2013-08-13 18:20:32python-devsetnosy: + python-dev
messages: + msg195089
2013-08-13 18:04:44vstinnersetmessages: + msg195087
2013-08-13 16:08:27rhettingersetnosy: + rhettinger
messages: + msg195084
2013-08-13 11:18:04Arfreversetnosy: + Arfrever
2013-08-13 08:29:12pitrousetmessages: + msg195054
2013-08-13 08:24:04serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg195053
2013-08-13 07:49:17mark.dickinsonsetmessages: + msg195050
2013-08-12 22:05:08vstinnersetnosy: + vstinner
messages: + msg195029
2013-08-12 22:00:51pitrousetmessages: + msg195028
2013-08-12 21:59:22pitrousetnosy: + mark.dickinson, skrah
2013-08-12 21:46:47pitrousetmessages: + msg195025
2013-08-12 21:46:11pitroucreate