strange case of kernel performance regression (4.3.x and newer)

Started by Tomas Vondraover 9 years ago2 messages
#1Tomas Vondra
tomas.vondra@2ndquadrant.com
3 attachment(s)

Hi,

Over the past couple of days I've been doing a bit of benchmarking for
the "group clog" patch [1]/messages/by-id/CAA4eK1+8=X9mSNeVeHg_NqMsOR-XKsjuqrYzQf=iCsdh3U4EOA@mail.gmail.com, and I've ran into what I suspect might be a
fairly serious performance regression on newer kernels (essentially
4.3.0 and newer). I got to a point where I need help with further
investigation, testing on other systems etc.

The workload tested in the patch [1]/messages/by-id/CAA4eK1+8=X9mSNeVeHg_NqMsOR-XKsjuqrYzQf=iCsdh3U4EOA@mail.gmail.com is quite simple - a transaction
with 3 x SELECT FOR UPDATE queries and 2 x SAVEPOINT on unlogged tables.
The results (average tps from 5 x 5 minute runs, for 32 and 64 clients)
on multiple kernels look like this:

kernel 32 64
---------------------------------
3.19.8 48524 59291
4.1.33 47193 59574
4.2.8 48901 59877
4.3.0 32187 38970
4.3.6 31889 38815
4.4.0 31946 37702
4.4.23 31498 37724
4.5.5 31531 37351
4.7.6 32859 38490

Notice the sudden drop from ~50k to ~30k tps between 4.2.8 and 4.3.0
(for 32 clients) and from 60k to 40k (for 64 clients). See the attached
kernel-regression-e5-4620.png.

Those results are from a 4-socket machine, with e5-4620 CPUs, so 32
physical cores in total, 64 with HT. The CPU is v1 model (Sandy Bridge
EP, releases in 2012 and discontinued in Q2 2015), so not particularly
new or obsolete.

This is on scale 300, which easily fits into RAM on the machine. The
results are very stable and IMHO quite consistent.

I've also done some tests with regular pgbench (both read-only and
read-write), with WAL-logged tables, and the results are quite similar.

type kernel 32 64
--------------------------------------------
ro 3.19.8 55796 81563
4.4.23 38188 50983
--------------------------------------------
rw 3.19.8 32282 46234
4.4.23 23367 31311

I've tried to reproduce the issue on another machine, but without much
success. This machine however only has 2 sockets and much newer CPU
(e5-2620 v4, so Broadwell, released Q1 2016).

So it might be somewhat related to the older CPU, maybe a slightly
different kernel config, or something else.

If you have access to similar machines (2 or 4 sockets), it'd be very
helpful if you could repeat the benchmarks and report the results, to
confirm (or invalidate) my results.

The test scripts (and results), and kernel configs are available here:

https://bitbucket.org/tvondra/kernel-perf-regression

It's nothing fancy, mostly trivial shell scripts (you'll need to modify
some paths in those, I guess). Testing a single kernel version takes
roughly 1h.

Those are vanilla kernels, BTW - no customized distribution kernels with
extra patches, etc.

[1]: /messages/by-id/CAA4eK1+8=X9mSNeVeHg_NqMsOR-XKsjuqrYzQf=iCsdh3U4EOA@mail.gmail.com
/messages/by-id/CAA4eK1+8=X9mSNeVeHg_NqMsOR-XKsjuqrYzQf=iCsdh3U4EOA@mail.gmail.com

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

kernel-regression-e5-4620.pngimage/png; name=kernel-regression-e5-4620.pngDownload
regression-pgbench-ro.pngimage/png; name=regression-pgbench-ro.pngDownload
regression-pgbench-rw.pngimage/png; name=regression-pgbench-rw.pngDownload
�PNG


IHDR]T�)	pHYs��-z8-�IDATx���{XT������!Q�M#�
��A��aG0
;�u�����m�XI���j[k@0Ws2��l�,�"��J��$�f�j��{'F��V��]���5���q4���������3k�������^y��Yp��
�G�E4�"r
���\@C.�!���h�E4�"r
���\@C.�!���h�E4�"rW@@���g������'N���;�\��\���C]��p
���._��7�������o�����7o�c��~������FGG?���������\���[o�y��Fwq�\2������u����Cnnn\\��o�=b�����E��Y��?_v��/�����i��w��{����g���3**��.��"��m���w�}Fw1h:taO��������o�����qll���HL�\\�n]AAAbb��e�p�B����z���\�O����=������{��1c�,_����Z���o�.]����u���eee�'O������+�=���������|�'?���Y7n���~u�����0����8^��olnn������>��{�}��g#""��W^y����������N�>}���rd�_y�������da!������{<#9�4�^?u������w�}W��;v�������ne���X����o��������"����������H���~�3�<�wy>|�m��8qB2@�;7�|�\�[o����?5jTkk���+�Jj������r�4��������/��~L/�����������O?��w���C��j(�����;?�6���z5�%��������~���s�r>�����y���	&8p`��#G���w�c��KL�9&&f��-rw�,�P4
��%J��)I���>g��������7�
��^�:u�[o�5k�����i����:y���.������K}}}��o�f��d�����>*��o|�r��5DVV����e���_���� �!�����//�~:���}�����W��������j�K�K�r����s������#�\�4�6����eeeeTT���\�/�����b�����{�����
����;��#����.]�����^s�5����w^���:���g��|���%�7l� �,oq��\����EGG�������\�����?����_������%�,������x�	���\����O>)K
�-���cr7t<��?�����,�$'$#%�p���K]bl��Uk��u�%����?���2���<K�[j����6��*�����G�.I�����+V�����x.������n��$`d������o}�Q����
%::ZRY]��SOI��6�4�
=Y`�a�.���%oT.�u�]�����6R��J��k��u��_�5s�����Z�?��^>^�����L����e��KU����*Y����:�.��"������8�S�Lq�LK���Kb�������c,7S��1Y	%%%9�rg��u~-�g]���|������z��V��1;v��f<N;������[Y�8Z��o��I��T�x���������\��S�\����4�������� /��c��Gv���r^����3��q��9�wW��w�������0(�E��k���1�����Qc��9�I���a�����5�\��g��~*6z�h�i����e�c������.��W9S��g�hnn.((��+�����K��H�usCCCgg��T��9���?��?.������p��������K/�T\\,/��k���L�+=�����CEE���,�$����o�Y�F�V�����q��9��%K�^xa���*�9��R�[hh�{���\�yp���R�q�

��s��?��c�g����&�~uBnU���pz��������D�y������W���S�t���u�-����Ih�Tv��].��m����,����*���_���}-b���?�UW������w����ANg����6��3f����&�/W��z�(,,��}���h�����R:s�]�/�E�����������vs�M7�s�������HY�<��Cj��[o���N�4i��]��r����0{��>��������������*�o����+�]��v�������L//!K�{��G5q�Dy([K�����u��u����}����C//W��zS*++322���}�����w���#��l��~��}�r����+~��_��'>>�/���~����W�]���[�t��q�d�#��M�69�5l��U�V�;V�u��������zJ��-Z�`��
���o�B����{��w������333e�p��������������^��D�m���py�666�?��?���s��1�H����?������U��"y� ��{��-Y�D�����������Cy���~���o�L�����:X�V���������[�N���^>^��9����^z���?��0j�����f�=���j�����)������:[�r�s�r���'�����m����V�\��
��}�{r������'�f���/����������g�yF����1c����=��#�r+OJJZ�f�/=�GfJ���#G��jkk��,^}���������^xAn�r��������w�q�g�}6c������~�����_���%d����/�<����S�^T#U��$MZZ�\��>���k{�� n��I��?!�3Uu//W��W��I�'��w�)	z���K?�l�����?��8 �V�C�p�
����\��>��s���g��{�P���.��/��vww�~���)�<���o��o8�g9������,�n����v�se�5~h�cWOO����<y���e���������������s^Y������.�����h���	��x�;m�4y�u���s"1^~����dY��o������#16n�(Y�x��k��F���-���~ftSp!�E��%K��q�}}}��ee��!\v�E����Z^^~)����\@C.�!���h�E4�"r
���\@C.�!���h�E4�"��������f5^�`��5kd������m��-KMMMhh�^�c]o&�����':�\,..�Z����eee%%%EEEzE�u��(�����5j�K�������l6���gdd�`�X�X��	��������{������7FDDH���=,,L���mmmj������L����������'._��f�544H���/((H����Q3==��f��o.VUU���e�"##�888X�M����!!!^��z3��������~b����x�����w��	&6���?00P% ;;;cbb:::����=��f*			.����s^A��B�������8o�����9s�'&&�bZZZ]]��f�mjj������L����������K�N�:���B333KKK�Vkuu������L��������V���lnjj�����7�s�K�\@C.�!���h�E4�"r
���\@C.�!iU��������K3���� ����"#�m|����Fwa��������s���j��Yg��U�������x��k���AWWWvv��n�X,555���j�{]o&�_�����
�+'N�8t�PTT�s����j�������������f��u.n��y��I��owTd�7j�(�i������f�9===##��v�u��(~�������*--uT$���v���q����)������� <<����1���7�sq��#G�?~�s1999??�����/��l


R���
����e������^������tww�e�9�������5�c477�1��.������U�-Z�R���,[�,22R����%�d+_`!!!���u��JBB�KEB1%%e��	����#���Fwa������f��r|Y��o.�a�Hh�
r���&L6lX``��+�������8�{]o&�����o3$�y�������3���X�m�bZZZ]]��f�mjj���u��(���������.]�t����XXX���YZZj�Z������z3P.�\t,E\\\kk���������D���L�� �d�E4�"r
���\@C.�!���h�E4�"r���bUU��Y��txWWWvv��n�X,555���zE�u��(~���6lp�[�������������"�����L�����7O�4i����Jccc}}��lNOO���P������7��sQ�tUUU����J{{{XX��������=��f��o.���c������w.����@�===^��z3������n��,1��8���5�c477�1��.������U�-Z�R�l��|-���x)z���T\*�)))�{^��1u�6�$&&F�5�����R�s��8  @BKV�������111���j������L��E��fH(:�iiiuuu6�M����^��z3P�7=*,,���,--�Z����^��z3P.�\t,��lnjjr������7�2�E.r
���\@C.�!���h�E4�"r
���\@���x�������{�����[�n��IRLJJjnnV,X�f�tuuegg��v��RSS�&���f��o.��;7==}���������������':�<����j�������������f��u.fff>|����(�Q�F��lll���7������s���@��\�8���3g***�M�����YYY�w������qcDD�������d����8�{]o&����"��q�����C=LNN����8q����m6[CC�������d ����s��z3P�=O�>]^^����s�NyXUU����-���T���`	<�������8��^������tww�/����ht�hnn3b��]������W/\�0000''g�����w��	&6���_v��dgggLLLGGGtt���u��JBB�KEB1%%�b�!y�Zs��}��.���1�ltC�/K�����7K��l����[n�E���'19g����b��R������:�)���T���z3P�7��_����b���n�I��X^^.��K�N�:���B333KKK�Vkuu���u��(������v�������R4��MMM�Gp���@��\��#���h�E4�"r
����~�i�?���n}M�U|Z07 ?�������W��0��~5��������E.�!���h�E0��56So��]�'���ct���`����>9jtF��)�;8���������766v��u�&M�bWWWvv��n�X,555���zE�u��(���s��MOO��ukeee~~��}��X\\l�Zkkk���JJJ������z3P�:333�>s����Ulll���7���*�<=��f��o.J����3��MS��������wxxx[[������L��EE�������c�z���$����x)z���TZZZ���]�����un��7�u
g�����6�\:���F�`�S�����{q477��mt�����������yyy;w�������m������5�c�c]o�����R�PLII�������J�Q��
,���\s��}��.d���&����hk���/K�����W/\�0000''g���������������7�sq������6������[nQ������:)�655�K�c]o&�������sssW�Xq�M7�X333KKK�Vkuu������L�����X���R4��MMM�=��f��o.p���h�E4�"r
���\@C.�!���h�E4�"������������QQQ����'O�bRRRss���`��5k�����+;;�n�[,������P5���7�s1??���[�l��i����[[[�x���C�IR:�,..�Z����eee%%%EEEzu��(���3g��1cF```VVVAA�*��o��Q.3����fszzzFF�#���z3P�7����`��mS�LQc�E����w���o��1""B����aaa2okks���7�sQ���d�����&''���O�8q���6�M�������d ����s��z3������n��,1/��yu��qC^�pv����j�������kt�8u�����Gsss���Fw��`~\�o��x����~[f���g��}���x��>����SSS��];a�U���R�e��EFF�qpp��l�,$$��t���L%!!��"����r��%�V���&�P`�X��-��.p��1u�6��>5�	#$&&���5��Rg0sq��?���e�p���������s�^p.=zT2���L������{%#�
���������111������u��(���~�azzz{{���gee�>}���o��%�g�~�����������3gNqq�?�tHKK�����l����c�{]o&�`�bxx��}�~���H����K������UWW�={v�������e�W^^����t���S�VTT�]�������B�Z��,���z3P3e
��\���7o��O=����>{�G���w/����?dtf6�����'���f�f.~g������>����'�uM��M�8dtF��3]�?Lo0s�������~��o�<y��k��X,%%%��������|y�����0���7�v��M�\LKK�����q����'�{�������KpQ
f.~����������c�=����x|.�������?��#���[�v�T��\l������}}}�?�����g��p�f.������A< ��`��]w���.����������k_��jpr����;p�����G�]�vP���18��}�v�&%%m��mP�!����"�r�����������|����������'K���+;;�n�[,������P�����L���������o��e��M���W��Fqq��j���-+++)))**�+z���@��\�9s��3���


T�������l6���gdd�`�X�X��	����������m�2e������������6/E�u��(����| ��������/((H�����R�X��	�����������k�N�0AU���%�d������r�����L�����������x�N��������;y��lt������?1����-���>���^4����#F��7��q9z�hJJJYYYrr�������������7SIHHp�H(J������J�����5�G����,�����k���O���L���Mc��zu_�:���K�,�={��>�\LKK�����l���������L�������g��\�R=<x����
333KKK�V�LP�<=��f��o.�����fsSS�/E�u��(���\z�"r
���\@C.�!���h�E4�"r
���\@���XSS���;��III���j�`��5k�����+;;�n�[,yJhh���^��	�����k��}���={��x���C�EEE9����VkmmmYYYIIIQQ�^]o&�����={T�9e�7j�(��������f�9===##��v�u��(����E�������w���o��1""B����aaa2okksLv���@��\�(999??�����/��l


R���

��l{zz���z3������n��,1/�	�:~��!�k��'��F�`��~����0@oo��-�������;H���{G�6�o.��KUU�,[�,22R����%�d+_`!!!���u��JBB�KEB1%%�b��W%�V���&�P`6�03�	#X,�mw���k���O���L���Mc��zu_�:�Y.���w��	��
���TE	������������h�d���L��,������3g����������VWWg��d������^��	�����<P�Q^^����t���S�VTT�	���������V�����q���L��E��\T���Z[[]�f�����}�{]o&���"����\@C.�!���h�E4�"r
���\@C.���\���y������������l��n�Xdohh�^�c]o&�����]�������j[�������������"�����L���={��$s.666�����������l��z3P�7

�����aaa2okk�R�X��	�����Q___PP�d��������7Siii���v)��b��W��7�u
w�d���a����bt���5�c�:�w��Isss���Fw��e�q	�l��|-���x)z���T\*�)))��t��Zi:���C��<�t��&�`�XL��mt�9b�>mt2}jtFHLL4�
3��}Y�\f������������7�2�������:��&���T/E�u��(��������������V����ZM�X�X��	����������lnjj�����7�s�K�\@C.�!���h�E4�"r
���\@C.�!�\f���������,X�f��������v��b���	

=�"�Y.�8q���CQQQ����b��Z[[[VVVRRRTTt^E.�\���Q�\�������f�9===##C���E.�\�����{w||���#""����&������65��"�Y.&''���O�8q���6����A�}}}AAA2�mOO���{��,����`��e���j,�'��������-:���tww�/��xu��qC^�p'Ov����v��x�'Fwa�b4�c�:�w��Isss���Fw��e�q��w��	�
���������111����[tHHHp�H(���\��U�j���P\���#L��n���t��Fwa���#���Fwa��� ��F7a���D��0�^����e���������3gNqq�?/�������:��&�����-�p��byyynn���K�N�ZQQ�����������V�����|�8\f�����R4��MMM\��2�E.*r
���\@C.�!���h�E4�"r
���\@C.�Z�������m��-KMMMhh���������b��Z[[[VVVRRRTTdtG�2�r�������l6���gdd��C+������d���ft;�3�r���/((H����q��������R�%�%j��7����-���6�n����|��.����g���d3������kt�`����]���������7C+���%e�����7!!��"����r����:�_�:C+###;;;cbb:::����j����������:��&���T����������������V������v~gh���lnjj2���Z�x��7�R�SC�/����7��w��-���"|�T'���h�E4�"r
�#8p //o����������4i�>,�7�|3**���|���F�	|Q���6�m���_��W��y�������5k���g
l��Ei������[�n��������o�e0}��-[�l��i������F�	|Q�/$$������������w�����
��
.�EIr133s���3g�,((PE��1#000++�Q.k�����{���#Gfp�7o�<i������\��0�D�l��9SQQ1m�4U���S�m��M�2�������{�����III7�pCuu��7���%%%UUU�����g�"�'��q����������b��������t���}��:t��'�X�p���[�(����?~�����C.�x�O�.//�e���;Ue������k���0a����b��999�}��G#""Tq��U�-2�/x@.�H�W�������r�X�x�*=z4%%���,99�����r��7vww�~���+�����8   !!���&0�#m��Y��zee�-����K�,�={��>hlo� z���6m���SO9�H�������� a��������X����n��*VWW�=b��������nb\�� x��G����������K@��!a���X���R��!�OHH�+�������_!���h�E4�"r
���\@C.�!���h�E4�"r
���\@C.b�������~��1W]y�����������n��I�&�?������v��"�92g��={��{��/����lvy����;o��?�����z���;��m������y���M�"]jUUU�f����y�p��a9�7�|3**���|���&�N�#1��,{������#U"�j16w������[�VVV�������e��]����4�<���j������W�\YZZ�����\�������_�Z���o�6���'�S�iz�E����a����k��1}��-[�l��i������&N�r#W�^���9sfAA��Y;���?��,44455U����|��,1g���p��Aiu�������}��M�>g��!-eee9����|����+���9s���b��i���"  @�AAA����{e5)������w�}��jII���{�8!//O
�m�6e�5>��_n�"��,����c��[,�'�|��G]�n]oo���g�yf������������^{��w(��9r���<A���$}CC�s�|O�� �N�>]^^.+��;w�2�������x������*�	?����3f�����?��G��U�-Z�E&��������]�v��	���=}�K�\\�^�z������999�/��Y111��V�z����2�	�v�jll

�h��l_��?P��������=���G����H��������>��A.�6o����/�UYYy�-���������?���i��Y=���	���*	�����o�������X�<��q�	K�,�={��>�\����4�E!��;&�j���/��������X����n����H��5��*�Z�j�������[�f���6l� d)&��|X�1�b��P����=�KA�	��2X�r��<x0::Z���!�\������2-66�n���a�1u����#G�xyV||�;���S���mZ���LO����7���%p�;}`� ���h�E4�"r
���\@C.�!���h�E4�"r��w���T	P�IEND�B`�
#2Catalin Iacob
iacobcatalin@gmail.com
In reply to: Tomas Vondra (#1)
Re: strange case of kernel performance regression (4.3.x and newer)

On Wed, Oct 5, 2016 at 8:18 AM, Tomas Vondra
<tomas.vondra@2ndquadrant.com> wrote:

Over the past couple of days I've been doing a bit of benchmarking for the
"group clog" patch [1], and I've ran into what I suspect might be a fairly
serious performance regression on newer kernels (essentially 4.3.0 and
newer). I got to a point where I need help with further investigation,
testing on other systems etc.

The workload tested in the patch [1] is quite simple - a transaction with 3
x SELECT FOR UPDATE queries and 2 x SAVEPOINT on unlogged tables. The
results (average tps from 5 x 5 minute runs, for 32 and 64 clients) on
multiple kernels look like this:

kernel 32 64
---------------------------------
3.19.8 48524 59291
4.1.33 47193 59574
4.2.8 48901 59877
4.3.0 32187 38970
4.3.6 31889 38815
4.4.0 31946 37702
4.4.23 31498 37724
4.5.5 31531 37351
4.7.6 32859 38490

Just stumbled upon this old thread.

Since the regression is very clear and reproduceable and on a vanilla
kernel I don't think you need more testing. The kernel devs or at
least Linus take regressions (including performance) very seriously,
even if it's theoretically not the kernel's fault (so in this case
regardless what Postgres is doing).

I think you should just report it to lkml. If you have time to do a
bisection between 4.2.8 and 4.3.0 and find the offending commit that
would be even better, then email the author and CC lkml and Linus,
that should be enough to get it fixed.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers