Hi All, In a *very* quick patch I tested using huge pages/MAP_HUGETLB for the mmap'ed memory. That gives around 9.5% performance benefit in a read-only pgbench run (-n -S - j 64 -c 64 -T 10 -M prepared, scale 200, 6GB s_b, 8 cores, 24GB mem).
It also saves a bunch of memory per process due to the smaller page table (shared_buffers 6GB): cat /proc/$pid_of_pg_backend/status |grep VmPTE VmPTE: 6252 kB vs VmPTE: 60 kB Additionally it has the advantage that top/ps/... output under linux now looks like: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 10603 andres 20 0 6381m 4924 1952 R 21 0.0 0:28.04 postgres i.e. RES now actually shows something usable... Which is rather nice imo. I don't have the time atm into making this something useable, maybe somebody else want to pick it up? Looks pretty worthwile investing some time. Because of the required setup we sure cannot make this the default but... Greetings, Andres -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index e040400..05bbdf6 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -54,7 +54,7 @@ typedef int IpcMemoryId; /* shared memory ID returned by shmget(2) */ #define MAP_HASSEMAPHORE 0 #endif -#define PG_MMAP_FLAGS (MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE) +#define PG_MMAP_FLAGS (MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE|MAP_HUGETLB) /* Some really old systems don't define MAP_FAILED. */ #ifndef MAP_FAILED @@ -407,6 +407,10 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) { long pagesize = sysconf(_SC_PAGE_SIZE); + /* round up to hugetlb size on x86-64 linux */ + if(pagesize < (1024*2048)) + pagesize = 1024*2048; + /* * Ensure request size is a multiple of pagesize. *
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers