enable-linux-huge-pages.patch

text/x-patch

Filename: enable-linux-huge-pages.patch
Type: text/x-patch
Part: 0
Message: Report: Linux huge pages with Postgres

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
src/backend/port/sysv_shmem.c 12 0
*** src/backend/port/sysv_shmem.c.orig	Wed Sep 22 18:57:31 2010
--- src/backend/port/sysv_shmem.c	Sat Nov 27 13:39:46 2010
***************
*** 33,38 ****
--- 33,39 ----
  #include "miscadmin.h"
  #include "storage/ipc.h"
  #include "storage/pg_shmem.h"
+ #include "storage/shmem.h"
  
  
  typedef key_t IpcMemoryKey;		/* shared memory key passed to shmget(2) */
***************
*** 75,80 ****
--- 76,92 ----
  	IpcMemoryId shmid;
  	void	   *memAddress;
  
+ #ifdef SHM_HUGETLB
+ 	/* request must be multiple of page size, else shmat() will fail */
+ #define HUGE_PAGE_SIZE (2 * 1024 * 1024)
+ 	size = add_size(size, HUGE_PAGE_SIZE - (size % HUGE_PAGE_SIZE));
+ 
+ 	shmid = shmget(memKey, size,
+ 				   SHM_HUGETLB | IPC_CREAT | IPC_EXCL | IPCProtection);
+ 	if (shmid >= 0)
+ 		elog(LOG, "shmget with SHM_HUGETLB succeeded");
+ 	else
+ #endif
  	shmid = shmget(memKey, size, IPC_CREAT | IPC_EXCL | IPCProtection);
  
  	if (shmid < 0)