博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
taskset - retrieve or set a process's CPU affinity (affect SYSTEMTAP TIME)
阅读量:6816 次
发布时间:2019-06-26

本文共 24063 字,大约阅读时间需要 80 分钟。

在使用systemtap监控进程或者内核的运行状况时, 我们会发现使用systemtap和不使用systemtap时, 某些操作的运行时间差别会比较大. 这是因为systemtap本身带来的开销导致的, 那么如何减少这部分开销呢?
可选的方法较多, 例如精简systemtap, 减少systemtap的触发事件的范围, 简化handler的逻辑等等.
除此之外, 还有其他的方法, 例如设置CPU亲和, Linux进程使用哪个CPU资源是由内核进行调度的.
被跟踪进程的亲和与stap运行的进程亲和分开, 可以有效的减少stap的影响吗. 实际上影响甚微, 但是有效果.  
其次我发现CentOS 6.4 x64系统下面, 使用CPU 0的话, 性能会远远不如使用其他任何CPU.  (这才是本文主题)
所以改亲和的话, 只要不使用0号CPU就可以了.
例如 : 
服务器上有8个CPU
pg93@db-172-16-3-150-> numactl --showpolicy: defaultpreferred node: currentphyscpubind: 0 1 2 3 4 5 6 7 cpubind: 0 nodebind: 0 membind: 0 pg93@db-172-16-3-150-> cat /proc/cpuinfo processor       : 0vendor_id       : GenuineIntelcpu family      : 6model           : 26model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHzstepping        : 5cpu MHz         : 1595.992cache size      : 4096 KBphysical id     : 1siblings        : 4core id         : 0cpu cores       : 4apicid          : 16initial apicid  : 16fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidbogomips        : 3191.98clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:processor       : 1vendor_id       : GenuineIntelcpu family      : 6model           : 26model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHzstepping        : 5cpu MHz         : 1595.992cache size      : 4096 KBphysical id     : 0siblings        : 4core id         : 0cpu cores       : 4apicid          : 0initial apicid  : 0fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidbogomips        : 3191.50clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:processor       : 2vendor_id       : GenuineIntelcpu family      : 6model           : 26model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHzstepping        : 5cpu MHz         : 1595.992cache size      : 4096 KBphysical id     : 1siblings        : 4core id         : 1cpu cores       : 4apicid          : 18initial apicid  : 18fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidbogomips        : 3191.98clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:processor       : 3vendor_id       : GenuineIntelcpu family      : 6model           : 26model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHzstepping        : 5cpu MHz         : 1595.992cache size      : 4096 KBphysical id     : 0siblings        : 4core id         : 1cpu cores       : 4apicid          : 2initial apicid  : 2fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidbogomips        : 3191.50clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:processor       : 4vendor_id       : GenuineIntelcpu family      : 6model           : 26model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHzstepping        : 5cpu MHz         : 1595.992cache size      : 4096 KBphysical id     : 1siblings        : 4core id         : 2cpu cores       : 4apicid          : 20initial apicid  : 20fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidbogomips        : 3191.98clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:processor       : 5vendor_id       : GenuineIntelcpu family      : 6model           : 26model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHzstepping        : 5cpu MHz         : 1595.992cache size      : 4096 KBphysical id     : 0siblings        : 4core id         : 2cpu cores       : 4apicid          : 4initial apicid  : 4fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidbogomips        : 3191.50clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:processor       : 6vendor_id       : GenuineIntelcpu family      : 6model           : 26model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHzstepping        : 5cpu MHz         : 1595.992cache size      : 4096 KBphysical id     : 1siblings        : 4core id         : 3cpu cores       : 4apicid          : 22initial apicid  : 22fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidbogomips        : 3191.98clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:processor       : 7vendor_id       : GenuineIntelcpu family      : 6model           : 26model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHzstepping        : 5cpu MHz         : 1595.992cache size      : 4096 KBphysical id     : 0siblings        : 4core id         : 3cpu cores       : 4apicid          : 6initial apicid  : 6fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidbogomips        : 3191.50clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:
从以上CPUINFO可以看出, 这里有2个物理CPU, 0和1.
使用dmidecode也可以看到这部分信息
[root@db-172-16-3-150 ~]# dmidecode -t processor# dmidecode 2.11SMBIOS 2.6 present.Handle 0x0400, DMI type 4, 40 bytesProcessor Information        Socket Designation: CPU1        Type: Central Processor        Family: Xeon        Manufacturer: Intel        ID: A5 06 01 00 FF FB EB BF        Signature: Type 0, Family 6, Model 26, Stepping 5        Flags:                FPU (Floating-point unit on-chip)                VME (Virtual mode extension)                DE (Debugging extension)                PSE (Page size extension)                TSC (Time stamp counter)                MSR (Model specific registers)                PAE (Physical address extension)                MCE (Machine check exception)                CX8 (CMPXCHG8 instruction supported)                APIC (On-chip APIC hardware supported)                SEP (Fast system call)                MTRR (Memory type range registers)                PGE (Page global enable)                MCA (Machine check architecture)                CMOV (Conditional move instruction supported)                PAT (Page attribute table)                PSE-36 (36-bit page size extension)                CLFSH (CLFLUSH instruction supported)                DS (Debug store)                ACPI (ACPI supported)                MMX (MMX technology supported)                FXSR (FXSAVE and FXSTOR instructions supported)                SSE (Streaming SIMD extensions)                SSE2 (Streaming SIMD extensions 2)                SS (Self-snoop)                HTT (Multi-threading)                TM (Thermal monitor supported)                PBE (Pending break enabled)        Version: Intel(R) Xeon(R) CPU           E5504  @ 2.00GHz        Voltage: 1.2 V        External Clock: 4800 MHz        Max Speed: 3600 MHz        Current Speed: 1600 MHz        Status: Populated, Enabled        Upgrade: Socket LGA1366        L1 Cache Handle: 0x0700        L2 Cache Handle: 0x0701        L3 Cache Handle: 0x0702        Serial Number: Not Specified        Asset Tag: Not Specified        Part Number: Not Specified        Core Count: 4        Core Enabled: 4        Thread Count: 4        Characteristics:                64-bit capableHandle 0x0401, DMI type 4, 40 bytesProcessor Information        Socket Designation: CPU2        Type: Central Processor        Family: Xeon        Manufacturer: Intel        ID: A5 06 01 00 FF FB EB BF        Signature: Type 0, Family 6, Model 26, Stepping 5        Flags:                FPU (Floating-point unit on-chip)                VME (Virtual mode extension)                DE (Debugging extension)                PSE (Page size extension)                TSC (Time stamp counter)                MSR (Model specific registers)                PAE (Physical address extension)                MCE (Machine check exception)                CX8 (CMPXCHG8 instruction supported)                APIC (On-chip APIC hardware supported)                SEP (Fast system call)                MTRR (Memory type range registers)                PGE (Page global enable)                MCA (Machine check architecture)                CMOV (Conditional move instruction supported)                PAT (Page attribute table)                PSE-36 (36-bit page size extension)                CLFSH (CLFLUSH instruction supported)                DS (Debug store)                ACPI (ACPI supported)                MMX (MMX technology supported)                FXSR (FXSAVE and FXSTOR instructions supported)                SSE (Streaming SIMD extensions)                SSE2 (Streaming SIMD extensions 2)                SS (Self-snoop)                HTT (Multi-threading)                TM (Thermal monitor supported)                PBE (Pending break enabled)        Version: Intel(R) Xeon(R) CPU           E5504  @ 2.00GHz        Voltage: 1.2 V        External Clock: 4800 MHz        Max Speed: 3600 MHz        Current Speed: 1600 MHz        Status: Populated, Idle        Upgrade: Socket LGA1366        L1 Cache Handle: 0x0703        L2 Cache Handle: 0x0704        L3 Cache Handle: 0x0705        Serial Number: Not Specified        Asset Tag: Not Specified        Part Number: Not Specified        Core Count: 4        Core Enabled: 4        Thread Count: 4        Characteristics:                64-bit capable[root@db-172-16-3-150 ~]# cat /proc/cpuinfo |grep "core id"core id         : 0core id         : 0core id         : 1core id         : 1core id         : 2core id         : 2core id         : 3core id         : 3[root@db-172-16-3-150 ~]# cat /proc/cpuinfo |grep "physical id"physical id     : 1physical id     : 0physical id     : 1physical id     : 0physical id     : 1physical id     : 0physical id     : 1physical id     : 0
在没有运行业务的情况下, 我们要测试PostgreSQL某SQL的IO请求次数和请求时间.
启动PostgreSQL数据库时, 把CPU亲和设置为0. (也就是文章开头提到的性能最烂的做法.)
pg93@db-172-16-3-150-> taskset -c 0 /home/pg93/pgsql9.3.1/bin/postgres >/dev/null 2>&1
使用亲和1启动psql.
pg93@db-172-16-3-150-> taskset -c 1 psqlpsql (9.3.1)Type "help" for help.digoal=# select pg_backend_pid(); pg_backend_pid ----------------          24781(1 row)
然后在启动stap时把亲和设置为和PostgreSQL不一样的CPU id. 例如3(这样也确保了不在一个物理core上.). 
[root@db-172-16-3-150 ~]# taskset -c 3 stap -e 'global aprobe process("/home/pg93/pgsql9.3.1/bin/postgres").mark("query__start") {  delete a  println("query__start ", user_string($arg1), "pid:", pid())}probe vfs.read.return {  t = gettimeofday_ns() - @entry(gettimeofday_ns())  # if (execname() == "postgres" && devname != "N/A")  # 这句判断也有一定的影响, 所以不用. 我们使用target模式.    a[pid()] <<< t}probe process("/home/pg93/pgsql9.3.1/bin/postgres").mark("query__done") {  printdln("**", pid(), @count(a[pid()]), @avg(a[pid()]))  println("query__done ", user_string($arg1), "pid:", pid())  delete a}' -x 24781
在psql中连续快速的执行SQL
digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.023..3154.782 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared read=94393 Total runtime: 4710.788 ms(4 rows)digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.040..3151.680 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=32 read=94361 Total runtime: 4696.888 ms(4 rows)digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.035..3158.134 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=64 read=94329 Total runtime: 4706.135 ms(4 rows)
stap输出
query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2478124781**94417**5461query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24781query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2478124781**94361**5429query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24781query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2478124781**94329**5529query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24781
我们看到每次read IO的时间为5461纳秒左右.
如果把stap的亲和设置为非0, 即使与stap的亲和一致也没关系. 那么会发生什么情况呢?
pg93@db-172-16-3-150-> taskset -c 3 /home/pg93/pgsql9.3.1/bin/postgres >/dev/null 2>&1pg93@db-172-16-3-150-> taskset -c 3 psqlpsql (9.3.1)Type "help" for help.digoal=# select pg_backend_pid(); pg_backend_pid ----------------          24829(1 row)[root@db-172-16-3-150 ~]# taskset -c 3 stap -e 'global aprobe process("/home/pg93/pgsql9.3.1/bin/postgres").mark("query__start") {  delete a  println("query__start ", user_string($arg1), "pid:", pid())}probe vfs.read.return {  t = gettimeofday_ns() - @entry(gettimeofday_ns())  # if (execname() == "postgres" && devname != "N/A")  # 这句判断也有一定的影响, 所以不用. 建议使用target模式.    a[pid()] <<< t}probe process("/home/pg93/pgsql9.3.1/bin/postgres").mark("query__done") {  printdln("**", pid(), @count(a[pid()]), @avg(a[pid()]))  println("query__done ", user_string($arg1), "pid:", pid())  delete a}' -x 24829digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.023..2039.248 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared read=94393 Total runtime: 3065.989 ms(4 rows)digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.036..2039.643 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=32 read=94361 Total runtime: 3066.841 ms(4 rows)digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.034..2039.005 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=64 read=94329 Total runtime: 3066.746 ms(4 rows)query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2482924829**94417**3277query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24829query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2482924829**94361**3272query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24829query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2482924829**94329**3273query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24829
每次IO响应时间降到了3273纳秒左右, 几乎下降了一半, 所以说CPU 0不行啊.
最后把STAP的亲和设置为4, (与postgres进程分开使用物理CPU)那么会怎么样呢?
digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.055..2032.953 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=96 read=94297 Total runtime: 3059.635 ms(4 rows)digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.044..2034.114 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=128 read=94265 Total runtime: 3060.832 ms(4 rows)digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.043..2038.548 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=160 read=94233 Total runtime: 3065.674 ms(4 rows)
测得的IO响应时间又有了一定的下降, 说明还是有一定效果的. 但是相比不使用CPU 0 这里显得效果比较弱了.
query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2482924829**94297**3194query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24829query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2482924829**94265**3200query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24829query__start explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:2482924829**94233**3195query__done explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;pid:24829
最后在附一个未开启stap得到的结果.
digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.037..1812.712 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=192 read=94201 Total runtime: 2833.760 ms(4 rows)digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.038..1814.074 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=224 read=94169 Total runtime: 2835.363 ms(4 rows)digoal=# explain (analyze,verbose,costs,buffers,timing) select * from tbl_cost_align;                                                               QUERY PLAN                                                               ---------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on postgres.tbl_cost_align  (cost=0.00..195393.00 rows=10100000 width=45) (actual time=0.039..1814.641 rows=10100000 loops=1)   Output: id, info, crt_time   Buffers: shared hit=256 read=94137 Total runtime: 2840.508 ms(4 rows)
stap开启后, 查询时间长了220毫秒左右. 本文中每个handler带来的额外开销是 : 
digoal=# select 220/94137.0;        ?column?        ------------------------ 0.00233701945037551653(1 row)0.002337毫秒. 2337纳秒.
[参考]
1. man taskset
2. 
3. 

转载地址:http://ziczl.baihongyu.com/

你可能感兴趣的文章
jmeter响应时间与postman响应时间为什么不一样?
查看>>
HTTPonly属性
查看>>
WindowsDriver_知识_点滴
查看>>
显示磁盘信息
查看>>
关于使用索引的一些经验
查看>>
基于spark和sparkstreaming的word2vec
查看>>
常用正则表达式爬取网页信息及HTML分析总结
查看>>
selenium关于断言的使用
查看>>
eclipse 安装properties编辑器,显示中文
查看>>
C++系统学习之五:表达式
查看>>
java 格式化日期(转)
查看>>
【转】Automated Testing and the Test Pyramid
查看>>
[转] Mac下MySql卸载方法
查看>>
浙大版《C语言程序设计(第3版)》题目集 练习4-6 猜数字游戏 (15 分)
查看>>
ORA-00845: MEMORY_TARGET not supported on this system
查看>>
HashTable原理与源码分析
查看>>
JPA多对一单向关联
查看>>
系统查看硬件相关信息命令
查看>>
sublime 3 text 中运行Java
查看>>
前序遍历
查看>>