Re: LogwrtResult contended spinlock
От | Alvaro Herrera |
---|---|
Тема | Re: LogwrtResult contended spinlock |
Дата | |
Msg-id | 202404031119.cd2kugjk2vho@alvherre.pgsql обсуждение исходный текст |
Ответ на | Re: LogwrtResult contended spinlock (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>) |
Ответы |
Re: LogwrtResult contended spinlock
Re: LogwrtResult contended spinlock Re: LogwrtResult contended spinlock |
Список | pgsql-hackers |
Thanks for keeping this moving forward. I gave your proposed patches a look. One thing I didn't like much is that we're adding a new member (Copy) to XLogwrtAtomic -- but this struct is supposed to be a mirror of XLogwrtResult for use with atomic access. Since this new member is not added to XLogwrtResult (because it's not needed there), the whole idea of there being symmetry between those two structs crumbles down. Because we later stop using struct-assign anyway, meaning we no longer need the structs to match, we can instead spell out the members in XLogCtl and call it a day. So what I do in the attached 0001 is stop using the XLogwrtResult struct in XLogCtl and replace it with separate Write and Flush values, and add the macro XLogUpdateLocalLogwrtResult() that copies the values of Write and Flush from the shared XLogCtl to the local variable given as macro argument. (I also added our idiomatic do {} while(0) to the macro definition, for safety). The new members are XLogCtl->logWriteResult and XLogCtl->logFlushResult and as of 0001 are just XLogRecPtr, so essentially identical semantics as the previous code. No atomic access yet! 0002 then adds pg_atomic_monotonic_advance_u64. (I don't add the _u32 variant, because I don't think it's a great idea to add dead code. If later we see a need for it we can put it in.) It also changes the two new members to be atomics, changes the macro to use atomic read, and XLogWrite now uses monotonic increment. A couple of other places can move the macro calls to occur outside the spinlock. Also, XLogWrite gains the invariant checking that involves Write and Flush. Finally, 0003 adds the Copy pointer to XLogCtl alongside Write and Flush, and updates WALReadFromBuffers to test that instead of the Write pointer, and adds in XLogWrite the invariant checks that involve the Copy pointer. I haven't rerun Bharath test loop yet; will do so shortly. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "You're _really_ hosed if the person doing the hiring doesn't understand relational systems: you end up with a whole raft of programmers, none of whom has had a Date with the clue stick." (Andrew Sullivan) https://postgr.es/m/20050809113420.GD2768@phlogiston.dyndns.org
Вложения
В списке pgsql-hackers по дате отправления: