SlideShare una empresa de Scribd logo
1 de 35
Scope Stack Allocation Andreas Fredriksson, DICE <dep@dice.se>
Contents What are Scope Stacks? Background – embedded systems Linear memory allocation Scope Stacks Bits and pieces
What are Scope Stacks? A memory management tool Linear memory layout of arbitrary object hierarchies Support C++ object life cycle if desired Destructors called in correct dependency order Super-duper oiled-up fast! Makes debugging easier
Background Why is all this relevant? Console games are embedded systems Fixed (small) amount of memory Can't run out of memory or you can't ship – fragmentation is a serious issue Heap allocation is very expensive Lots of code for complex heap manager Bad cache locality Allocation & deallocation speed
Embedded systems With a global heap, memory fragments Assume 10-15% wasted with good allocator Can easily get 25% wasted with poor allocator Caused by allocating objects with mixed life time next to each other Temporary stuff allocated next to semi-permanent stuff (system arrays etc)
Heap Fragmentation Each alloc has to traverse the free list of this structure! Assuming “best fit” allocator for less fragmentation Will likely cache miss for each probed location Large blocks disappear quickly
Memory Map Ideally we would like fully deterministic memory map Popular approach on console Partition all memory up front Load new level Rewind level part only Reconfigure systems Rewind both level, systems Fragmentation not possible
Linear Allocation Many games use linear allocators to achieve this kind of memory map Linear allocators basically sit on a pointer Allocations just increment the pointer To rewind, reset the pointer Very fast, but only suitable for POD data No finalizers/destructors called Used in Frostbite's renderer for command buffers
Linear Allocator Implementation Simplified C++ example Real implementation needs checks, alignment In retail build, allocation will be just a few cycles  1 class LinearAllocator {  2 // ...  3     u8 *allocate(size_t size) {  4 return m_ptr += size;  5     }  6 void rewind(u8 *ptr) {  7         m_ptr = ptr;  8     }  9 // ... 10     u8 *m_ptr; 11 };
Using Linear Allocation We're implementing FrogSystem A new system tied to the level Randomly place frogs across the level as the player is moving around Clearly the Next Big Thing Design for linear allocation Grab all memory up front Mr FISK (c) FLT Used with permission
FrogSystem - Linear Allocation Simplified C++ example  1 struct FrogInfo { ... };  2  3 struct FrogSystem {  4 // ...  5 int maxFrogs;  6     FrogInfo *frogPool;  7 };  8  9 FrogSystem* FrogSystem_init(LinearAllocator& alloc) { 10     FrogSystem *self = alloc.allocate(sizeof(FrogSystem)); 11     self->maxFrogs = ...; 12     self->frogPool = alloc.allocate(sizeof(FrogInfo) * self->maxFrogs); 13 return self; 14 } 15 16 void FrogSystem_update(FrogSystem *system) { 17 // ... 18 }
Resulting Memory Layout FrogSystem Frog Pool Allocation Point POD Data
Linear allocation limitations Works well until we need resource cleanup File handles, sockets, ... Pool handles, other API resources This is the “systems programming” aspect Assume frog system needs a critical section Kernel object Must be released when no longer used
FrogSystem – Adding a lock  1 class FrogSystem {  2     CriticalSection *m_lock;  3  4     FrogSystem(LinearAllocator& a)  5 // get memory  6     ,   m_lock((CriticalSection*) a.allocate(sizeof(CriticalSection)))  7 // ...  8     {  9 new (m_lock) CriticalSection; // construct object 10     } 11 12     ~FrogSystem() { 13         m_lock->~CriticalSection(); // destroy object 14     } 15 }; 16 17 FrogSystem* FrogSystem_init(LinearAllocator& a) { 18 returnnew (a.allocate(sizeof(FrogSystem))) FrogSystem(a); 19 } 20 21 void FrogSystem_cleanup(FrogSystem *system) { 22     system->~FrogSystem(); 23 }
Resulting Memory Layout FrogSystem Frog Pool CritialSect Allocation Point POD Data Object with cleanup
Linear allocation limitations Code quickly drowns in low-level details Lots of boilerplate We must add a cleanup function Manually remember what resources to free Error prone In C++, we would rather rely on destructors
Scope Stacks Introducing Scope Stacks Sits on top of linear allocator Rewinds part of underlying allocator when destroyed Designed to make larger-scale system design with linear allocation possible Maintain a list of finalizers to run when rewinding Only worry about allocation, not cleanup
Scope Stacks, contd. Type itself is a lightweight construct  1 struct Finalizer {  2 void (*fn)(void *ptr);  3     Finalizer *chain;  4 };  5  6 class ScopeStack {  7     LinearAllocator& m_alloc;  8 void *m_rewindPoint;  9     Finalizer *m_finalizerChain; 10 11 explicit ScopeStack(LinearAllocator& a); 12     ~ScopeStack(); // unwind 13 14 template <typename T> T* newObject(); 15 template <typename T> T* newPOD(); 16 }; 17
Scope Stacks, contd. Can create a stack of scopes on top of a single linear allocator Only allocate from topmost scope Can rewind scopes as desired For example init/systems/level Finer-grained control over nested lifetimes Can also follow call stack Very elegant per-thread scratch pad
Scope Stack Diagram Linear Allocator Scope Scope Active Scope
Scope Stack API Simple C++ interface scope.newObject<T>(...) - allocate object with cleanup (stores finalizer) scope.newPod<T>(...) - allocate object without cleanup scope.alloc(...) - raw memory allocation Can also implement as C interface Similar ideas in APR (Apache Portable Runtime)
Scope Stack Implementation newObject<T>()  1 template <typename T>  2 void destructorCall(void *ptr) {  3 static_cast<T*>(ptr)->~T();  4 }  5  6 template <typename T>  7 T* ScopeStack::newObject() {  8 // Allocate memory for finalizer + object.  9     Finalizer* f = allocWithFinalizer(sizeof(T)); 10 11 // Placement construct object in space after finalizer. 12     T* result = new (objectFromFinalizer(f)) T; 13 14 // Link this finalizer onto the chain. 15     f->fn = &destructorCall<T>; 16     f->chain = m_finalizerChain; 17     m_finalizerChain = f; 18 return result; 19 }
FrogSystem – Scope Stacks Critical Section example with Scope Stack  1 class FrogSystem {  2 // ...  3     CriticalSection *m_lock;  4  5     FrogSystem(ScopeStack& scope)  6     :   m_lock(scope.newObject<CriticalSection>())  7 // ...  8     {}  9 10 // no destructor needed! 11 }; 12 13 FrogSystem* FrogSystem_init(ScopeStack& scope) { 14 return scope.newPod<FrogSystem>(); 15 }
Memory Layout (with context) FrogSystem Frog Pool CritialSect (other stuff) ... Allocation Point POD Data Object with cleanup Finalizer record Scope
Scope Cleanup With finalizer chain in place we can unwind without manual code Iterate linked list Call finalizer for objects that require cleanup POD data still zero overhead Finalizer for C++ objects => destructor call
Per-thread allocation Scratch pad = Thread-local linear allocator Construct nested scopes on this allocator Utility functions can lay out arbitrary objects on scratch pad scope  1 class File; // next slide  2  3 constchar *formatString(ScopeStack& scope, constchar *fmt, ...);  4  5 void myFunction(constchar *fn) {  6     ScopeStack scratch(tls_allocator);  7 constchar *filename = formatString(scratch, "foo/bar/%s", fn);  8     File *file = scratch.newObject<File>(scratch, filename);  9 10     file->read(...); 11 12 // No cleanup required! 13 }
Per-thread allocation, contd. File object allocates buffer from designed scope Doesn't care about lifetime – its buffer and itself will live for exactly the same time Can live on scratch pad without knowing it  1 class File {  2 private:  3     u8 *m_buffer;  4 int m_handle;  5 public:  6     File(ScopeStack& scope, constchar *filename)  7     :   m_buffer(scope.alloc(8192))  8     ,   m_handle(open(filename, O_READ))  9     {} 10 11     ~File() { 12         close(m_handle); 13     } 14 };
Memory Layout: Scratch Pad File Buffer Filename File Allocation Point Old Allocation Point POD Data Object with cleanup Finalizer record Rewind Point Scope Parent Scope
PIMPL C++ addicts can enjoy free PIMPL idiom Because allocations are essentially “free”; PIMPL idiom becomes more attractive Can slim down headers and hide all data members without concern for performance
Limitations Must set upper bound all pool sizes Can never grow an allocation This design style is classical in games industry But pool sizes can vary between levels! Reconfigure after rewind By default API not thread safe Makes sense as this is more like layout than allocation Pools/other structures can still be made thread safe once memory is allocated
Limitations, contd. Doesn't map 100% to C++ object modeling But finalizers enable RAII-like cleanup Many traditional C++ tricks become obsolete Pointer swapping Reference counting Must always think about lifetime and ownership when allocating Lifetime determined on global level Can't hold on to pointers – unwind = apocalypse Manage on higher level instead
Conclusion Scope stacks are a system programming tool Suitable for embedded systems with few variable parameters – games Requires planning and commitment Pays dividends in speed and simplicity Same pointers every time – debugging easier Out of memory analysis usually very simple Either the level runs, or doesn't run Can never fail half through
Links Toy implementation of scope stacks For playing with, not industrial strength http://pastebin.com/h7nU8JE2 “Start Pre-allocating And Stop Worrying” - Noel Llopis http://gamesfromwithin.com/start-pre-allocating-and-stop-worrying Apache Portable Runtime http://apr.apache.org/
Questions
Bonus: what about.. ..building an array, final size unknown? Standard approach in C++: STL vector push Instead build linked list/dequeue on scratch pad Allocate array in target scope stack once size is known ..dynamic lifetime of individual objects? Allocate object pool from scope stack Requires bounding the worst case – a good idea for games anyway

Más contenido relacionado

La actualidad más candente

Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Johan Andersson
 
Killzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo PostmortemKillzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo PostmortemGuerrilla
 
BitSquid Tech: Benefits of a data-driven renderer
BitSquid Tech: Benefits of a data-driven rendererBitSquid Tech: Benefits of a data-driven renderer
BitSquid Tech: Benefits of a data-driven renderertobias_persson
 
Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666Tiago Sousa
 
Screen Space Reflections in The Surge
Screen Space Reflections in The SurgeScreen Space Reflections in The Surge
Screen Space Reflections in The SurgeMichele Giacalone
 
Optimizing the graphics pipeline with compute
Optimizing the graphics pipeline with computeOptimizing the graphics pipeline with compute
Optimizing the graphics pipeline with computeWuBinbo
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility bufferWolfgang Engel
 
Z Buffer Optimizations
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizationspjcozzi
 
Optimizing Large Scenes in Unity
Optimizing Large Scenes in UnityOptimizing Large Scenes in Unity
Optimizing Large Scenes in UnityNoam Gat
 
Dynamic Resolution and Interlaced Rendering
Dynamic Resolution and Interlaced RenderingDynamic Resolution and Interlaced Rendering
Dynamic Resolution and Interlaced RenderingMartinMueller34
 
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...Johan Andersson
 
Stylized Rendering in Battlefield Heroes
Stylized Rendering in Battlefield HeroesStylized Rendering in Battlefield Heroes
Stylized Rendering in Battlefield HeroesElectronic Arts / DICE
 
A Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering SystemA Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering SystemBo Li
 
Bindless Deferred Decals in The Surge 2
Bindless Deferred Decals in The Surge 2Bindless Deferred Decals in The Surge 2
Bindless Deferred Decals in The Surge 2Philip Hammer
 
Forward+ (EUROGRAPHICS 2012)
Forward+ (EUROGRAPHICS 2012)Forward+ (EUROGRAPHICS 2012)
Forward+ (EUROGRAPHICS 2012)Takahiro Harada
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonAMD Developer Central
 
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunElectronic Arts / DICE
 

La actualidad más candente (20)

Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
 
Killzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo PostmortemKillzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo Postmortem
 
BitSquid Tech: Benefits of a data-driven renderer
BitSquid Tech: Benefits of a data-driven rendererBitSquid Tech: Benefits of a data-driven renderer
BitSquid Tech: Benefits of a data-driven renderer
 
Light prepass
Light prepassLight prepass
Light prepass
 
Frostbite on Mobile
Frostbite on MobileFrostbite on Mobile
Frostbite on Mobile
 
Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666
 
Screen Space Reflections in The Surge
Screen Space Reflections in The SurgeScreen Space Reflections in The Surge
Screen Space Reflections in The Surge
 
Optimizing the graphics pipeline with compute
Optimizing the graphics pipeline with computeOptimizing the graphics pipeline with compute
Optimizing the graphics pipeline with compute
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility buffer
 
Z Buffer Optimizations
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizations
 
Optimizing Large Scenes in Unity
Optimizing Large Scenes in UnityOptimizing Large Scenes in Unity
Optimizing Large Scenes in Unity
 
Dynamic Resolution and Interlaced Rendering
Dynamic Resolution and Interlaced RenderingDynamic Resolution and Interlaced Rendering
Dynamic Resolution and Interlaced Rendering
 
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
 
Stylized Rendering in Battlefield Heroes
Stylized Rendering in Battlefield HeroesStylized Rendering in Battlefield Heroes
Stylized Rendering in Battlefield Heroes
 
A Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering SystemA Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering System
 
Bindless Deferred Decals in The Surge 2
Bindless Deferred Decals in The Surge 2Bindless Deferred Decals in The Surge 2
Bindless Deferred Decals in The Surge 2
 
A Real-time Radiosity Architecture
A Real-time Radiosity ArchitectureA Real-time Radiosity Architecture
A Real-time Radiosity Architecture
 
Forward+ (EUROGRAPHICS 2012)
Forward+ (EUROGRAPHICS 2012)Forward+ (EUROGRAPHICS 2012)
Forward+ (EUROGRAPHICS 2012)
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
 

Destacado

How data rules the world: Telemetry in Battlefield Heroes
How data rules the world: Telemetry in Battlefield HeroesHow data rules the world: Telemetry in Battlefield Heroes
How data rules the world: Telemetry in Battlefield HeroesElectronic Arts / DICE
 
5 Major Challenges in Interactive Rendering
5 Major Challenges in Interactive Rendering5 Major Challenges in Interactive Rendering
5 Major Challenges in Interactive RenderingElectronic Arts / DICE
 
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3Electronic Arts / DICE
 
Battlelog - Building scalable web sites with tight game integration
Battlelog - Building scalable web sites with tight game integrationBattlelog - Building scalable web sites with tight game integration
Battlelog - Building scalable web sites with tight game integrationElectronic Arts / DICE
 
Destruction Masking in Frostbite 2 using Volume Distance Fields
Destruction Masking in Frostbite 2 using Volume Distance FieldsDestruction Masking in Frostbite 2 using Volume Distance Fields
Destruction Masking in Frostbite 2 using Volume Distance FieldsElectronic Arts / DICE
 
Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)
 	 Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09) 	 Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)
Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)Johan Andersson
 
Building the Battlefield AI Experience
Building the Battlefield AI ExperienceBuilding the Battlefield AI Experience
Building the Battlefield AI ExperienceElectronic Arts / DICE
 
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal FilteringStable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal FilteringElectronic Arts / DICE
 
Level Design Challenges & Solutions - Mirror's Edge
Level Design Challenges & Solutions - Mirror's EdgeLevel Design Challenges & Solutions - Mirror's Edge
Level Design Challenges & Solutions - Mirror's EdgeElectronic Arts / DICE
 

Destacado (12)

How data rules the world: Telemetry in Battlefield Heroes
How data rules the world: Telemetry in Battlefield HeroesHow data rules the world: Telemetry in Battlefield Heroes
How data rules the world: Telemetry in Battlefield Heroes
 
5 Major Challenges in Interactive Rendering
5 Major Challenges in Interactive Rendering5 Major Challenges in Interactive Rendering
5 Major Challenges in Interactive Rendering
 
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
 
Battlelog - Building scalable web sites with tight game integration
Battlelog - Building scalable web sites with tight game integrationBattlelog - Building scalable web sites with tight game integration
Battlelog - Building scalable web sites with tight game integration
 
Destruction Masking in Frostbite 2 using Volume Distance Fields
Destruction Masking in Frostbite 2 using Volume Distance FieldsDestruction Masking in Frostbite 2 using Volume Distance Fields
Destruction Masking in Frostbite 2 using Volume Distance Fields
 
Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)
 	 Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09) 	 Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)
Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)
 
Building the Battlefield AI Experience
Building the Battlefield AI ExperienceBuilding the Battlefield AI Experience
Building the Battlefield AI Experience
 
Bending the Graphics Pipeline
Bending the Graphics PipelineBending the Graphics Pipeline
Bending the Graphics Pipeline
 
A Step Towards Data Orientation
A Step Towards Data OrientationA Step Towards Data Orientation
A Step Towards Data Orientation
 
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal FilteringStable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
 
Introduction to Data Oriented Design
Introduction to Data Oriented DesignIntroduction to Data Oriented Design
Introduction to Data Oriented Design
 
Level Design Challenges & Solutions - Mirror's Edge
Level Design Challenges & Solutions - Mirror's EdgeLevel Design Challenges & Solutions - Mirror's Edge
Level Design Challenges & Solutions - Mirror's Edge
 

Similar a Scope Stack Allocation

Improving app performance using .Net Core 3.0
Improving app performance using .Net Core 3.0Improving app performance using .Net Core 3.0
Improving app performance using .Net Core 3.0Richard Banks
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory Optimizationguest3eed30
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory OptimizationWei Lin
 
NET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptxNET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptxpetabridge
 
Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2ppd1961
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETMaarten Balliauw
 
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management....NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...NETFest
 
(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart PointersCarlo Pescio
 
CodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneCodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneMaarten Balliauw
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)bolovv
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in productionParis Data Engineers !
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internalsKostas Tzoumas
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelVitaly Nikolenko
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bChereCheek752
 

Similar a Scope Stack Allocation (20)

Improving app performance using .Net Core 3.0
Improving app performance using .Net Core 3.0Improving app performance using .Net Core 3.0
Improving app performance using .Net Core 3.0
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory Optimization
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory Optimization
 
Introduction to c part -3
Introduction to c   part -3Introduction to c   part -3
Introduction to c part -3
 
NET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptxNET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptx
 
Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
 
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management....NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
 
(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers
 
Flink internals web
Flink internals web Flink internals web
Flink internals web
 
Java
JavaJava
Java
 
CodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneCodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory lane
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internals
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernel
 
Unix executable buffer overflow
Unix executable buffer overflowUnix executable buffer overflow
Unix executable buffer overflow
 
jvm goes to big data
jvm goes to big datajvm goes to big data
jvm goes to big data
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
 
Embedded C - Lecture 4
Embedded C - Lecture 4Embedded C - Lecture 4
Embedded C - Lecture 4
 

Más de Electronic Arts / DICE

GDC2019 - SEED - Towards Deep Generative Models in Game Development
GDC2019 - SEED - Towards Deep Generative Models in Game DevelopmentGDC2019 - SEED - Towards Deep Generative Models in Game Development
GDC2019 - SEED - Towards Deep Generative Models in Game DevelopmentElectronic Arts / DICE
 
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's EdgeSIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's EdgeElectronic Arts / DICE
 
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray TracingSyysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray TracingElectronic Arts / DICE
 
Khronos Munich 2018 - Halcyon and Vulkan
Khronos Munich 2018 - Halcyon and VulkanKhronos Munich 2018 - Halcyon and Vulkan
Khronos Munich 2018 - Halcyon and VulkanElectronic Arts / DICE
 
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingCEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingElectronic Arts / DICE
 
CEDEC 2018 - Functional Symbiosis of Art Direction and Proceduralism
CEDEC 2018 - Functional Symbiosis of Art Direction and ProceduralismCEDEC 2018 - Functional Symbiosis of Art Direction and Proceduralism
CEDEC 2018 - Functional Symbiosis of Art Direction and ProceduralismElectronic Arts / DICE
 
SIGGRAPH 2018 - PICA PICA and NVIDIA Turing
SIGGRAPH 2018 - PICA PICA and NVIDIA TuringSIGGRAPH 2018 - PICA PICA and NVIDIA Turing
SIGGRAPH 2018 - PICA PICA and NVIDIA TuringElectronic Arts / DICE
 
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingSIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingElectronic Arts / DICE
 
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsHPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsElectronic Arts / DICE
 
EPC 2018 - SEED - Exploring The Collaboration Between Proceduralism & Deep Le...
EPC 2018 - SEED - Exploring The Collaboration Between Proceduralism & Deep Le...EPC 2018 - SEED - Exploring The Collaboration Between Proceduralism & Deep Le...
EPC 2018 - SEED - Exploring The Collaboration Between Proceduralism & Deep Le...Electronic Arts / DICE
 
DD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time RenderingDD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time RenderingElectronic Arts / DICE
 
Creativity of Rules and Patterns: Designing Procedural Systems
Creativity of Rules and Patterns: Designing Procedural SystemsCreativity of Rules and Patterns: Designing Procedural Systems
Creativity of Rules and Patterns: Designing Procedural SystemsElectronic Arts / DICE
 
Shiny Pixels and Beyond: Real-Time Raytracing at SEED
Shiny Pixels and Beyond: Real-Time Raytracing at SEEDShiny Pixels and Beyond: Real-Time Raytracing at SEED
Shiny Pixels and Beyond: Real-Time Raytracing at SEEDElectronic Arts / DICE
 
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...Electronic Arts / DICE
 
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Physically Based Sky, Atmosphere and Cloud Rendering in FrostbitePhysically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Physically Based Sky, Atmosphere and Cloud Rendering in FrostbiteElectronic Arts / DICE
 
High Dynamic Range color grading and display in Frostbite
High Dynamic Range color grading and display in FrostbiteHigh Dynamic Range color grading and display in Frostbite
High Dynamic Range color grading and display in FrostbiteElectronic Arts / DICE
 
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect AndromedaElectronic Arts / DICE
 
Photogrammetry and Star Wars Battlefront
Photogrammetry and Star Wars BattlefrontPhotogrammetry and Star Wars Battlefront
Photogrammetry and Star Wars BattlefrontElectronic Arts / DICE
 

Más de Electronic Arts / DICE (20)

GDC2019 - SEED - Towards Deep Generative Models in Game Development
GDC2019 - SEED - Towards Deep Generative Models in Game DevelopmentGDC2019 - SEED - Towards Deep Generative Models in Game Development
GDC2019 - SEED - Towards Deep Generative Models in Game Development
 
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's EdgeSIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
 
SEED - Halcyon Architecture
SEED - Halcyon ArchitectureSEED - Halcyon Architecture
SEED - Halcyon Architecture
 
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray TracingSyysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
 
Khronos Munich 2018 - Halcyon and Vulkan
Khronos Munich 2018 - Halcyon and VulkanKhronos Munich 2018 - Halcyon and Vulkan
Khronos Munich 2018 - Halcyon and Vulkan
 
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingCEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
 
CEDEC 2018 - Functional Symbiosis of Art Direction and Proceduralism
CEDEC 2018 - Functional Symbiosis of Art Direction and ProceduralismCEDEC 2018 - Functional Symbiosis of Art Direction and Proceduralism
CEDEC 2018 - Functional Symbiosis of Art Direction and Proceduralism
 
SIGGRAPH 2018 - PICA PICA and NVIDIA Turing
SIGGRAPH 2018 - PICA PICA and NVIDIA TuringSIGGRAPH 2018 - PICA PICA and NVIDIA Turing
SIGGRAPH 2018 - PICA PICA and NVIDIA Turing
 
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingSIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
 
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsHPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
 
EPC 2018 - SEED - Exploring The Collaboration Between Proceduralism & Deep Le...
EPC 2018 - SEED - Exploring The Collaboration Between Proceduralism & Deep Le...EPC 2018 - SEED - Exploring The Collaboration Between Proceduralism & Deep Le...
EPC 2018 - SEED - Exploring The Collaboration Between Proceduralism & Deep Le...
 
DD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time RenderingDD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time Rendering
 
Creativity of Rules and Patterns: Designing Procedural Systems
Creativity of Rules and Patterns: Designing Procedural SystemsCreativity of Rules and Patterns: Designing Procedural Systems
Creativity of Rules and Patterns: Designing Procedural Systems
 
Shiny Pixels and Beyond: Real-Time Raytracing at SEED
Shiny Pixels and Beyond: Real-Time Raytracing at SEEDShiny Pixels and Beyond: Real-Time Raytracing at SEED
Shiny Pixels and Beyond: Real-Time Raytracing at SEED
 
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
 
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Physically Based Sky, Atmosphere and Cloud Rendering in FrostbitePhysically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
 
High Dynamic Range color grading and display in Frostbite
High Dynamic Range color grading and display in FrostbiteHigh Dynamic Range color grading and display in Frostbite
High Dynamic Range color grading and display in Frostbite
 
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
 
Lighting the City of Glass
Lighting the City of GlassLighting the City of Glass
Lighting the City of Glass
 
Photogrammetry and Star Wars Battlefront
Photogrammetry and Star Wars BattlefrontPhotogrammetry and Star Wars Battlefront
Photogrammetry and Star Wars Battlefront
 

Último

📞 Contact Number 8617697112 VIP Ganderbal Call Girls
📞 Contact Number 8617697112 VIP Ganderbal Call Girls📞 Contact Number 8617697112 VIP Ganderbal Call Girls
📞 Contact Number 8617697112 VIP Ganderbal Call GirlsNitya salvi
 
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...SUHANI PANDEY
 
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceBorum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceDamini Dixit
 
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...SUHANI PANDEY
 
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRLBhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRLNitya salvi
 
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...ritikasharma
 
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...Riya Pathan
 
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...Riya Pathan
 
(TOP CLASS) Call Girls In Nungambakkam Phone 7427069034 Call Girls Model With...
(TOP CLASS) Call Girls In Nungambakkam Phone 7427069034 Call Girls Model With...(TOP CLASS) Call Girls In Nungambakkam Phone 7427069034 Call Girls Model With...
(TOP CLASS) Call Girls In Nungambakkam Phone 7427069034 Call Girls Model With... Shivani Pandey
 
Science City Kolkata ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sex...
Science City Kolkata ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sex...Science City Kolkata ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sex...
Science City Kolkata ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sex...rahim quresi
 
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...aamir
 
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Verified Trusted Call Girls Ambattur Chennai ✔✔7427069034 Independent Chenna...
Verified Trusted Call Girls Ambattur Chennai ✔✔7427069034  Independent Chenna...Verified Trusted Call Girls Ambattur Chennai ✔✔7427069034  Independent Chenna...
Verified Trusted Call Girls Ambattur Chennai ✔✔7427069034 Independent Chenna... Shivani Pandey
 
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.Nitya salvi
 
Tikiapara Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex A...
Tikiapara Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex A...Tikiapara Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex A...
Tikiapara Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex A...aamir
 
Sonagachi ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Sonagachi ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...Sonagachi ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Sonagachi ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...rahim quresi
 
Hotel And Home Service Available Kolkata Call Girls Diamond Harbour ✔ 6297143...
Hotel And Home Service Available Kolkata Call Girls Diamond Harbour ✔ 6297143...Hotel And Home Service Available Kolkata Call Girls Diamond Harbour ✔ 6297143...
Hotel And Home Service Available Kolkata Call Girls Diamond Harbour ✔ 6297143...ritikasharma
 
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...aamir
 

Último (20)

📞 Contact Number 8617697112 VIP Ganderbal Call Girls
📞 Contact Number 8617697112 VIP Ganderbal Call Girls📞 Contact Number 8617697112 VIP Ganderbal Call Girls
📞 Contact Number 8617697112 VIP Ganderbal Call Girls
 
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...
 
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceBorum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
 
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...
 
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRLBhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
 
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...
 
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
 
Desi Bhabhi Call Girls In Goa 💃 730 02 72 001💃desi Bhabhi Escort Goa
Desi Bhabhi Call Girls  In Goa  💃 730 02 72 001💃desi Bhabhi Escort GoaDesi Bhabhi Call Girls  In Goa  💃 730 02 72 001💃desi Bhabhi Escort Goa
Desi Bhabhi Call Girls In Goa 💃 730 02 72 001💃desi Bhabhi Escort Goa
 
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
 
(TOP CLASS) Call Girls In Nungambakkam Phone 7427069034 Call Girls Model With...
(TOP CLASS) Call Girls In Nungambakkam Phone 7427069034 Call Girls Model With...(TOP CLASS) Call Girls In Nungambakkam Phone 7427069034 Call Girls Model With...
(TOP CLASS) Call Girls In Nungambakkam Phone 7427069034 Call Girls Model With...
 
Chat 9316020077💋 Call Girls Agency In Goa By Goa Call Girls Agency 💋
Chat 9316020077💋 Call Girls  Agency In Goa  By Goa  Call Girls  Agency 💋Chat 9316020077💋 Call Girls  Agency In Goa  By Goa  Call Girls  Agency 💋
Chat 9316020077💋 Call Girls Agency In Goa By Goa Call Girls Agency 💋
 
Science City Kolkata ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sex...
Science City Kolkata ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sex...Science City Kolkata ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sex...
Science City Kolkata ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sex...
 
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
 
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
 
Verified Trusted Call Girls Ambattur Chennai ✔✔7427069034 Independent Chenna...
Verified Trusted Call Girls Ambattur Chennai ✔✔7427069034  Independent Chenna...Verified Trusted Call Girls Ambattur Chennai ✔✔7427069034  Independent Chenna...
Verified Trusted Call Girls Ambattur Chennai ✔✔7427069034 Independent Chenna...
 
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.
 
Tikiapara Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex A...
Tikiapara Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex A...Tikiapara Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex A...
Tikiapara Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex A...
 
Sonagachi ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Sonagachi ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...Sonagachi ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Sonagachi ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
 
Hotel And Home Service Available Kolkata Call Girls Diamond Harbour ✔ 6297143...
Hotel And Home Service Available Kolkata Call Girls Diamond Harbour ✔ 6297143...Hotel And Home Service Available Kolkata Call Girls Diamond Harbour ✔ 6297143...
Hotel And Home Service Available Kolkata Call Girls Diamond Harbour ✔ 6297143...
 
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
 

Scope Stack Allocation

  • 1. Scope Stack Allocation Andreas Fredriksson, DICE <dep@dice.se>
  • 2. Contents What are Scope Stacks? Background – embedded systems Linear memory allocation Scope Stacks Bits and pieces
  • 3. What are Scope Stacks? A memory management tool Linear memory layout of arbitrary object hierarchies Support C++ object life cycle if desired Destructors called in correct dependency order Super-duper oiled-up fast! Makes debugging easier
  • 4. Background Why is all this relevant? Console games are embedded systems Fixed (small) amount of memory Can't run out of memory or you can't ship – fragmentation is a serious issue Heap allocation is very expensive Lots of code for complex heap manager Bad cache locality Allocation & deallocation speed
  • 5. Embedded systems With a global heap, memory fragments Assume 10-15% wasted with good allocator Can easily get 25% wasted with poor allocator Caused by allocating objects with mixed life time next to each other Temporary stuff allocated next to semi-permanent stuff (system arrays etc)
  • 6. Heap Fragmentation Each alloc has to traverse the free list of this structure! Assuming “best fit” allocator for less fragmentation Will likely cache miss for each probed location Large blocks disappear quickly
  • 7. Memory Map Ideally we would like fully deterministic memory map Popular approach on console Partition all memory up front Load new level Rewind level part only Reconfigure systems Rewind both level, systems Fragmentation not possible
  • 8. Linear Allocation Many games use linear allocators to achieve this kind of memory map Linear allocators basically sit on a pointer Allocations just increment the pointer To rewind, reset the pointer Very fast, but only suitable for POD data No finalizers/destructors called Used in Frostbite's renderer for command buffers
  • 9. Linear Allocator Implementation Simplified C++ example Real implementation needs checks, alignment In retail build, allocation will be just a few cycles 1 class LinearAllocator { 2 // ... 3 u8 *allocate(size_t size) { 4 return m_ptr += size; 5 } 6 void rewind(u8 *ptr) { 7 m_ptr = ptr; 8 } 9 // ... 10 u8 *m_ptr; 11 };
  • 10. Using Linear Allocation We're implementing FrogSystem A new system tied to the level Randomly place frogs across the level as the player is moving around Clearly the Next Big Thing Design for linear allocation Grab all memory up front Mr FISK (c) FLT Used with permission
  • 11. FrogSystem - Linear Allocation Simplified C++ example 1 struct FrogInfo { ... }; 2 3 struct FrogSystem { 4 // ... 5 int maxFrogs; 6 FrogInfo *frogPool; 7 }; 8 9 FrogSystem* FrogSystem_init(LinearAllocator& alloc) { 10 FrogSystem *self = alloc.allocate(sizeof(FrogSystem)); 11 self->maxFrogs = ...; 12 self->frogPool = alloc.allocate(sizeof(FrogInfo) * self->maxFrogs); 13 return self; 14 } 15 16 void FrogSystem_update(FrogSystem *system) { 17 // ... 18 }
  • 12. Resulting Memory Layout FrogSystem Frog Pool Allocation Point POD Data
  • 13. Linear allocation limitations Works well until we need resource cleanup File handles, sockets, ... Pool handles, other API resources This is the “systems programming” aspect Assume frog system needs a critical section Kernel object Must be released when no longer used
  • 14. FrogSystem – Adding a lock 1 class FrogSystem { 2 CriticalSection *m_lock; 3 4 FrogSystem(LinearAllocator& a) 5 // get memory 6 , m_lock((CriticalSection*) a.allocate(sizeof(CriticalSection))) 7 // ... 8 { 9 new (m_lock) CriticalSection; // construct object 10 } 11 12 ~FrogSystem() { 13 m_lock->~CriticalSection(); // destroy object 14 } 15 }; 16 17 FrogSystem* FrogSystem_init(LinearAllocator& a) { 18 returnnew (a.allocate(sizeof(FrogSystem))) FrogSystem(a); 19 } 20 21 void FrogSystem_cleanup(FrogSystem *system) { 22 system->~FrogSystem(); 23 }
  • 15. Resulting Memory Layout FrogSystem Frog Pool CritialSect Allocation Point POD Data Object with cleanup
  • 16. Linear allocation limitations Code quickly drowns in low-level details Lots of boilerplate We must add a cleanup function Manually remember what resources to free Error prone In C++, we would rather rely on destructors
  • 17. Scope Stacks Introducing Scope Stacks Sits on top of linear allocator Rewinds part of underlying allocator when destroyed Designed to make larger-scale system design with linear allocation possible Maintain a list of finalizers to run when rewinding Only worry about allocation, not cleanup
  • 18. Scope Stacks, contd. Type itself is a lightweight construct 1 struct Finalizer { 2 void (*fn)(void *ptr); 3 Finalizer *chain; 4 }; 5 6 class ScopeStack { 7 LinearAllocator& m_alloc; 8 void *m_rewindPoint; 9 Finalizer *m_finalizerChain; 10 11 explicit ScopeStack(LinearAllocator& a); 12 ~ScopeStack(); // unwind 13 14 template <typename T> T* newObject(); 15 template <typename T> T* newPOD(); 16 }; 17
  • 19. Scope Stacks, contd. Can create a stack of scopes on top of a single linear allocator Only allocate from topmost scope Can rewind scopes as desired For example init/systems/level Finer-grained control over nested lifetimes Can also follow call stack Very elegant per-thread scratch pad
  • 20. Scope Stack Diagram Linear Allocator Scope Scope Active Scope
  • 21. Scope Stack API Simple C++ interface scope.newObject<T>(...) - allocate object with cleanup (stores finalizer) scope.newPod<T>(...) - allocate object without cleanup scope.alloc(...) - raw memory allocation Can also implement as C interface Similar ideas in APR (Apache Portable Runtime)
  • 22. Scope Stack Implementation newObject<T>() 1 template <typename T> 2 void destructorCall(void *ptr) { 3 static_cast<T*>(ptr)->~T(); 4 } 5 6 template <typename T> 7 T* ScopeStack::newObject() { 8 // Allocate memory for finalizer + object. 9 Finalizer* f = allocWithFinalizer(sizeof(T)); 10 11 // Placement construct object in space after finalizer. 12 T* result = new (objectFromFinalizer(f)) T; 13 14 // Link this finalizer onto the chain. 15 f->fn = &destructorCall<T>; 16 f->chain = m_finalizerChain; 17 m_finalizerChain = f; 18 return result; 19 }
  • 23. FrogSystem – Scope Stacks Critical Section example with Scope Stack 1 class FrogSystem { 2 // ... 3 CriticalSection *m_lock; 4 5 FrogSystem(ScopeStack& scope) 6 : m_lock(scope.newObject<CriticalSection>()) 7 // ... 8 {} 9 10 // no destructor needed! 11 }; 12 13 FrogSystem* FrogSystem_init(ScopeStack& scope) { 14 return scope.newPod<FrogSystem>(); 15 }
  • 24. Memory Layout (with context) FrogSystem Frog Pool CritialSect (other stuff) ... Allocation Point POD Data Object with cleanup Finalizer record Scope
  • 25. Scope Cleanup With finalizer chain in place we can unwind without manual code Iterate linked list Call finalizer for objects that require cleanup POD data still zero overhead Finalizer for C++ objects => destructor call
  • 26. Per-thread allocation Scratch pad = Thread-local linear allocator Construct nested scopes on this allocator Utility functions can lay out arbitrary objects on scratch pad scope 1 class File; // next slide 2 3 constchar *formatString(ScopeStack& scope, constchar *fmt, ...); 4 5 void myFunction(constchar *fn) { 6 ScopeStack scratch(tls_allocator); 7 constchar *filename = formatString(scratch, "foo/bar/%s", fn); 8 File *file = scratch.newObject<File>(scratch, filename); 9 10 file->read(...); 11 12 // No cleanup required! 13 }
  • 27. Per-thread allocation, contd. File object allocates buffer from designed scope Doesn't care about lifetime – its buffer and itself will live for exactly the same time Can live on scratch pad without knowing it 1 class File { 2 private: 3 u8 *m_buffer; 4 int m_handle; 5 public: 6 File(ScopeStack& scope, constchar *filename) 7 : m_buffer(scope.alloc(8192)) 8 , m_handle(open(filename, O_READ)) 9 {} 10 11 ~File() { 12 close(m_handle); 13 } 14 };
  • 28. Memory Layout: Scratch Pad File Buffer Filename File Allocation Point Old Allocation Point POD Data Object with cleanup Finalizer record Rewind Point Scope Parent Scope
  • 29. PIMPL C++ addicts can enjoy free PIMPL idiom Because allocations are essentially “free”; PIMPL idiom becomes more attractive Can slim down headers and hide all data members without concern for performance
  • 30. Limitations Must set upper bound all pool sizes Can never grow an allocation This design style is classical in games industry But pool sizes can vary between levels! Reconfigure after rewind By default API not thread safe Makes sense as this is more like layout than allocation Pools/other structures can still be made thread safe once memory is allocated
  • 31. Limitations, contd. Doesn't map 100% to C++ object modeling But finalizers enable RAII-like cleanup Many traditional C++ tricks become obsolete Pointer swapping Reference counting Must always think about lifetime and ownership when allocating Lifetime determined on global level Can't hold on to pointers – unwind = apocalypse Manage on higher level instead
  • 32. Conclusion Scope stacks are a system programming tool Suitable for embedded systems with few variable parameters – games Requires planning and commitment Pays dividends in speed and simplicity Same pointers every time – debugging easier Out of memory analysis usually very simple Either the level runs, or doesn't run Can never fail half through
  • 33. Links Toy implementation of scope stacks For playing with, not industrial strength http://pastebin.com/h7nU8JE2 “Start Pre-allocating And Stop Worrying” - Noel Llopis http://gamesfromwithin.com/start-pre-allocating-and-stop-worrying Apache Portable Runtime http://apr.apache.org/
  • 35. Bonus: what about.. ..building an array, final size unknown? Standard approach in C++: STL vector push Instead build linked list/dequeue on scratch pad Allocate array in target scope stack once size is known ..dynamic lifetime of individual objects? Allocate object pool from scope stack Requires bounding the worst case – a good idea for games anyway