Re: O_DIRECT on macOS

2021-07-19 Thread Thomas Munro
On Tue, Jul 20, 2021 at 12:26 PM Tom Lane wrote: > > I can try that on the gcc farm in a bit. Thanks! > Hmm, it compiles cleanly, but something seems drastically wrong, > because performance is just awful. On the other hand, I don't > know what sort of storage is underlying this instance, so

Re: O_DIRECT on macOS

2021-07-19 Thread Tom Lane
I wrote: > Thomas Munro writes: >> While I was here again, I couldn't resist trying to extend this to >> Solaris, since it looked so easy. I don't have access, but I tested >> on Illumos by undefining O_DIRECT. Thoughts? > I can try that on the gcc farm in a bit. Hmm, it compiles cleanly, but

Re: O_DIRECT on macOS

2021-07-19 Thread Tom Lane
Thomas Munro writes: > While I was here again, I couldn't resist trying to extend this to > Solaris, since it looked so easy. I don't have access, but I tested > on Illumos by undefining O_DIRECT. Thoughts? I can try that on the gcc farm in a bit. regards, tom lane

Re: O_DIRECT on macOS

2021-07-19 Thread Thomas Munro
On Tue, Jul 20, 2021 at 2:13 AM Tom Lane wrote: > Hmm ... we used to have to avoid putting #if constructs in the arguments > of macros (such as StaticAssertStmt). Maybe that's not a thing anymore > with C99, and in any case this whole stanza is fairly platform-specific > so we may not run into a

Re: O_DIRECT on macOS

2021-07-19 Thread Tom Lane
Thomas Munro writes: > On Mon, Jul 19, 2021 at 4:42 PM Tom Lane wrote: >> prairiedog thinks that Assert is too optimistic about whether all >> those flags exist. > Fixed. Hmm ... we used to have to avoid putting #if constructs in the arguments of macros (such as StaticAssertStmt). Maybe

Re: O_DIRECT on macOS

2021-07-19 Thread John Naylor
On Mon, Jul 19, 2021 at 12:55 AM Thomas Munro wrote: > > On Mon, Jul 19, 2021 at 4:42 PM Tom Lane wrote: > > prairiedog thinks that Assert is too optimistic about whether all > > those flags exist. > > Fixed. > > (Huh, I received no -committers email for 2dbe8905.) It didn't show up in the

Re: O_DIRECT on macOS

2021-07-18 Thread Thomas Munro
On Mon, Jul 19, 2021 at 4:42 PM Tom Lane wrote: > prairiedog thinks that Assert is too optimistic about whether all > those flags exist. Fixed. (Huh, I received no -committers email for 2dbe8905.)

Re: O_DIRECT on macOS

2021-07-18 Thread Tom Lane
Thomas Munro writes: > Agreed. Pushed! prairiedog thinks that Assert is too optimistic about whether all those flags exist. regards, tom lane

Re: O_DIRECT on macOS

2021-07-18 Thread Thomas Munro
On Tue, Jul 13, 2021 at 1:56 PM Andres Freund wrote: > On 2021-07-13 13:25:50 +1200, Thomas Munro wrote: > > I'm planning to go with that idea (#1), if there are no objections. > > The only other viable approach I see is to completely separate our > internal flag representation from the OS

Re: O_DIRECT on macOS

2021-07-12 Thread Andres Freund
Hi, On 2021-07-13 13:25:50 +1200, Thomas Munro wrote: > On Mon, May 31, 2021 at 10:29 AM Thomas Munro wrote: > > For comparison, here is my sketch of idea #1. I pick an arbitrary > > value to use as PG_O_DIRECT (I don't want to define O_DIRECT for fear > > of breaking other code that might see

Re: O_DIRECT on macOS

2021-07-12 Thread Thomas Munro
On Mon, May 31, 2021 at 10:29 AM Thomas Munro wrote: > For comparison, here is my sketch of idea #1. I pick an arbitrary > value to use as PG_O_DIRECT (I don't want to define O_DIRECT for fear > of breaking other code that might see it and try to pass it into > open()... for all I know, it might

Re: O_DIRECT on macOS

2021-05-30 Thread Thomas Munro
On Mon, May 31, 2021 at 4:19 AM Justin Pryzby wrote: > Should there be an "else" to warn/error in the case that "direct" is requested > but not supported? The way we use O_DIRECT currently is extremely minimal, it's just "if you've got it, we'll use it, but otherwise not complain", and I wasn't

Re: O_DIRECT on macOS

2021-05-30 Thread Thomas Munro
On Mon, May 31, 2021 at 8:12 AM Andres Freund wrote: > On 2021-05-30 16:39:48 +1200, Thomas Munro wrote: > > I thought about a few different ways to encapsulate this API > > difference in PostgreSQL, and toyed with two: > > > > 1. We could define our own fake O_DIRECT flag, and translate that to

Re: O_DIRECT on macOS

2021-05-30 Thread Andres Freund
Hi, Thanks for starting the discussion on this! On 2021-05-30 16:39:48 +1200, Thomas Munro wrote: > I thought about a few different ways to encapsulate this API > difference in PostgreSQL, and toyed with two: > > 1. We could define our own fake O_DIRECT flag, and translate that to > the right

Re: O_DIRECT on macOS

2021-05-30 Thread Justin Pryzby
On Sun, May 30, 2021 at 04:39:48PM +1200, Thomas Munro wrote: > +BasicOpenFilePermDirect(const char *fileName, int fileFlags, mode_t fileMode, > + bool direct) > ... > +#if !defined(O_DIRECT) && defined(F_NOCACHE) > + /*

O_DIRECT on macOS

2021-05-29 Thread Thomas Munro
Hi, IRIX gave the world O_DIRECT, and then every Unix I've used followed their lead except Apple's, which gave the world fcntl(fd, F_NOCACHE, 1). From what I could find in public discussion, this API difference may stem from the caching policy being controlled at the per-file (vnode) level in