Re: remap the .text segment into huge pages at run time
От | John Naylor |
---|---|
Тема | Re: remap the .text segment into huge pages at run time |
Дата | |
Msg-id | CAFBsxsEW1fTbhciaGQM1FtJsKtidJG1QGs79nVEny4SZnpjEyg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: remap the .text segment into huge pages at run time (Andres Freund <andres@anarazel.de>) |
Ответы |
Re: remap the .text segment into huge pages at run time
Re: remap the .text segment into huge pages at run time |
Список | pgsql-hackers |
On Sat, Nov 5, 2022 at 3:27 PM Andres Freund <andres@anarazel.de> wrote:
> /*
> * Make huge pages out of it. Requires at least linux 6.1. We could
> * fall back to MADV_HUGEPAGE if it fails, but it doesn't do all that
> * much in older kernels.
> */
> #define MADV_COLLAPSE 25
> r = madvise(addr, advlen, MADV_COLLAPSE);
> if (r != 0)
> fprintf(stderr, "MADV_COLLAPSE failed: %m\n");
>
>
> A real version would have to open /proc/self/maps and do this for at least
> postgres' r-xp mapping. We could do it for libraries too, if they're suitably
> aligned (both in memory and on-disk).
Hi Andres, my kernel has been new enough for a while now, and since TLBs and context switches came up in the thread on... threads, I'm swapping this back in my head.
For the postmaster, it should be simple to have a function that just takes the address of itself, then parses /proc/self/maps to find the boundaries within which it lies. I haven't thought about libraries much. Though with just the postmaster it seems that would give us the biggest bang for the buck?
--
John Naylor
EDB: http://www.enterprisedb.com
> /*
> * Make huge pages out of it. Requires at least linux 6.1. We could
> * fall back to MADV_HUGEPAGE if it fails, but it doesn't do all that
> * much in older kernels.
> */
> #define MADV_COLLAPSE 25
> r = madvise(addr, advlen, MADV_COLLAPSE);
> if (r != 0)
> fprintf(stderr, "MADV_COLLAPSE failed: %m\n");
>
>
> A real version would have to open /proc/self/maps and do this for at least
> postgres' r-xp mapping. We could do it for libraries too, if they're suitably
> aligned (both in memory and on-disk).
Hi Andres, my kernel has been new enough for a while now, and since TLBs and context switches came up in the thread on... threads, I'm swapping this back in my head.
For the postmaster, it should be simple to have a function that just takes the address of itself, then parses /proc/self/maps to find the boundaries within which it lies. I haven't thought about libraries much. Though with just the postmaster it seems that would give us the biggest bang for the buck?
--
John Naylor
EDB: http://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: