postgresql/src/backend/utils/probes.d

95 lines
3.4 KiB
D
Raw Normal View History

/* ----------
* DTrace probes for PostgreSQL backend
*
* Copyright (c) 2006-2020, PostgreSQL Global Development Group
*
2010-09-20 22:08:53 +02:00
* src/backend/utils/probes.d
* ----------
*/
/*
* Typedefs used in PostgreSQL probes.
*
* NOTE: Do not use system-provided typedefs (e.g. uintptr_t, uint32_t, etc)
* in probe definitions, as they cause compilation errors on macOS.
*/
#define LocalTransactionId unsigned int
#define LWLockMode int
#define LOCKMODE int
#define BlockNumber unsigned int
#define Oid unsigned int
#define ForkNumber int
#define bool unsigned char
provider postgresql {
probe transaction__start(LocalTransactionId);
probe transaction__commit(LocalTransactionId);
probe transaction__abort(LocalTransactionId);
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
2016-12-16 17:29:23 +01:00
probe lwlock__acquire(const char *, LWLockMode);
probe lwlock__release(const char *);
probe lwlock__wait__start(const char *, LWLockMode);
probe lwlock__wait__done(const char *, LWLockMode);
probe lwlock__condacquire(const char *, LWLockMode);
probe lwlock__condacquire__fail(const char *, LWLockMode);
probe lwlock__acquire__or__wait(const char *, LWLockMode);
probe lwlock__acquire__or__wait__fail(const char *, LWLockMode);
probe lock__wait__start(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE);
probe lock__wait__done(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE);
probe query__parse__start(const char *);
probe query__parse__done(const char *);
probe query__rewrite__start(const char *);
probe query__rewrite__done(const char *);
probe query__plan__start();
probe query__plan__done();
probe query__execute__start();
probe query__execute__done();
probe query__start(const char *);
probe query__done(const char *);
probe statement__status(const char *);
probe sort__start(int, bool, int, int, bool, int);
probe sort__done(bool, long);
probe buffer__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid, int, bool);
probe buffer__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, bool, bool);
probe buffer__flush__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
probe buffer__flush__done(ForkNumber, BlockNumber, Oid, Oid, Oid);
probe buffer__checkpoint__start(int);
probe buffer__checkpoint__sync__start();
probe buffer__checkpoint__done();
probe buffer__sync__start(int, int);
probe buffer__sync__written(int);
probe buffer__sync__done(int, int, int);
probe buffer__write__dirty__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
probe buffer__write__dirty__done(ForkNumber, BlockNumber, Oid, Oid, Oid);
probe deadlock__found();
probe checkpoint__start(int);
probe checkpoint__done(int, int, int, int, int);
probe clog__checkpoint__start(bool);
probe clog__checkpoint__done(bool);
probe subtrans__checkpoint__start(bool);
probe subtrans__checkpoint__done(bool);
probe multixact__checkpoint__start(bool);
probe multixact__checkpoint__done(bool);
probe twophase__checkpoint__start();
probe twophase__checkpoint__done();
probe smgr__md__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid, int);
probe smgr__md__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int, int);
probe smgr__md__write__start(ForkNumber, BlockNumber, Oid, Oid, Oid, int);
probe smgr__md__write__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int, int);
probe wal__insert(unsigned char, unsigned char);
probe wal__switch();
probe wal__buffer__write__dirty__start();
probe wal__buffer__write__dirty__done();
};