!5171 IUDS优化,调整热点函数调用顺序

Merge pull request !5171 from npczwh1/iuds_opt1
This commit is contained in:
opengauss_bot
2024-07-08 11:49:35 +00:00
committed by Gitee
7 changed files with 39 additions and 35 deletions

View File

@ -121,8 +121,8 @@ TupleTableSlot* ExecScan(ScanState* node, ExecScanAccessMtd access_mtd, /* funct
* Fetch data from node
*/
qual = node->ps.qual;
proj_info = node->ps.ps_ProjInfo;
econtext = node->ps.ps_ExprContext;
proj_info = node->ps.ps_ProjInfo;
/*
* If we have neither a qual to check nor a projection to do, just skip

View File

@ -120,8 +120,8 @@ static TupleTableSlot* IndexOnlyNext(IndexOnlyScanState* node)
TupleTableSlot* slot = NULL;
TupleTableSlot* tmpslot = NULL;
ItemPointer tid;
bool isVersionScan = node->ss.isVersionScan;
bool isUHeap = false;
bool isVersionScan;
/*
* extract necessary information from index scan node
@ -135,9 +135,10 @@ static TupleTableSlot* IndexOnlyNext(IndexOnlyScanState* node)
else if (ScanDirectionIsBackward(direction))
direction = ForwardScanDirection;
}
scandesc = node->ioss_ScanDesc;
econtext = node->ss.ps.ps_ExprContext;
slot = node->ss.ss_ScanTupleSlot;
isVersionScan = node->ss.isVersionScan;
scandesc = node->ioss_ScanDesc;
isUHeap = RelationIsUstoreFormat(node->ss.ss_currentRelation);
if (isUHeap) {
tmpslot = MakeSingleTupleTableSlot(RelationGetDescr(scandesc->heapRelation),
@ -239,7 +240,6 @@ static TupleTableSlot* IndexOnlyNext(IndexOnlyScanState* node)
* Fill the scan tuple slot with data from the index.
*/
StoreIndexTuple(slot, indexScan->xs_itup, indexScan->xs_itupdesc);
/*
* If the index was lossy, we have to recheck the index quals.
* (Currently, this can never happen, but we should support the case

View File

@ -77,9 +77,9 @@ static TupleTableSlot* IndexNext(IndexScanState* node)
else if (ScanDirectionIsBackward(direction))
direction = ForwardScanDirection;
}
scandesc = node->iss_ScanDesc;
econtext = node->ss.ps.ps_ExprContext;
slot = node->ss.ss_ScanTupleSlot;
scandesc = node->iss_ScanDesc;
isUstore = RelationIsUstoreFormat(node->ss.ss_currentRelation);

View File

@ -2481,17 +2481,18 @@ bool heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer, S
* because the SSI checks and the *Satisfies routine for historical
* MVCC snapshots need the correct tid to decide about the visibility.
*/
heap_tuple->t_data = (HeapTupleHeader)PageGetItem(dp, lp);
heap_tuple->t_len = ItemIdGetLength(lp);
heap_tuple->t_tableOid = RelationGetRelid(relation);
heap_tuple->t_bucketId = RelationGetBktid(relation);
ItemPointerSet(&heap_tuple->t_self, blkno, offnum);
heap_tuple->t_tableOid = RelationGetRelid(relation);
HeapTupleCopyBaseFromPage(heap_tuple, dp);
#ifdef PGXC
heap_tuple->t_xc_node_id = u_sess->pgxc_cxt.PGXCNodeIdentifier;
#endif
ItemPointerSet(&heap_tuple->t_self, blkno, offnum);
heap_tuple->t_data = (HeapTupleHeader)PageGetItem(dp, lp);
/*
* Shouldn't see a HEAP_ONLY tuple at chain start.
*/
if (at_chain_start && HeapTupleIsHeapOnly(heap_tuple)) {

View File

@ -475,6 +475,7 @@ int32 _bt_compare(Relation rel, BTScanInsert key, Page page, OffsetNumber offnum
datum = index_getattr(itup, scankey->sk_attno, itupdesc, &isNull);
if (likely((!(scankey->sk_flags & SK_ISNULL)) && !isNull)) {
int8 multiplier = (scankey->sk_flags & SK_BT_DESC) ? 1 : -1;
/* btint4cmp */
if (scankey->sk_func.fn_oid == F_BTINT4CMP) {
result = (int32)datum == (int32)scankey->sk_argument
@ -497,8 +498,7 @@ int32 _bt_compare(Relation rel, BTScanInsert key, Page page, OffsetNumber offnum
FunctionCall2Coll(&scankey->sk_func, scankey->sk_collation, datum, scankey->sk_argument));
}
if (!(scankey->sk_flags & SK_BT_DESC))
result = -result;
result *= multiplier;
} else {
if (scankey->sk_flags & SK_ISNULL) { /* key is NULL */
if (isNull)

View File

@ -1028,13 +1028,7 @@ static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info, XLogFPWInfo fpw_
xid = GetCurrentTransactionIdIfAny();
}
rechdr->xl_xid = xid;
rechdr->xl_tot_len = total_len;
rechdr->xl_info = info;
rechdr->xl_rmid = rmid;
rechdr->xl_prev = InvalidXLogRecPtr;
rechdr->xl_crc = rdata_crc;
Assert(hashbucket_flag == false || no_hashbucket_flag == false);
rechdr->xl_term = Max(g_instance.comm_cxt.localinfo_cxt.term_from_file,
g_instance.comm_cxt.localinfo_cxt.term_from_xlog);
if ((rechdr->xl_term & XLOG_CONTAIN_CSN) != 0) {
@ -1047,7 +1041,13 @@ static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info, XLogFPWInfo fpw_
if (t_thrd.proc->workingVersionNum >= PARALLEL_DECODE_VERSION_NUM && XLogLogicalInfoActive()) {
rechdr->xl_term |= XLOG_CONTAIN_CSN;
}
rechdr->xl_xid = xid;
rechdr->xl_prev = InvalidXLogRecPtr;
rechdr->xl_info = info;
rechdr->xl_rmid = rmid;
Assert(hashbucket_flag == false || no_hashbucket_flag == false);
rechdr->xl_bucket_id = (uint2)(bucket_id + 1);
rechdr->xl_crc = rdata_crc;
return t_thrd.xlog_cxt.ptr_hdr_rdt;
}

View File

@ -1856,12 +1856,12 @@ void pgstate_update_percentile_responsetime(void);
*/
static inline WaitState pgstat_report_waitstatus(WaitState waitstatus, bool isOnlyFetch = false)
{
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
WaitState oldwaitstatus;
if (IS_PGSTATE_TRACK_UNDEFINE)
return STATE_WAIT_UNDEFINED;
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
WaitState oldwaitstatus;
WaitState oldStatus = beentry->st_waitstatus;
if (isOnlyFetch)
@ -1919,10 +1919,11 @@ static inline WaitState pgstat_report_waitstatus(WaitState waitstatus, bool isOn
*/
static inline WaitState pgstat_report_waitstatus_xid(WaitState waitstatus, uint64 xid, bool isOnlyFetch = false)
{
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
if (IS_PGSTATE_TRACK_UNDEFINE)
return STATE_WAIT_UNDEFINED;
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
WaitState oldStatus = beentry->st_waitstatus;
if (isOnlyFetch)
@ -1949,11 +1950,12 @@ static inline WaitState pgstat_report_waitstatus_xid(WaitState waitstatus, uint6
*/
static inline WaitState pgstat_report_waitstatus_relname(WaitState waitstatus, char* relname, bool isOnlyFetch = false)
{
if (IS_PGSTATE_TRACK_UNDEFINE)
return STATE_WAIT_UNDEFINED;
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
int len = 0;
if (IS_PGSTATE_TRACK_UNDEFINE)
return STATE_WAIT_UNDEFINED;
WaitState oldStatus = beentry->st_waitstatus;
if (isOnlyFetch)
@ -1992,10 +1994,11 @@ static inline WaitState pgstat_report_waitstatus_relname(WaitState waitstatus, c
static inline WaitState pgstat_report_waitstatus_comm(WaitState waitstatus, int nodeId = -1, int waitnode_count = -1,
int plannodeid = -1, int numnodes = -1, bool isOnlyFetch = false)
{
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
if (IS_PGSTATE_TRACK_UNDEFINE)
return STATE_WAIT_UNDEFINED;
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
WaitState oldStatus = beentry->st_waitstatus;
if (isOnlyFetch)
@ -2024,11 +2027,11 @@ static inline WaitState pgstat_report_waitstatus_comm(WaitState waitstatus, int
*/
static inline WaitStatePhase pgstat_report_waitstatus_phase(WaitStatePhase waitstatus_phase, bool isOnlyFetch = false)
{
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
if (IS_PGSTATE_TRACK_UNDEFINE)
return PHASE_NONE;
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
WaitStatePhase oldPhase = beentry->st_waitstatus_phase;
if (isOnlyFetch)
@ -2045,10 +2048,10 @@ static inline WaitStatePhase pgstat_report_waitstatus_phase(WaitStatePhase waits
static inline void pgstat_report_wait_lock_failed(uint32 wait_event_info)
{
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
if (!u_sess->attr.attr_common.pgstat_track_activities || !u_sess->attr.attr_common.enable_instr_track_wait ||
!beentry)
!t_thrd.shemem_ptr_cxt.MyBEEntry)
return;
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
pgstat_increment_changecount_before(beentry);
uint32 old_wait_event_info = beentry->st_waitevent;
UpdateWaitEventFaildStat(&beentry->waitInfo, old_wait_event_info);
@ -2070,11 +2073,11 @@ static inline void pgstat_report_wait_lock_failed(uint32 wait_event_info)
*/
static inline void pgstat_report_waitevent(uint32 wait_event_info)
{
PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
if (IS_PGSTATE_TRACK_UNDEFINE)
return;
PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
pgstat_increment_changecount_before(beentry);
/*
* Since this is a four-byte field which is always read and written as
@ -2099,11 +2102,11 @@ static inline void pgstat_report_waitevent(uint32 wait_event_info)
static inline void pgstat_report_waitevent_count(uint32 wait_event_info)
{
PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
if (IS_PGSTATE_TRACK_UNDEFINE)
return;
PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
pgstat_increment_changecount_before(beentry);
/*
* Since this is a four-byte field which is always read and written as
@ -2120,11 +2123,11 @@ static inline void pgstat_report_waitevent_count(uint32 wait_event_info)
static inline void pgstat_reset_waitStatePhase(WaitState waitstatus, WaitStatePhase waitstatus_phase)
{
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
if (IS_PGSTATE_TRACK_UNDEFINE)
return;
volatile PgBackendStatus* beentry = t_thrd.shemem_ptr_cxt.MyBEEntry;
beentry->st_waitstatus = waitstatus;
beentry->st_waitstatus_phase = waitstatus_phase;