pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Simplify LWLock tranche machinery by removing array_base/array_s
5+ messages / 3 participants
[nested] [flat]

* pgsql: Simplify LWLock tranche machinery by removing array_base/array_s
@ 2016-12-16 16:41 Robert Haas <rhaas@postgresql.org>
  2016-12-21 07:14 ` Re: pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Robert Haas @ 2016-12-16 16:41 UTC (permalink / raw)
  To: pgsql-committers

Simplify LWLock tranche machinery by removing array_base/array_stride.

array_base and array_stride were added so that we could identify the
offset of an LWLock within a tranche, but this facility is only very
marginally used apart from the main tranche.  So, give every lock in
the main tranche its own tranche ID and get rid of array_base,
array_stride, and all that's attached.  For debugging facilities
(Trace_lwlocks and LWLOCK_STATS) print the pointer address of the
LWLock using %p instead of the offset.  This is arguably more useful,
and certainly a lot cheaper.  Drop the offset-within-tranche from
the information reported to dtrace and from one can't-happen message
inside lwlock.c.

The main user-visible impact of this change is that pg_stat_activity
will now report all waits for LWLocks as "LWLock" rather than
reporting some as "LWLockTranche" and others as "LWLockNamed".

The main motivation for this change is that the need to specify an
array_base and an array_stride is awkward for parallel query.  There
is only a very limited supply of tranche IDs so we can't just keep
allocating new ones, and if we try to use the same tranche IDs every
time then we run into trouble when multiple parallel contexts are
use simultaneously.  So if we didn't get rid of this mechanism we'd
have to make it even more complicated.  By simplifying it in this
way, we instead reduce the size of the generated code for lwlock.c
by about 5%.

Discussion: http://postgr.es/m/CA+TgmoYsFn6NUW1x0AZtupJGUAs1UDY4dJtCN47_Q6D0sP80PA@mail.gmail.com

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/3761fe3c20bb040b15f0e8da58d824631da00caa

Modified Files
--------------
doc/src/sgml/monitoring.sgml             |  52 ++++-----
src/backend/access/transam/slru.c        |   6 +-
src/backend/access/transam/xlog.c        |   9 +-
src/backend/postmaster/pgstat.c          |  10 +-
src/backend/replication/logical/origin.c |   8 +-
src/backend/replication/slot.c           |   8 +-
src/backend/storage/buffer/buf_init.c    |  16 +--
src/backend/storage/ipc/procarray.c      |   9 +-
src/backend/storage/lmgr/lwlock.c        | 175 ++++++++++---------------------
src/backend/utils/mmgr/dsa.c             |  15 +--
src/backend/utils/probes.d               |  16 +--
src/include/access/slru.h                |   1 -
src/include/pgstat.h                     |   3 +-
src/include/storage/lwlock.h             |  45 ++------
14 files changed, 112 insertions(+), 261 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Simplify LWLock tranche machinery by removing array_base/array_s
  2016-12-16 16:41 pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Robert Haas <rhaas@postgresql.org>
@ 2016-12-21 07:14 ` Pavel Stehule <pavel.stehule@gmail.com>
  2016-12-21 12:54   ` Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Pavel Stehule @ 2016-12-21 07:14 UTC (permalink / raw)
  To: Robert Haas <rhaas@postgresql.org>; +Cc: pgsql-committers

Hi

Is there some help for extensions developers, how to fix extensions after
this change?

Orafce hits this change.

Regards

Pavel

2016-12-16 17:41 GMT+01:00 Robert Haas <rhaas@postgresql.org>:

> Simplify LWLock tranche machinery by removing array_base/array_stride.
>
> array_base and array_stride were added so that we could identify the
> offset of an LWLock within a tranche, but this facility is only very
> marginally used apart from the main tranche.  So, give every lock in
> the main tranche its own tranche ID and get rid of array_base,
> array_stride, and all that's attached.  For debugging facilities
> (Trace_lwlocks and LWLOCK_STATS) print the pointer address of the
> LWLock using %p instead of the offset.  This is arguably more useful,
> and certainly a lot cheaper.  Drop the offset-within-tranche from
> the information reported to dtrace and from one can't-happen message
> inside lwlock.c.
>
> The main user-visible impact of this change is that pg_stat_activity
> will now report all waits for LWLocks as "LWLock" rather than
> reporting some as "LWLockTranche" and others as "LWLockNamed".
>
> The main motivation for this change is that the need to specify an
> array_base and an array_stride is awkward for parallel query.  There
> is only a very limited supply of tranche IDs so we can't just keep
> allocating new ones, and if we try to use the same tranche IDs every
> time then we run into trouble when multiple parallel contexts are
> use simultaneously.  So if we didn't get rid of this mechanism we'd
> have to make it even more complicated.  By simplifying it in this
> way, we instead reduce the size of the generated code for lwlock.c
> by about 5%.
>
> Discussion: http://postgr.es/m/CA+TgmoYsFn6NUW1x0AZtupJGUAs1UDY4
> dJtCN47_Q6D0sP80PA@mail.gmail.com
>
> Branch
> ------
> master
>
> Details
> -------
> http://git.postgresql.org/pg/commitdiff/3761fe3c20bb040b15f0e8da58d824
> 631da00caa
>
> Modified Files
> --------------
> doc/src/sgml/monitoring.sgml             |  52 ++++-----
> src/backend/access/transam/slru.c        |   6 +-
> src/backend/access/transam/xlog.c        |   9 +-
> src/backend/postmaster/pgstat.c          |  10 +-
> src/backend/replication/logical/origin.c |   8 +-
> src/backend/replication/slot.c           |   8 +-
> src/backend/storage/buffer/buf_init.c    |  16 +--
> src/backend/storage/ipc/procarray.c      |   9 +-
> src/backend/storage/lmgr/lwlock.c        | 175
> ++++++++++---------------------
> src/backend/utils/mmgr/dsa.c             |  15 +--
> src/backend/utils/probes.d               |  16 +--
> src/include/access/slru.h                |   1 -
> src/include/pgstat.h                     |   3 +-
> src/include/storage/lwlock.h             |  45 ++------
> 14 files changed, 112 insertions(+), 261 deletions(-)
>
>
> --
> Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-committers
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s
  2016-12-16 16:41 pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Robert Haas <rhaas@postgresql.org>
  2016-12-21 07:14 ` Re: pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Pavel Stehule <pavel.stehule@gmail.com>
@ 2016-12-21 12:54   ` Robert Haas <robertmhaas@gmail.com>
  2016-12-21 13:00     ` Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Robert Haas @ 2016-12-21 12:54 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On Wed, Dec 21, 2016 at 2:14 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Is there some help for extensions developers, how to fix extensions after
> this change?
>
> Orafce hits this change.

array_base and array_stride are gone; don't pass them.  The second
argument to LWLockRegisterTranche() is now the tranche name.  Pass
that instead of a structure.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s
  2016-12-16 16:41 pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Robert Haas <rhaas@postgresql.org>
  2016-12-21 07:14 ` Re: pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Pavel Stehule <pavel.stehule@gmail.com>
  2016-12-21 12:54   ` Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Robert Haas <robertmhaas@gmail.com>
@ 2016-12-21 13:00     ` Pavel Stehule <pavel.stehule@gmail.com>
  2016-12-23 08:17       ` Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Pavel Stehule @ 2016-12-21 13:00 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

2016-12-21 13:54 GMT+01:00 Robert Haas <robertmhaas@gmail.com>:

> On Wed, Dec 21, 2016 at 2:14 AM, Pavel Stehule <pavel.stehule@gmail.com>
> wrote:
> > Is there some help for extensions developers, how to fix extensions after
> > this change?
> >
> > Orafce hits this change.
>
> array_base and array_stride are gone; don't pass them.  The second
> argument to LWLockRegisterTranche() is now the tranche name.  Pass
> that instead of a structure.
>

Thank you

Pavel

>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s
  2016-12-16 16:41 pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Robert Haas <rhaas@postgresql.org>
  2016-12-21 07:14 ` Re: pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Pavel Stehule <pavel.stehule@gmail.com>
  2016-12-21 12:54   ` Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Robert Haas <robertmhaas@gmail.com>
  2016-12-21 13:00     ` Re: [COMMITTERS] pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Pavel Stehule <pavel.stehule@gmail.com>
@ 2016-12-23 08:17       ` Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Pavel Stehule @ 2016-12-23 08:17 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

2016-12-21 14:00 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:

>
>
> 2016-12-21 13:54 GMT+01:00 Robert Haas <robertmhaas@gmail.com>:
>
>> On Wed, Dec 21, 2016 at 2:14 AM, Pavel Stehule <pavel.stehule@gmail.com>
>> wrote:
>> > Is there some help for extensions developers, how to fix extensions
>> after
>> > this change?
>> >
>> > Orafce hits this change.
>>
>> array_base and array_stride are gone; don't pass them.  The second
>> argument to LWLockRegisterTranche() is now the tranche name.  Pass
>> that instead of a structure.
>>
>
> Thank you
>

It is working - for record the necessary changes in Orafce
https://github.com/orafce/orafce/commit/cac48984458c24d92243a7d4df549409dec0b826

Regards

Pavel


> Pavel
>
>>
>> --
>> Robert Haas
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2016-12-23 08:17 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 16:41 pgsql: Simplify LWLock tranche machinery by removing array_base/array_s Robert Haas <rhaas@postgresql.org>
2016-12-21 07:14 ` Pavel Stehule <pavel.stehule@gmail.com>
2016-12-21 12:54   ` Robert Haas <robertmhaas@gmail.com>
2016-12-21 13:00     ` Pavel Stehule <pavel.stehule@gmail.com>
2016-12-23 08:17       ` Pavel Stehule <pavel.stehule@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox