-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not allocate shared memory for wal_redo process #165
Conversation
I did a somewhat similar thing while playing with WASM, but one level up https://gist.github.com/kelvich/d0afaf4192574a3fc196263d441e6c04 I think a more clear approach would be to implement |
shmdt is any case not enabled in secomp mode:
IMHO providing special implementation of PG shared memory (local_shmem.c) just for wal redo is overkill. Also it may be not so convenient to build two different versions of postgres binaries. It is also possible to add pecial type for From my point of view adding two lines of Neon specific code is better than other alternatives requiring more invasive changes of postgres core. |
@@ -155,6 +155,8 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size) | |||
} | |||
} | |||
#endif | |||
if (am_wal_redo_postgres) | |||
return valloc(size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to look up what valloc
is, never heard of that before :-).
Why not malloc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valloc returns address aligned on page boundary. It may affect alignment of some Postgres data structures. Not sure that it is critical for wal redo. But I thought that it will be better to preserve alignement.
I agree with Stas' earlier comment that this needs a NULL check. If the valloc() call fails and returns NULL, I think this will retry the valloc() call in an infinite loop. I also think we should replace the valloc() with plain malloc(). There is no reason for the allocation to be page-aligned. BTW, with the default settings, this is only used to replace the tiny shmem shim allocation. Most of the shared memory is still allocated with the mmap() call. I think that's OK, as that codepath also does some tricks to make huge pages effective, which probably makes sense for the WAL redo process, too. |
I do not think that we should eliminate mmaps, because even malloc is using it internally. |
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
* Do not allocate shared memory for wal_redo process * Add comment
No description provided.