[PATCH] Address false sharing on x86_64 and i386 in BufferStrategyControl

Поиск
Список
Период
Сортировка
От Tekchandani, Nitin
Тема [PATCH] Address false sharing on x86_64 and i386 in BufferStrategyControl
Дата
Msg-id MW5PR11MB590630852DAF15D17DCF21F7E9DBA@MW5PR11MB5906.namprd11.prod.outlook.com
обсуждение исходный текст
Список pgsql-hackers
This patch resolves false sharing observed when running Postgres in a Docker container against sysbench.
False sharing was observed in freelist.c in the BufferStrategyControl struct.
As the size slock_t is platform dependent, and testing was done on an Intel Xeon scalable platform, the changes
are made conditionally similar to how slock_t is defined.

This patch is against master.

As the patch involves only data structure padding, I do not believe any new regression tests are required.

False sharing has a negative impact on performance, this patch resolves false sharing in the BufferStrategyControl
struct.

To verify this, I ran sysbench on the host against a running postgres docker instance like so:

sysbench --db-driver=pgsql --report-interval=2 --table-size=100000 --tables=25 --threads=70 --time=60
--pgsql-host=127.0.0.1--pgsql-port=5432 --pgsql-user=postgres --pgsql-password=password --pgsql-db=postgres
/usr/share/sysbench/oltp_read_only.luaprepare 

sysbench --db-driver=pgsql --report-interval=2 --table-size=100000 --tables=25 --threads=70 --time=60
--pgsql-host=127.0.0.1--pgsql-port=5432 --pgsql-user=postgres --pgsql-password=password --pgsql-db=postgres
/usr/share/sysbench/oltp_read_only.luarun 

During the run phase, I ran perf like so:

sudo perf c2c record -a -u --ldlat 50 -- sleep 30

After the runs I post processed the perf data like this:

sudo perf c2c report -NN -g --call-graph --full-symbols -c pid,iaddr --stdio >perf_report.txt

You can observe the changes in the attached perf_report files.  Note the strategygetbuffer function in cacheline 1 in
thebase report, it goes to cacheline 4 in the fix report.  In the report prior to the fix (base) we can observe
multipleoffsets within the same cacheline and after the fix there is a single offset. 

---
Nitin Tekchandani
nitin.tekchandani@intel.com


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: LLVM 16 (opaque pointers)
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Server crash on RHEL 9/s390x platform against PG16