Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Server Memory - Chernivtsi JS 2019
Search
Андрей Листочкин (Andrey Listochkin)
June 22, 2019
Programming
160
1
Share
Server Memory - Chernivtsi JS 2019
Андрей Листочкин (Andrey Listochkin)
June 22, 2019
More Decks by Андрей Листочкин (Andrey Listochkin)
See All by Андрей Листочкин (Andrey Listochkin)
Everybody Stand Back! I Know Regular Expressions
listochkin
0
210
Command-line scripting with Rust. Wait, what?!
listochkin
0
420
Server Memory - BuildStuff Ukraine 2019
listochkin
0
67
10 Years Later
listochkin
0
390
Managing Managers - DevTalks iHUB
listochkin
0
77
Time, Numbers, Text
listochkin
1
640
Software Licensing: A Minefield Guide
listochkin
0
180
We Make Bots. For Real
listochkin
0
460
Devops for A Busy Developer - XP Days 2016
listochkin
0
190
Other Decks in Programming
See All in Programming
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
3
670
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
240
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
190
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
380
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
1.3k
GoogleCloudとterraform完全に理解した
terisuke
1
160
Vibe NLP for Applied NLP
inesmontani
PRO
0
480
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
150
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
1
440
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
160
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
110
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
200
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Odyssey Design
rkendrick25
PRO
2
580
Documentation Writing (for coders)
carmenintech
77
5.3k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
160
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
53k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
540
Transcript
None
@listochkin fb.com/tektonna
Not a JavaScript talk
No CSS No frameworks No Node
A bit deeper than most talks on similar subject
None
How programming languages work
Just-in-time compilers Garbage Collection
Memory Management
Server runs our programs
CPU Caches RAM Swap Disk Network
Operating System
None
Pages
4k
Virtual
2 processes [0 … ∞]
Oh, I got a pointer at 4096 What’s at 4095?
Page fault
Allocate page But not really
Once you start writing to it
not 4k?
None
None
malloc
None
malloc me some memory
a pointer
free(pointer)
malloc malloc malloc free malloc free free
Forget to free Free the wrong pointer Read from unallocated
memory
Can we do better?
Reference Counting
None
const players = [ … ] players.forEach(p => makeMove(p))
a = … doX(a) yield a
scope
if ( … ) { let a = … …
}
None
C++: std::shared_ptr
None
Optimizations
Delayed Counting
Don’t count local references
function (user) { let email = user.email; … … }
Delayed deallocation
Cycle Collector
None
None
Compile time ref-counting
Several types of pointers
Ownership
Forbids cycles by forbidding several owning references at the same
time
None
None
None
Perl 1987 - today Python 1991 - 2001 PHP 1994
- 2009
Multiprocess deploys
fork
Copy on Write
Worker Accepts requests As memory use raises: Stop accepting requests
Complete in-flight requests Terminate
Master Keep track on workers Start new workers Signal them
to terminate when memory pressure is high
“Pre-fork”
Load the framework Load app code Run full GC Start
forking process to accept requests
None
None
“Processes”
Tracing GC
1959 60 years ago
Start at Root references Follow all references Build a live
objects tree Delete all objects not part of the tree
Ruby Java JavaScript Lua Go
Roots?
Constants Global variables Local variables Closures Thread-locals ...
Mark & Sweep vs Mark-Compact
None
Can you move objects after mark?
Team Sweep: Go Ruby* Lua Embedded JS engines Erlang
Pros: Pointers don’t change Native extensions Easier to implement
Team Compact: Java JavaScript Ruby* Haskell
Pros: Less memory fragmentation over time Cons: Harder Takes longer
to do a GC
Mark all memory
None
Incremental Marking
3-colored algorithm by Dijkstra™
None
None
None
None
None
What is a barrier? if statement
else branch is very rare CPU branch predictor
Parallel marking
None
None
Lazy Sweep
Generational
Temporary data
Major vs Minor GC
Pointers from Old objects to new objects
Remembered Set
Major GC Scan roots only Bigger object graph
Minor GC Scan roots + RS Small object graph
None
Modern GCs are hybrid
None
None
C-extensions
Can’t move objects if their references are passed to an
extension
Can’t add WB
RGen GC
2 types of objects WB-protected WB-unprotected
WBu are never OldGen
OldGen -> WBu WBu to Remembered Set
Mark WBus on every minor GC
1 stw to mark all WBu in RS
None
None
Adding compaction for WBp
None
V8
Minor GC Parallel
Major Parallel marking Parallel / Concurrent Compact || Sweep
None
When to trigger GC?
Out-of-Bounds GC
request? Minor GCs response is sent? Major GC
Firefox Run GC in background tabs first instead of current
tab
Chrome Animation frame
Walking the memory
Cache locality
GPU
OS Pages pre-forked processes malloc zones GC Pages Remembered Sets
Barriers
None
None