Home > Database > Mysql Tutorial > sharedpool之二:freelists/sharedpoollrulist

sharedpool之二:freelists/sharedpoollrulist

WBOY
Release: 2016-06-07 15:23:05
Original
1284 people have browsed it

介绍free lists及shared pool lru list. free list 空闲列表 按bucket划分,共有255个,bucket 0---bucket 254 每个bucket上挂有一个 chunk list; free lists上的都是未使用的chunk RESERVED FREE LISTS: RESERVED FREE LISTS上的bucket个数我DUMP出来的是15

介绍free lists及shared pool lru list.

free list 空闲列表

按bucket划分,共有255个,bucket 0---bucket 254
每个bucket上挂有一个 chunk list; free lists上的都是未使用的chunk
RESERVED FREE LISTS:
RESERVED FREE LISTS上的bucket个数我DUMP出来的是15个。
保留FREE LISTS,在SQL语句所需CHUNK大于4400bytes时,会在RESERVED FREE LISTS中查找空闲CHUNK。
如果SQL语句所需CHUNK不大于4400bytes时,只会在free list 中查找CHUNK。
这个是由隐含参数控制的:_shared_pool_reserved_min_alloc minimum allocation size in bytes for reserved area ,默认值4400
###################
DUMP 共享池查看free lists/bucket/RESERVED FREE LISTS结构:--用新建会话来做
alter session set events 'immediate trace name heapdump level 2';
select value from v$diag_info where name like 'De%';
/u01/diag/rdbms/bys3/bys3/trace/bys3_ora_7876.trc
查看TRACE文件内容: --找这一段的方法:VI搜索HEAP DUMP
Chunk 2bffa844 sz= 22460 freeable "character set m"
Total heap size =146798680 -- 146798680/1024/1024 --139.99813 初始化参数:shared_pool_size--140M
FREE LISTS: ------空闲列,可以明显看出bucket大小分配的规律--从小到大,共有255个buckets,从16bytes到64k,采用此方法分配内存,可以有效的减少内存碎片。每个Bucket之间都用double linked 相互连接
Bucket 0 size=16
Chunk 2bc00048 sz= 0 kghdsx
Bucket 1 size=20 20字节的Bucket 1,有很多个Chunk,节约篇幅省略了
Chunk 23a60468 sz= 20 free " "
Chunk的地址、大小、状态
Chunk 23ceb498 sz= 20 free " "
Chunk 237fcde4 sz= 20 free " "
Bucket 2 size=24 --Bucket 2 --24字节
Chunk 245b13e4 sz= 24 free " "
Chunk 23ace7c0 sz= 24 free " "
Chunk 239c5a28 sz= 24 free " "
Bucket 3 size=28
Chunk 24540e9c sz= 28 free " "
Chunk 2521209c sz= 28 free " "
Chunk 23483448 sz= 28 free " "
……
Bucket 252 size=16396
Bucket 253 size=32780
Bucket 254 size=65548
Total free space = 518232
RESERVED FREE LISTS: --保留FREE LISTS,解析方法同上。保留池中CHUNK都比较大
Reserved bucket 0 size=16
Chunk 23420320 sz= 676 R-free " "
Chunk 23427b94 sz= 3420 R-free " "
Chunk 2342618c sz= 952 R-free " "
Chunk 23800050 sz= 1040 R-free " "
Chunk 23400050 sz= 2824 R-free " "
Chunk 25bff028 sz= 4032 R-free " "
Chunk 293ff788 sz= 2144 R-free " "
Reserved bucket 1 size=4400 --这个如果用的会,4564-4400,剩下164字节会成为新CHUNK
Chunk 23430a40 sz= 4564 R-free " "
Reserved bucket 2 size=8204
Reserved bucket 3 size=8460
Reserved bucket 4 size=8464
Reserved bucket 5 size=8468
Reserved bucket 6 size=8472
Chunk 2342b988 sz= 9136 R-free " "
Reserved bucket 7 size=9296
Reserved bucket 8 size=9300
Reserved bucket 9 size=12320
Reserved bucket 10 size=12324
Reserved bucket 11 size=16396
Chunk 234161f8 sz= 16448 R-free " "
Reserved bucket 12 size=32780
Reserved bucket 13 size=65548
Chunk 23401d50 sz= 72296 R-free " "
Chunk 23815668 sz= 125312 R-free " "
Chunk 23c00050 sz= 180380 R-free " "
Reserved bucket 14 size=1990652
Total reserved free space = 6712468 --总空闲保留空间是6.4M,shared_pool_reserved_size 初始化参数大小是 7M,用了0.6M
######################

shared pool LRU链

shared pool LRU链上挂的都是recreate状态的chunk,一个SQL语句可能需要多个CHUNK,在LRU链上找到recreate状态的chunk,然后在recreate状态的chunk下再下挂freeabl状态的CHUNK,--避免全部CHUNK在LRU链上导致LRU链太长。
TRACE文件中找到关于(lru first)的一段,方法同上:
Reserved bucket 14 size=1990652
Total reserved free space = 6712468
UNPINNED RECREATABLE CHUNKS (lru first):
Chunk 246c9848 sz= 348 recreate "KGLHD " latch=(nil) --latch状态为空,Chunk SIZE是348字节,状态recreate,
Chunk 237cb10c sz= 4096 recreate "KGLH0^b9197c6e " latch=(nil)
Chunk 24bb5df0 sz= 364 recreate "KGLHD " latch=(nil)
Chunk 241aa1b8 sz= 4096 recreate "KGLH0^59449e50 " latch=(nil)
Chunk 252640a0 sz= 364 recreate "KGLHD " latch=(nil)
Chunk 23a619a0 sz= 4096 recreate "KGLH0^d5f1e0d7 " latch=(nil)
Chunk 23465600 sz= 348 recreate "KGLHD " latch=(nil)
Chunk 2346575c sz= 1036 recreate "KGLHD " latch=(nil)
Chunk 23465b68 sz= 4096 recreate "KGLH0^c6e0d102 " latch=(nil) --一个recreate状态CHUNK下的多个freeable状态CHUNK
ds 24bdecb0 sz= 4096 ct= 1
Chunk 23466b68 sz= 4096 freeable "SQLA^1536bb77 " ds=0x23db5bd8
Chunk 23467b68 sz= 144 freeable "KGLDA "
Chunk 23467bf8 sz= 4096 freeable "KGLH0^ba3f9b05 " ds=0x2425e238
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template