[20190417]隐含参数_SPIN_COUNT.txt

--//在探究latch spin计数之前,先简单探究_SPIN_COUNT.实际上oracle现在版本latch spin的数量不再是2000,而是记录在
--//x$ksllclass里面.通过例子说明:

1.环境:
SYS@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> select * from x$ksllclass ;
ADDR                   INDX    INST_ID       SPIN      YIELD   WAITTIME     SLEEP0     SLEEP1     SLEEP2     SLEEP3     SLEEP4     SLEEP5     SLEEP6     SLEEP7
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00000000861986C0          0          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861986EC          1          1      20000          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198718          2          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
0000000086198744          3          1      20000          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198770          4          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
000000008619879C          5          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987C8          6          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987F4          7          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
8 rows selected.

SYS@book> select CLASS_KSLLT,count(*) from x$kslltr group by CLASS_KSLLT;
CLASS_KSLLT   COUNT(*)
----------- ----------
          2          1
          0        581
SYS@book> select CLASS_KSLLT,decode(CLASS_KSLLT,2,KSLLTNAM) name,count(*) from x$kslltr group by  CLASS_KSLLT,decode(CLASS_KSLLT,2,KSLLTNAM);
CLASS_KSLLT NAME               COUNT(*)
----------- ------------------ --------
          0                         581
          2 process allocation        1

--//还可以看出仅仅1个latch属于2类(latch name='process allocation').其它都是0类.实际上即使是0类,后面的SLEEP0-7不再使用.
--//可以发现缺省全部SPIN=20000.

2.测试1:
SYS@book> alter system set "_spin_count"=200 scope=memory;
System altered.

--//实际上动态修改无效.重新登录会话:
SYS@book> select * from x$ksllclass ;
ADDR                   INDX    INST_ID       SPIN      YIELD   WAITTIME     SLEEP0     SLEEP1     SLEEP2     SLEEP3     SLEEP4     SLEEP5     SLEEP6     SLEEP7
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00000000861986C0          0          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861986EC          1          1      20000          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198718          2          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
0000000086198744          3          1      20000          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198770          4          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
000000008619879C          5          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987C8          6          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987F4          7          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
8 rows selected.

--//SPIN数量不变.实际上动态修改,对应exclusive latch无效.仅仅对shared latch有效,导致实际spin 数量等于_spin_count*2.(我当前没有测试)
--//参考链接:http://andreynikolaev.wordpress.com/2011/01/14/spin-tales-part-2-shared-latches-in-oracle-9-2-11g/

3.测试2:
SYS@book> alter system set "_spin_count"=200 scope=spfile ;
System altered.

--//重启数据库观察:
SYS@book> select * from x$ksllclass ;
ADDR                   INDX    INST_ID       SPIN      YIELD   WAITTIME     SLEEP0     SLEEP1     SLEEP2     SLEEP3     SLEEP4     SLEEP5     SLEEP6     SLEEP7
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00000000861986C0          0          1        200          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861986EC          1          1        200          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198718          2          1        200          0          1       8000       8000       8000       8000       8000       8000       8000       8000
0000000086198744          3          1        200          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198770          4          1        200          0          1       8000       8000       8000       8000       8000       8000       8000       8000
000000008619879C          5          1        200          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987C8          6          1        200          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987F4          7          1        200          0          1       8000       8000       8000       8000       8000       8000       8000       8000
8 rows selected.
--//这样更改才生效.
SYS@book> alter system reset "_spin_count";
System altered.

--//实际上可以但是设置_latch_class_N参数.
SYS@book> alter system set "_latch_class_0"=1000 scope=spfile;
System altered.

--//重启数据库观察:
SYS@book> select * from x$ksllclass ;
ADDR                   INDX    INST_ID       SPIN      YIELD   WAITTIME     SLEEP0     SLEEP1     SLEEP2     SLEEP3     SLEEP4     SLEEP5     SLEEP6     SLEEP7
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00000000861986C0          0          1       1000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861986EC          1          1      20000          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198718          2          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
0000000086198744          3          1      20000          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198770          4          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
000000008619879C          5          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987C8          6          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987F4          7          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
8 rows selected.

--//你甚至指定特定的latch采用特定的类.还可以修改后面的YIELD,WAITTIME,SLEEP0-SELLP7值.例子:
*._latch_classes='8:3'
*._latch_class_3='100 0 1 10000 20000 30000 40000 50000 60000 70000 80000'

SYS@book> select * from v$latchname where name='process allocation';
    LATCH# NAME                                           HASH
---------- ---------------------------------------- ----------
         8 process allocation                       2600548697

--//_latch_classes 里面8 值LATCH#,后面3值类.可以指定多个,例子:
--//alter system set "_latch_classes"='46:3 103:3' scope=spfile;
--//还原:
SYS@book> alter system reset "_latch_class_0";
System altered.

4.加强记忆我找一个latch测试看看:
--//上午测试是process allocation,现在测试看看类0的修改是否有效.
select addr,name,level#,latch#,gets,misses,sleeps,immediate_gets,immediate_misses,waiters_woken,waits_holding_latch,spin_gets,wait_time from v$latch_parent   where lower(name) like '%'||lower('test excl. parent l0')||'%'
ADDR             NAME                                         LEVEL#     LATCH#       GETS     MISSES     SLEEPS IMMEDIATE_GETS IMMEDIATE_MISSES WAITERS_WOKEN WAITS_HOLDING_LATCH  SPIN_GETS  WAIT_TIME
---------------- ---------------------------------------- ---------- ---------- ---------- ---------- ---------- -------------- ---------------- ------------- ------------------- ---------- ----------
00000000600098D8 test excl. parent l0                              0          4          7          0          0              0                0             0                   0          0          0

--//LATCH#=4.
SYS@book> create pfile='/tmp/@.ora' from spfile ;
File created.

--//修改/tmp/book.ora 加入:
*._latch_classes='4:3'
*._latch_class_3='100 0 1 10000 20000 30000 40000 50000 60000 70000 50000'

SYS@book> startup pfile=/tmp/@.ora
ORACLE instance started.
Total System Global Area  643084288 bytes
Fixed Size                  2255872 bytes
Variable Size             205521920 bytes
Database Buffers          427819008 bytes
Redo Buffers                7487488 bytes
Database mounted.
Database opened.

SYS@book> select * from x$ksllclass ;
ADDR                   INDX    INST_ID       SPIN      YIELD   WAITTIME     SLEEP0     SLEEP1     SLEEP2     SLEEP3     SLEEP4     SLEEP5     SLEEP6     SLEEP7
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00000000861986C0          0          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861986EC          1          1      20000          0          1       1000       1000       1000       1000       1000       1000       1000       1000
0000000086198718          2          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
0000000086198744          3          1        100          0          1      10000      20000      30000      40000      50000      60000      70000      50000
0000000086198770          4          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
000000008619879C          5          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987C8          6          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
00000000861987F4          7          1      20000          0          1       8000       8000       8000       8000       8000       8000       8000       8000
8 rows selected.

SYS@book> select CLASS_KSLLT,decode(CLASS_KSLLT,2,KSLLTNAM,3,KSLLTNAM) name,count(*) from x$kslltr group by  CLASS_KSLLT,decode(CLASS_KSLLT,2,KSLLTNAM,3,KSLLTNAM);
CLASS_KSLLT NAME                                       COUNT(*)
----------- ---------------------------------------- ----------
          0                                                 580
          3 test excl. parent l0                              1
          2 process allocation                                1
--//latch_name='test excl. parent l0',CLASS_KSLLT=3.

$ cat p4.sh
#! /bin/bash
vdate=$(date '+%H%M%S')
echo $vdate

source peek.sh "$1" 20 | timestamp.pl >| /tmp/peekx_${vdate}.txt &

sqlplus -s -l / as sysdba <<EOF  >| /tmp/latch_free_${vdate}.txt &
$(seq 20 | xargs -I {} echo -e '@latch_free \n host sleep 1')
EOF

sleep 1
# 参数如下: @ exclusive_latch.txt latch_name willing why where  sleep_num
sqlplus /nolog @ exclusive_latch.txt "$1" 1 4 5 10 > /dev/null &
sleep 2
sqlplus /nolog @ exclusive_latch.txt "$1" 1 6 7 10 > /dev/null &
p=$!
strace -ftrT  -p $p -o /tmp/pp_${vdate}.txt > /dev/null &
wait

$ . p4.sh 'test excl. parent l0'
172843
Process 29626 attached - interrupt to quit
Process 29628 attached
Process 29645 attached
Process 29626 suspended
[1]   Done                    source peek.sh "$1" 20 | timestamp.pl >|/tmp/peekx_${vdate}.txt
[3]   Done                    sqlplus /nolog @ exclusive_latch.txt "$1" 1 4 5 10 > /dev/null
[2]   Done                    sqlplus -s -l / as sysdba  >|/tmp/latch_free_${vdate}.txt <<EOF
$(seq 20 | xargs -I {} echo -e '@latch_free \n host sleep 1')
EOF

Process 29626 resumed
Process 29645 detached
Process 29626 detached
[4]-  Done                    sqlplus /nolog @ exclusive_latch.txt "$1" 1 6 7 10 > /dev/null
Process 29628 detached
[5]+  Done                    strace -ftrT -p $p -o /tmp/pp_${vdate}.txt > /dev/null

--// /tmp/pp_172843.txt
29628      0.000081 write(10, "\n", 1)  = 1 <0.000026>
29628      0.000149 select(0, [], [], [], {0, 10000}) = 0 (Timeout) <0.010082>
29628      0.010161 select(0, [], [], [], {0, 20000}) = 0 (Timeout) <0.020110>
29628      0.020195 select(0, [], [], [], {0, 30000}) = 0 (Timeout) <0.030115>
29628      0.030207 select(0, [], [], [], {0, 40000}) = 0 (Timeout) <0.040118>
29628      0.040216 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050120>
29628      0.050209 select(0, [], [], [], {0, 60000}) = 0 (Timeout) <0.060129>
29628      0.060218 select(0, [], [], [], {0, 70000}) = 0 (Timeout) <0.070140>
29628      0.070230 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050124>
29628      0.050213 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050118>
29628      0.050207 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050124>
29628      0.050216 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050134>
29628      0.050224 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050117>
29628      0.050207 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050120>
29628      0.050209 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050117>
29628      0.050206 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050120>
29628      0.050211 select(0, [], [], [], {0, 50000}) = 0 (Timeout) <0.050125>
--//可以发现一样有效.

$ awk '/select/ {print $NF}' /tmp/pp_172843.txt | tr -d '<>' | xargs | sed 's/ /+/g' | bc -l
7.899805
--//接近8秒.spin占用时间不多.

[20190417]隐含参数_SPIN_COUNT.txt的更多相关文章

  1. [20190401]隐含参数_mutex_spin_count.txt

    [20190401]隐含参数_mutex_spin_count.txt --//上午做了一些测试关于semtimedop函数调用,发现自己上个星期在一些问题上理解错误.--//相关链接:--//htt ...

  2. [20191206]隐含参数_db_always_check_system_ts.txt

    [20191206]隐含参数_db_always_check_system_ts.txt --//今年年头我做tab$删除恢复时,遇到的问题,就是遇到延迟块清除的问题.参考链接:http://blog ...

  3. [20181108]12c sqlplus rowfetch参数4.txt

    [20181108]12c sqlplus rowfetch参数4.txt --//12cR2 可以改变缺省rowfetch参数.11g之前缺省是1.通过一些测试说明问题.--//前几天做的测试有点乱 ...

  4. 转 rman-08120 以及查询隐含参数

    rman-08120 We need RMAN to automatically purge archivelogs from the FRA once they are applied to the ...

  5. js的隐含参数(arguments,callee,caller)使用方法

    在提到上述的概念之前,首先想说说javascript中函数的隐含参数: arguments arguments 该对象代表正在执行的函数和调用它的函数的参数.[function.]arguments[ ...

  6. paip.提升性能---mysql 性能 测试以及 参数调整.txt

    paip.提升性能---mysql 性能 测试以及 参数调整.txt 作者Attilax  艾龙,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://b ...

  7. paip.提升性能----jvm参数调整.txt

    paip.提升性能----jvm参数调整.txt 作者Attilax  艾龙,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.n ...

  8. 传递给函数的隐含参数:arguments及递归函数的实现

    传递给函数的隐含参数:arguments当进行函数调用时,除了指定的参数外,还创建一个隐含的对象——arguments.arguments是一个类似数组但不是数组的对象,说它类似是因为它具有数组一样的 ...

  9. [20170927]hugepages与内核参数nr_overcommit_hugepages.txt

    [20170927]hugepages与内核参数nr_overcommit_hugepages.txt /proc/sys/vm/nr_overcommit_hugepages specifies h ...

随机推荐

  1. 我爱Java系列之《JavaEE学习笔记day12》---【缓冲流、转换流、序列/反序列化流、打印流】

    [缓冲流.转换流.序列/反序列化流.打印流] 一.缓冲流 1.字节缓冲输出流 java.io.BufferedOutputStream extends OutputStream 高效字节输出流 写入文 ...

  2. svn统计代码行数(增量)

    转载请标明出处,维权必究:https://www.cnblogs.com/tangZH/p/10770296.html android代码,两个版本之间,代码行数增加了多少,怎么得出呢? 1.安装To ...

  3. spring Boot环境下dubbo+zookeeper的一个基础讲解与示例

    一,学习背景 1.   前言 对于我们不管工作还是生活中,需要或者想去学习一些东西的时候,大致都考虑几点: a)      我们为什么需要学习这个东西? b)     这个东西是什么? c)      ...

  4. python3 树莓派 + usb摄像头 做颜色识别 二维码识别

    今天又啥也没干 我完蛋了哦  就是没办法沉下心来,咋办....还是先来条NLP吧.. 七,凡事必有至少三个解决方法 对事情只有一个方法的人,必陷入困境,因为别无选择. 对事情有两个方法的人也陷入困境, ...

  5. dotnet中Stream、string及byte[]的相关操作

    string与byte[](UTF-8) //string to byte[] string str = "abc中文"; //0x61 0x62 0x63 0xE4 0xB8 0 ...

  6. springboot+aop切点记录请求和响应信息

    本篇主要分享的是springboot中结合aop方式来记录请求参数和响应的数据信息:这里主要讲解两种切入点方式,一种方法切入,一种注解切入:首先创建个springboot测试工程并通过maven添加如 ...

  7. springboot + redis(单机版)

    本次和大家分享的是在springboot集成使用redis,这里使用的是redis的jedis客户端(这里我docker运行的redis,可以参考 docker快速搭建几个常用的第三方服务),如下添加 ...

  8. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之二 || 后端项目搭建

    前言 至于为什么要搭建.Net Core 平台,这个网上的解释以及铺天盖地,想了想,还是感觉重要的一点,跨平台,嗯!没错,而且比.Net 更容易搭建,速度也更快,所有的包均有Nuget提供,不再像以前 ...

  9. 机器学习之十一问支持向量机(SVM)

    推导了支持向量机的数学公式后,还需要对比和总结才能更深入地理解这个模型,所以整理了十一个关于支持向量机的问题. 第一问:支持向量机和感知机(Perceptron)的联系? 1.相同点: 都是一种属于监 ...

  10. 解决mac上每次升级nodejs都要重新安装扩展包的问题

    虽然有了一些新生派竞品比如yarn,但使用或者习惯了npm的开发者仍然大有人在. 以前用起来没注意到这个现象,最近一段时间发现,每次随着使用brew upgrade自动升级了nodejs版本,原来安装 ...