Re: remap the .text segment into huge pages at run time

2023-06-21 Thread John Naylor
On Wed, Jun 21, 2023 at 10:42 AM Andres Freund wrote: > So I am wondering if you're encountering a different kind of problem. As I > mentioned, I have observed that the pages need to be clean for this to > work. For me adding a "sync path/to/postgres" makes it work on 6.3.8. Without > the sync

Re: remap the .text segment into huge pages at run time

2023-06-20 Thread Andres Freund
Hi, On 2023-06-21 09:35:36 +0700, John Naylor wrote: > On Wed, Jun 21, 2023 at 12:46 AM Andres Freund wrote: > > > > Hi, > > > > On 2023-06-20 10:29:41 -0700, Andres Freund wrote: > > > On 2023-06-20 10:23:14 +0700, John Naylor wrote: > > > > Here's a start at that, trying with postmaster only.

Re: remap the .text segment into huge pages at run time

2023-06-20 Thread John Naylor
On Wed, Jun 21, 2023 at 12:46 AM Andres Freund wrote: > > Hi, > > On 2023-06-20 10:29:41 -0700, Andres Freund wrote: > > On 2023-06-20 10:23:14 +0700, John Naylor wrote: > > > Here's a start at that, trying with postmaster only. Unfortunately, I get > > > "MADV_COLLAPSE failed: Invalid argument".

Re: remap the .text segment into huge pages at run time

2023-06-20 Thread Andres Freund
Hi, On 2023-06-20 10:29:41 -0700, Andres Freund wrote: > On 2023-06-20 10:23:14 +0700, John Naylor wrote: > > Here's a start at that, trying with postmaster only. Unfortunately, I get > > "MADV_COLLAPSE failed: Invalid argument". > > I also see that. But depending on the steps, I also see >

Re: remap the .text segment into huge pages at run time

2023-06-20 Thread Andres Freund
Hi, On 2023-06-20 10:23:14 +0700, John Naylor wrote: > Here's a start at that, trying with postmaster only. Unfortunately, I get > "MADV_COLLAPSE failed: Invalid argument". I also see that. But depending on the steps, I also see MADV_COLLAPSE failed: Resource temporarily unavailable I suspect

Re: remap the .text segment into huge pages at run time

2023-06-19 Thread John Naylor
On Wed, Jun 14, 2023 at 12:40 PM John Naylor wrote: > > On Sat, Nov 5, 2022 at 3:27 PM Andres Freund wrote: > > 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

Re: remap the .text segment into huge pages at run time

2023-06-14 Thread Andres Freund
Hi, On 2023-06-14 12:40:18 +0700, John Naylor wrote: > On Sat, Nov 5, 2022 at 3:27 PM Andres Freund 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 > >

Re: remap the .text segment into huge pages at run time

2023-06-13 Thread John Naylor
On Sat, Nov 5, 2022 at 3:27 PM Andres Freund 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

Re: remap the .text segment into huge pages at run time

2022-11-06 Thread Andres Freund
Hi, On 2022-11-06 13:56:10 +0700, John Naylor wrote: > On Sat, Nov 5, 2022 at 3:27 PM Andres Freund wrote: > > I don't think the dummy functions are a good approach, there were plenty > > things after it when I played with them. > > To be technical, the point wasn't to have no code after it, but

Re: remap the .text segment into huge pages at run time

2022-11-06 Thread John Naylor
On Sat, Nov 5, 2022 at 3:27 PM Andres Freund wrote: > > simplified it. Interestingly enough, looking through the commit history, > > they used to align the segments via linker flags, but took it out here: > > > > https://github.com/intel/iodlr/pull/25#discussion_r397787559 > > > > ...saying "I'm

Re: remap the .text segment into huge pages at run time

2022-11-05 Thread Andres Freund
Hi, On 2022-11-05 12:54:18 +0700, John Naylor wrote: > On Sat, Nov 5, 2022 at 1:33 AM Andres Freund wrote: > > I hacked in a MADV_COLLAPSE (with setarch -R, so that I could just > hardcode > > the address / length), and it seems to work nicely. > > > > With the weird caveat that on fs one needs

Re: remap the .text segment into huge pages at run time

2022-11-04 Thread John Naylor
On Sat, Nov 5, 2022 at 1:33 AM Andres Freund wrote: > > I wonder how far we can get with just using the linker hints to align > > sections. I know that the linux folks are working on promoting sufficiently > > aligned executable pages to huge pages too, and might have succeeded already. > > > >

Re: remap the .text segment into huge pages at run time

2022-11-04 Thread Andres Freund
Hi, On 2022-11-03 10:21:23 -0700, Andres Freund wrote: > > - Add a "cold" __asm__ filler function that just takes up space, enough to > > push the end of the .text segment over the next aligned boundary, or to > > ~8MB in size. > > I don't understand why this is needed - as long as the pages are

Re: remap the .text segment into huge pages at run time

2022-11-04 Thread Andres Freund
Hi, This nerd-sniped me badly :) On 2022-11-03 10:21:23 -0700, Andres Freund wrote: > On 2022-11-02 13:32:37 +0700, John Naylor wrote: > > I found an MIT-licensed library "iodlr" from Intel [3] that allows one to > > remap the .text segment to huge pages at program start. Attached is a > >

Re: remap the .text segment into huge pages at run time

2022-11-03 Thread Andres Freund
Hi, On 2022-11-02 13:32:37 +0700, John Naylor wrote: > It's been known for a while that Postgres spends a lot of time translating > instruction addresses, and using huge pages in the text segment yields a > substantial performance boost in OLTP workloads [1][2]. Indeed. Some of that we

remap the .text segment into huge pages at run time

2022-11-02 Thread John Naylor
It's been known for a while that Postgres spends a lot of time translating instruction addresses, and using huge pages in the text segment yields a substantial performance boost in OLTP workloads [1][2]. The difficulty is, this normally requires a lot of painstaking work (unless your OS does