This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients methane, pitrou, python-dev, serhiy.storchaka, vstinner, yselivanov
Date 2016-11-15.11:56:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1479210996.84.0.948834895663.issue28618@psf.upfronthosting.co.za>
In-reply-to
Content
> I don't understand well the effect of the hot attribute

I compared lookdict_unicode_nodummy assembly by `objdump -d dictobject.o`.
It looks completely same.

So I think only difference is placement. hot functions are in .text.hot section and linker
groups hot functions. This reduces cache hazard possibility.

When compiling Python with PGO, we can see what function is hot by objdump.

```
~/work/cpython/Objects$ objdump -tj .text.hot dictobject.o

dictobject.o:     file format elf64-x86-64

SYMBOL TABLE:
0000000000000000 l    d  .text.hot      0000000000000000 .text.hot
00000000000007a0 l     F .text.hot      0000000000000574 lookdict_unicode_nodummy
00000000000046d0 l     F .text.hot      00000000000000e8 free_keys_object
00000000000001c0 l     F .text.hot      0000000000000161 new_keys_object
00000000000003b0 l     F .text.hot      00000000000003e8 insertdict
0000000000001180 l     F .text.hot      000000000000081f dictresize
00000000000019a0 l     F .text.hot      0000000000000165 find_empty_slot.isra.0
0000000000002180 l     F .text.hot      00000000000005f1 lookdict
0000000000001b10 l     F .text.hot      00000000000000c2 unicode_eq
0000000000002780 l     F .text.hot      0000000000000184 dict_traverse
0000000000004c20 l     F .text.hot      00000000000005f7 lookdict_unicode
0000000000006b20 l     F .text.hot      0000000000000330 lookdict_split
...
```

cold section of hot function is placed in .text.unlikely section.

```
$ objdump -t  dictobject.o  | grep lookdict
00000000000007a0 l     F .text.hot      0000000000000574 lookdict_unicode_nodummy
0000000000002180 l     F .text.hot      00000000000005f1 lookdict
000000000000013e l       .text.unlikely 0000000000000000 lookdict_unicode_nodummy.cold.6
0000000000000a38 l       .text.unlikely 0000000000000000 lookdict.cold.15
0000000000004c20 l     F .text.hot      00000000000005f7 lookdict_unicode
0000000000006b20 l     F .text.hot      0000000000000330 lookdict_split
0000000000001339 l       .text.unlikely 0000000000000000 lookdict_unicode.cold.28
0000000000001d01 l       .text.unlikely 0000000000000000 lookdict_split.cold.42
```

All lookdict* function are put in hot section, and all of cold part is 0 byte.
It seems PGO put all lookdict* functions in hot section.

compiler info:
```
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
```
History
Date User Action Args
2016-11-15 11:56:36methanesetrecipients: + methane, pitrou, vstinner, python-dev, serhiy.storchaka, yselivanov
2016-11-15 11:56:36methanesetmessageid: <1479210996.84.0.948834895663.issue28618@psf.upfronthosting.co.za>
2016-11-15 11:56:36methanelinkissue28618 messages
2016-11-15 11:56:34methanecreate