Re: Move PinBuffer and UnpinBuffer to atomics
От | Alvaro Herrera |
---|---|
Тема | Re: Move PinBuffer and UnpinBuffer to atomics |
Дата | |
Msg-id | 20160328153843.GA750908@alvherre.pgsql обсуждение исходный текст |
Ответ на | Re: Move PinBuffer and UnpinBuffer to atomics (Andres Freund <andres@anarazel.de>) |
Список | pgsql-hackers |
Andres Freund wrote: > On 2016-03-28 15:46:43 +0300, Alexander Korotkov wrote: > > @@ -932,8 +936,13 @@ ReadBuffer_common(SMgrRelation smgr, cha > > > > if (isLocalBuf) > > { > > - /* Only need to adjust flags */ > > - bufHdr->flags |= BM_VALID; > > + /* > > + * Only need to adjust flags. Since it's local buffer, there is no > > + * concurrency. We assume read/write pair to be cheaper than atomic OR. > > + */ > > + uint32 state = pg_atomic_read_u32(&bufHdr->state); > > + state |= BM_VALID; > > + pg_atomic_write_u32(&bufHdr->state, state); > > I'm not a fan of repeating that comment in multiple places. Hm. Perhaps a set of macros should be offered that do "read, set some flag, write". Then the comments can be attached to the macro instead of to each callsite. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
В списке pgsql-hackers по дате отправления: