# Samples: 1M of event 'minor-faults' # Event count (approx.): 20314715 # # Children Self Period Command Shared Object Symbol # ........ ........ ............ ............... ..................................... ........................................................................ # 99.79% 0.00% 0 postgres postgres [.] _start | ---_start __libc_start_main@@GLIBC_2.34 __libc_start_call_main main PostmasterMain | --99.79%--ServerLoop | --99.61%--BackendStartup | --99.33%--postmaster_child_launch | |--95.12%--BackendInitialize | | | --95.08%--PostgresMain | | | |--53.39%--InitPostgres | | | | | |--35.65%--InitProcessPhase2 | | | | | | | --35.57%--ProcArrayAdd Percent | Source code & Disassembly of postgres for minor-faults (103275 samples, percent: local period) -------------------------------------------------------------------------------------------------------------- : : : : 3 Disassembly of section .text: : : 5 00000000006b5720 : : 6 /* : 7 * Add the specified PGPROC to the shared array. : 8 */ : 9 void : 10 ProcArrayAdd(PGPROC *proc) : 11 { 0.00 : 6b5720: endbr64 0.00 : 6b5724: push %rbp 0.00 : 6b5725: mov %rsp,%rbp 0.00 : 6b5728: sub $0x30,%rsp 0.00 : 6b572c: mov %rdi,-0x28(%rbp) : 17 int pgprocno = GetNumberFromPGProc(proc); 0.00 : 6b5730: mov 0x686319(%rip),%rax # d3ba50 0.00 : 6b5737: mov (%rax),%rax 0.00 : 6b573a: mov -0x28(%rbp),%rdx 0.00 : 6b573e: sub %rax,%rdx 0.00 : 6b5741: sar $0x7,%rdx 0.00 : 6b5745: movabs $0x6db6db6db6db6db7,%rax 0.00 : 6b574f: imul %rdx,%rax 0.00 : 6b5753: mov %eax,-0x18(%rbp) : 26 ProcArrayStruct *arrayP = procArray; 0.00 : 6b5756: mov 0x684043(%rip),%rax # d397a0 0.00 : 6b575d: mov %rax,-0x8(%rbp) : 29 int index; : 30 int movecount; : : 32 /* See ProcGlobal comment explaining why both locks are held */ : 33 LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); 0.00 : 6b5761: mov 0x6854f8(%rip),%rax # d3ac60 0.00 : 6b5768: add $0x200,%rax 0.00 : 6b576e: mov $0x0,%esi 0.00 : 6b5773: mov %rax,%rdi 0.00 : 6b5776: call 6d454c : 39 LWLockAcquire(XidGenLock, LW_EXCLUSIVE); 0.00 : 6b577b: mov 0x6854de(%rip),%rax # d3ac60 0.00 : 6b5782: add $0x180,%rax 0.00 : 6b5788: mov $0x0,%esi 0.00 : 6b578d: mov %rax,%rdi 0.00 : 6b5790: call 6d454c : : 46 if (arrayP->numProcs >= arrayP->maxProcs) 0.00 : 6b5795: mov -0x8(%rbp),%rax 0.11 : 6b5799: mov (%rax),%edx 0.00 : 6b579b: mov -0x8(%rbp),%rax 0.00 : 6b579f: mov 0x4(%rax),%eax 0.00 : 6b57a2: cmp %eax,%edx 0.00 : 6b57a4: jl 6b57f5 : 53 /* : 54 * Oops, no room. (This really shouldn't happen, since there is a : 55 * fixed supply of PGPROC structs too, and so we should have failed : 56 * earlier.) : 57 */ : 58 ereport(FATAL, 0.00 : 6b57a6: mov $0x0,%esi 0.00 : 6b57ab: mov $0x16,%edi 0.00 : 6b57b0: call 8f9a0f 0.00 : 6b57b5: test %al,%al 0.00 : 6b57b7: je 6b57f5 0.00 : 6b57b9: mov $0x30c5,%edi 0.00 : 6b57be: call 8fa2a6 0.00 : 6b57c3: lea 0x4496ce(%rip),%rax # afee98 <__func__.0+0x58> 0.00 : 6b57ca: mov %rax,%rdi 0.00 : 6b57cd: mov $0x0,%eax 0.00 : 6b57d2: call 8fa559 0.00 : 6b57d7: lea 0x449b4a(%rip),%rax # aff328 <__func__.19> 0.00 : 6b57de: mov %rax,%rdx 0.00 : 6b57e1: mov $0x1e2,%esi 0.00 : 6b57e6: lea 0x4496cb(%rip),%rax # afeeb8 <__func__.0+0x78> 0.00 : 6b57ed: mov %rax,%rdi 0.00 : 6b57f0: call 8f9c10 : 76 * PGPROC structure in the cache. : 77 * : 78 * Since the occurrence of adding/removing a proc is much lower than the : 79 * access to the ProcArray itself, the overhead should be marginal : 80 */ : 81 for (index = 0; index < arrayP->numProcs; index++) 0.00 : 6b57f5: movl $0x0,-0x1c(%rbp) 0.00 : 6b57fc: jmp 6b581f : 84 { : 85 int this_procno = arrayP->pgprocnos[index]; 0.00 : 6b57fe: mov -0x8(%rbp),%rax 0.00 : 6b5802: mov -0x1c(%rbp),%edx 0.00 : 6b5805: movslq %edx,%rdx 0.00 : 6b5808: add $0x8,%rdx 0.07 : 6b580c: mov 0x4(%rax,%rdx,4),%eax 0.00 : 6b5810: mov %eax,-0x14(%rbp) : : 93 Assert(this_procno >= 0 && this_procno < (arrayP->maxProcs + NUM_AUXILIARY_PROCS)); : 94 Assert(allProcs[this_procno].pgxactoff == index); : : 96 /* If we have found our right position in the array, break */ : 97 if (this_procno > pgprocno) 0.00 : 6b5813: mov -0x14(%rbp),%eax 0.00 : 6b5816: cmp -0x18(%rbp),%eax 0.00 : 6b5819: jg 6b582c : 101 for (index = 0; index < arrayP->numProcs; index++) 0.00 : 6b581b: addl $0x1,-0x1c(%rbp) 0.00 : 6b581f: mov -0x8(%rbp),%rax 0.00 : 6b5823: mov (%rax),%eax 0.00 : 6b5825: cmp %eax,-0x1c(%rbp) 0.00 : 6b5828: jl 6b57fe 0.00 : 6b582a: jmp 6b582d : 108 break; 0.00 : 6b582c: nop : 110 } : : 112 movecount = arrayP->numProcs - index; 0.00 : 6b582d: mov -0x8(%rbp),%rax 0.00 : 6b5831: mov (%rax),%eax 0.00 : 6b5833: sub -0x1c(%rbp),%eax 0.00 : 6b5836: mov %eax,-0x10(%rbp) : 117 memmove(&arrayP->pgprocnos[index + 1], 0.00 : 6b5839: mov -0x10(%rbp),%eax 0.00 : 6b583c: cltq 0.00 : 6b583e: lea 0x0(,%rax,4),%rdx : 121 &arrayP->pgprocnos[index], 0.00 : 6b5846: mov -0x1c(%rbp),%eax 0.00 : 6b5849: cltq 0.00 : 6b584b: add $0x8,%rax 0.00 : 6b584f: lea 0x0(,%rax,4),%rcx 0.00 : 6b5857: mov -0x8(%rbp),%rax 0.00 : 6b585b: add %rcx,%rax 0.00 : 6b585e: lea 0x4(%rax),%rcx : 129 memmove(&arrayP->pgprocnos[index + 1], 0.00 : 6b5862: mov -0x1c(%rbp),%eax 0.00 : 6b5865: add $0x1,%eax 0.00 : 6b5868: cltq 0.00 : 6b586a: add $0x8,%rax 0.00 : 6b586e: lea 0x0(,%rax,4),%rsi 0.00 : 6b5876: mov -0x8(%rbp),%rax 0.00 : 6b587a: add %rsi,%rax 0.00 : 6b587d: add $0x4,%rax 0.00 : 6b5881: mov %rcx,%rsi 0.00 : 6b5884: mov %rax,%rdi 0.00 : 6b5887: call ed240 : 141 movecount * sizeof(*arrayP->pgprocnos)); : 142 memmove(&ProcGlobal->xids[index + 1], 0.00 : 6b588c: mov -0x10(%rbp),%eax 0.00 : 6b588f: cltq 0.00 : 6b5891: lea 0x0(,%rax,4),%rdx : 146 &ProcGlobal->xids[index], 0.00 : 6b5899: mov 0x6861b0(%rip),%rax # d3ba50 0.00 : 6b58a0: mov 0x8(%rax),%rax 0.00 : 6b58a4: mov -0x1c(%rbp),%ecx 0.00 : 6b58a7: movslq %ecx,%rcx 0.00 : 6b58aa: shl $0x2,%rcx 0.00 : 6b58ae: add %rax,%rcx : 153 memmove(&ProcGlobal->xids[index + 1], 0.00 : 6b58b1: mov 0x686198(%rip),%rax # d3ba50 0.00 : 6b58b8: mov 0x8(%rax),%rax 0.00 : 6b58bc: mov -0x1c(%rbp),%esi 0.00 : 6b58bf: add $0x1,%esi 0.00 : 6b58c2: movslq %esi,%rsi 0.00 : 6b58c5: shl $0x2,%rsi 0.00 : 6b58c9: add %rsi,%rax 0.00 : 6b58cc: mov %rcx,%rsi 0.00 : 6b58cf: mov %rax,%rdi 0.00 : 6b58d2: call ed240 : 164 movecount * sizeof(*ProcGlobal->xids)); : 165 memmove(&ProcGlobal->subxidStates[index + 1], 0.00 : 6b58d7: mov -0x10(%rbp),%eax 0.00 : 6b58da: cltq 0.00 : 6b58dc: lea (%rax,%rax,1),%rdx : 169 &ProcGlobal->subxidStates[index], 0.00 : 6b58e0: mov 0x686169(%rip),%rax # d3ba50 0.00 : 6b58e7: mov 0x10(%rax),%rax 0.00 : 6b58eb: mov -0x1c(%rbp),%ecx 0.00 : 6b58ee: movslq %ecx,%rcx 0.00 : 6b58f1: add %rcx,%rcx 0.00 : 6b58f4: add %rax,%rcx : 176 memmove(&ProcGlobal->subxidStates[index + 1], 0.00 : 6b58f7: mov 0x686152(%rip),%rax # d3ba50 0.00 : 6b58fe: mov 0x10(%rax),%rax 0.00 : 6b5902: mov -0x1c(%rbp),%esi 0.00 : 6b5905: add $0x1,%esi 0.00 : 6b5908: movslq %esi,%rsi 0.00 : 6b590b: add %rsi,%rsi 0.00 : 6b590e: add %rsi,%rax 0.00 : 6b5911: mov %rcx,%rsi 0.00 : 6b5914: mov %rax,%rdi 0.00 : 6b5917: call ed240 : 187 movecount * sizeof(*ProcGlobal->subxidStates)); : 188 memmove(&ProcGlobal->statusFlags[index + 1], 0.00 : 6b591c: mov -0x10(%rbp),%eax 0.00 : 6b591f: cltq : 191 &ProcGlobal->statusFlags[index], 0.00 : 6b5921: mov 0x686128(%rip),%rdx # d3ba50 0.00 : 6b5928: mov 0x18(%rdx),%rcx : 194 memmove(&ProcGlobal->statusFlags[index + 1], 0.00 : 6b592c: mov -0x1c(%rbp),%edx 0.00 : 6b592f: movslq %edx,%rdx : 197 &ProcGlobal->statusFlags[index], 0.00 : 6b5932: lea (%rcx,%rdx,1),%rsi : 199 memmove(&ProcGlobal->statusFlags[index + 1], 0.00 : 6b5936: mov 0x686113(%rip),%rdx # d3ba50 0.00 : 6b593d: mov 0x18(%rdx),%rcx 0.00 : 6b5941: mov -0x1c(%rbp),%edx 0.00 : 6b5944: add $0x1,%edx 0.00 : 6b5947: movslq %edx,%rdx 0.00 : 6b594a: add %rdx,%rcx 0.00 : 6b594d: mov %rax,%rdx 0.00 : 6b5950: mov %rcx,%rdi 0.00 : 6b5953: call ed240 : 209 movecount * sizeof(*ProcGlobal->statusFlags)); : : 211 arrayP->pgprocnos[index] = GetNumberFromPGProc(proc); 0.00 : 6b5958: mov 0x6860f1(%rip),%rax # d3ba50 0.00 : 6b595f: mov (%rax),%rax 0.00 : 6b5962: mov -0x28(%rbp),%rdx 0.00 : 6b5966: sub %rax,%rdx 0.00 : 6b5969: sar $0x7,%rdx 0.00 : 6b596d: movabs $0x6db6db6db6db6db7,%rax 0.00 : 6b5977: imul %rdx,%rax 0.00 : 6b597b: mov %eax,%ecx 0.00 : 6b597d: mov -0x8(%rbp),%rax 0.00 : 6b5981: mov -0x1c(%rbp),%edx 0.00 : 6b5984: movslq %edx,%rdx 0.00 : 6b5987: add $0x8,%rdx 0.00 : 6b598b: mov %ecx,0x4(%rax,%rdx,4) : 225 proc->pgxactoff = index; 0.00 : 6b598f: mov -0x28(%rbp),%rax 0.00 : 6b5993: mov -0x1c(%rbp),%edx 0.00 : 6b5996: mov %edx,0x2c(%rax) : 229 ProcGlobal->xids[index] = proc->xid; 0.00 : 6b5999: mov 0x6860b0(%rip),%rax # d3ba50 0.00 : 6b59a0: mov 0x8(%rax),%rax 0.00 : 6b59a4: mov -0x1c(%rbp),%edx 0.00 : 6b59a7: movslq %edx,%rdx 0.00 : 6b59aa: shl $0x2,%rdx 0.00 : 6b59ae: add %rax,%rdx 0.00 : 6b59b1: mov -0x28(%rbp),%rax 0.00 : 6b59b5: mov 0x3c(%rax),%eax 0.00 : 6b59b8: mov %eax,(%rdx) : 239 ProcGlobal->subxidStates[index] = proc->subxidStatus; 0.00 : 6b59ba: mov 0x68608f(%rip),%rax # d3ba50 0.00 : 6b59c1: mov 0x10(%rax),%rax 0.00 : 6b59c5: mov -0x1c(%rbp),%edx 0.00 : 6b59c8: movslq %edx,%rdx 0.00 : 6b59cb: add %rdx,%rdx 0.00 : 6b59ce: add %rax,%rdx 0.00 : 6b59d1: mov -0x28(%rbp),%rax 0.00 : 6b59d5: movzwl 0x44(%rax),%eax 0.00 : 6b59d9: mov %ax,(%rdx) : 249 ProcGlobal->statusFlags[index] = proc->statusFlags; 0.00 : 6b59dc: mov 0x68606d(%rip),%rax # d3ba50 0.00 : 6b59e3: mov 0x18(%rax),%rdx 0.00 : 6b59e7: mov -0x1c(%rbp),%eax 0.00 : 6b59ea: cltq 0.00 : 6b59ec: add %rax,%rdx 0.00 : 6b59ef: mov -0x28(%rbp),%rax 0.00 : 6b59f3: movzbl 0x30(%rax),%eax 0.00 : 6b59f7: mov %al,(%rdx) : : 259 arrayP->numProcs++; 0.00 : 6b59f9: mov -0x8(%rbp),%rax 0.00 : 6b59fd: mov (%rax),%eax 0.00 : 6b59ff: lea 0x1(%rax),%edx 0.00 : 6b5a02: mov -0x8(%rbp),%rax 0.00 : 6b5a06: mov %edx,(%rax) : : 266 /* adjust pgxactoff for all following PGPROCs */ : 267 index++; 0.00 : 6b5a08: addl $0x1,-0x1c(%rbp) : 269 for (; index < arrayP->numProcs; index++) 0.00 : 6b5a0c: jmp 6b5a4c : 271 { : 272 int procno = arrayP->pgprocnos[index]; 0.00 : 6b5a0e: mov -0x8(%rbp),%rax 0.00 : 6b5a12: mov -0x1c(%rbp),%edx 0.00 : 6b5a15: movslq %edx,%rdx 0.00 : 6b5a18: add $0x8,%rdx 0.00 : 6b5a1c: mov 0x4(%rax,%rdx,4),%eax 0.00 : 6b5a20: mov %eax,-0xc(%rbp) : : 280 Assert(procno >= 0 && procno < (arrayP->maxProcs + NUM_AUXILIARY_PROCS)); : 281 Assert(allProcs[procno].pgxactoff == index - 1); : : 283 allProcs[procno].pgxactoff = index; 0.00 : 6b5a23: mov 0x683d7e(%rip),%rcx # d397a8 0.00 : 6b5a2a: mov -0xc(%rbp),%eax 0.00 : 6b5a2d: movslq %eax,%rdx 0.00 : 6b5a30: mov %rdx,%rax 0.00 : 6b5a33: shl $0x3,%rax 0.00 : 6b5a37: sub %rdx,%rax 0.00 : 6b5a3a: shl $0x7,%rax 0.00 : 6b5a3e: lea (%rcx,%rax,1),%rdx 0.00 : 6b5a42: mov -0x1c(%rbp),%eax 99.82 : 6b5a45: mov %eax,0x2c(%rdx) : 294 for (; index < arrayP->numProcs; index++) 0.00 : 6b5a48: addl $0x1,-0x1c(%rbp) 0.00 : 6b5a4c: mov -0x8(%rbp),%rax 0.00 : 6b5a50: mov (%rax),%eax 0.00 : 6b5a52: cmp %eax,-0x1c(%rbp) 0.00 : 6b5a55: jl 6b5a0e : : 301 /* : 302 * Release in reversed acquisition order, to reduce frequency of having to : 303 * wait for XidGenLock while holding ProcArrayLock. : 304 */ : 305 LWLockRelease(XidGenLock); 0.00 : 6b5a57: mov 0x685202(%rip),%rax # d3ac60 0.00 : 6b5a5e: add $0x180,%rax 0.00 : 6b5a64: mov %rax,%rdi 0.00 : 6b5a67: call 6d4da1 : 310 LWLockRelease(ProcArrayLock); 0.00 : 6b5a6c: mov 0x6851ed(%rip),%rax # d3ac60 0.00 : 6b5a73: add $0x200,%rax 0.00 : 6b5a79: mov %rax,%rdi 0.00 : 6b5a7c: call 6d4da1 : 315 } 0.00 : 6b5a81: nop 0.00 : 6b5a82: leave 0.00 : 6b5a83: ret