Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Memcached内存管理
Search
jiangbo
August 31, 2012
1.6k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Memcached内存管理
jiangbo
August 31, 2012
More Decks by jiangbo
See All by jiangbo
HDFS RAID
jiangbo
0
4k
HDFS
jiangbo
0
200
awk
jiangbo
4
340
vim
jiangbo
8
510
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
280
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
820
Music & Morning Musume
bryan
48
7.5k
Writing Fast Ruby
sferik
630
63k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Typedesign – Prime Four
hannesfritz
42
3.2k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
880
It's Worth the Effort
3n
188
29k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
650
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
510
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1.1k
Transcript
Memcached ଘཧ jiangbo$_ @mokeyj Friday, August 31, 12
Slab, Page, Chunk, Item Chunk ^ +------------------|------------------------------------------------------------+ | Memory |
| | +---------------|---------------------------------------------------------+ | | | +--------|---------------------+ +------------------------------+ | | | | |Page1 +-|---+ +-----+ +-----+ | |Page2 +-----+ +-----+ +-----+ | | | | | Slab |(1M) | 96B | | 68B | | 72B | | |(1M) | 92B | | 76B | | 84B | | | | | | 1 | +-----+ +-----+ +-----+ | | +-----+ +-----+ +-----+ | | | | | +------------------------------+ +------------------------------+ | | | +-------------------------------------------------------------------------+ | | | | +-------------------------------------------------------------------------+ | | | +------------------------------+ +------------------------------+ | | | | |Page1 +------+ +------+ | |Page2 +------+ +-------+ | | | | | Slab | (1M) | 128B | | 120B | | |(1M) | 128B | | 97B | | | | | | 2 | +------+ +------+ | | +------+ +-------+ | | | | | +------------------------------+ +------------------------------+ | | | +-------------------------------------------------------------------------+ | +-------------------------------------------------------------------------------+ Friday, August 31, 12
Item +---------------------------------------+ | key-value | cas | suffix | item
head | +---------------------------------------+ 实际ଘ์తਾ Item Size= data size + 32bytes item head Friday, August 31, 12
Chunk +------------------------------+ | data item | empty space | +------------------------------+
ଘ์ਾత࠷খ单ݩ Friday, August 31, 12
Page +-------------------------------------+ | chunk1 | chunk2 | chunk3 | chunk4
| +-------------------------------------+ ਃ请༻ଘత࠷খۭ间ɼ ᘍ认为1M Friday, August 31, 12
Slab +--------------------------------+ | Page1 | Page2 | Page3 | Page4
| +--------------------------------+ ҈chunkେখෆಉ䎞কଘ䎞ଟslabۭ间 Friday, August 31, 12
Slabॳ࢝Խ • ࠜਾෆಉతchunk_size䎞为ଟslabۭ间 • ॳ࢝࠷খchunk_sizeʢᘍ认为80=48+32ʣ • ࠜਾfactor҈ൺྫ递⃧ʢᘍ认1.25ʣ ࢀ⻅见 slabs.cதslabs_init() Friday,
August 31, 12
ਾଘ储 • 计ࢉitemେখɼፙ౸߹㭕తslab • ਗ਼ཧ该slabதత过ظchunk • ༗过ظchunkɼ则ਃ请৽ۭ间(slab_alloc) • ਃ请ۭ间ࣦ败ɼ༻LRUஞग़ ࢀ⻅见item.cதdo_item_alloc()
Friday, August 31, 12
ਃ请Slab • ဓSlotsྻදதਃ请 • ༗则ਃ请ҰPageత৽ۭ间 • ਃ请ۭ间ੋձઌஅslab_reasignɼᘍ认ෆ 䇖启 ࢀ⻅见slabs.cதslab_alloc() Friday,
August 31, 12
ଘ࿘费 • Item Size <= Chunk Size • Page Size%Chunk
Size ? • ቮ给slabతۭ间ᘍ认ෆճᏅ Friday, August 31, 12
Ҋྫੳ • ఆ⻓长问题导கେྔஞग़ Friday, August 31, 12
THX Friday, August 31, 12