SlideShare a Scribd company logo
PRACTICAL RESOURCE MANAGEMENT FOR MOBILE DEVICES

POOLING IS MAGIC
W H AT D O W E K N O W A B O U T M O B I L E
W H AT D O W E K N O W A B O U T M O B I L E
• Battery is limited
W H AT D O W E K N O W A B O U T M O B I L E
• Battery is limited
• Processing power is limited
W H AT D O W E K N O W A B O U T M O B I L E
• Battery is limited
• Processing power is limited
• Storage is limited
W H AT D O W E K N O W A B O U T M O B I L E
• Battery is limited
• Processing power is limited
• Storage is limited
• RAM is limited
W H AT D O W E K N O W A B O U T M O B I L E
• Battery is limited
• Processing power is limited
• Storage is limited
• RAM is limited

• Ubiquitous
W H AT D O W E K N O W A B O U T G A M E S
W H AT D O W E K N O W A B O U T G A M E S
• Consume all of the CPU
W H AT D O W E K N O W A B O U T G A M E S
• Consume all of the CPU
• Consume all of the GPU
W H AT D O W E K N O W A B O U T G A M E S
• Consume all of the CPU
• Consume all of the GPU
• Can consume a lot of storage space
W H AT D O W E K N O W A B O U T G A M E S
• Consume all of the CPU
• Consume all of the GPU
• Can consume a lot of storage space
• Consume all of RAM
W H AT D O W E K N O W A B O U T G A M E S
• Consume all of the CPU
• Consume all of the GPU
• Can consume a lot of storage space
• Consume all of RAM

• Thats what people do on mobile
R E D U C E B AT T E R Y C O N S U M P T I O N
• Reduce your network activity
• Every time cell radio is activated for 20-30 seconds
• Batch requests
• Prefetch as much data as possible
• Maximize bandwidth usage
• Reduce storage activity
• Don’t keep threads busy for no reason
R E D U C E A P P L I C AT I O N S I Z E
• Different assets for different device categories
• Use a smaller runtime if available
• Use texture atlases
• Enable batch drawing
• Less memory
• Use compressed textures where possible
• Use WebP for uncompressed images
GAMES ARE DIFFERENT
GAMES ARE DIFFERENT

• A lot is known in advance:
• Usage patterns are known
• Data dependencies are known
• Asset restrictions are known
USE YOUR KNOWLEDGE
USE YOUR KNOWLEDGE

• Set restrictions for designers and artists
• Custom build process:
• Use available tools
• Write your own
M E M O R Y A L L O C AT I O N PAT T E R S
• Application scope (allocated at app start, freed on

shutdown)

• Level scope (allocated at level start, freed on level

end)

• Frame scope (allocated for one frame, sometimes for

two)

• Temporary allocations
M E M O R Y A L L O C AT I O N PAT T E R N S

• Grab all required memory once on app start - this is all

you will have

• Divide it between several heaps for different

subsystems (avoids fragmentation, decoupling)

• Use stack allocations where possible (alloca, structs,

static arrays)
G O T TA G O F A S T

• Linear allocator:
• Just increase the pointer and adjust for alignment
• As fast as it can get
• Free all memory at once (reset pointer)
L I N E A R A L L O C AT O R
• Can only free in reverse order (better free all at once at scope

exit)

• How do we deal with temporary allocations?
• Separate heap for temporaries?
• Nope! Double-ended linear allocator
• What about cleanup?
• Scope stack (http://dice.se/publications/scope-stack-

allocation/)
B U T W A I T, W H AT A B O U T

• Objects with undefined lifetime:
• Use object pools
• Objects with variable size:
• Custom allocator (several free-lists for different sizes)
OBJECT POOLS
• Preallocate certain number of objects of same type
• Use objects from pool whenever one needs an object of that

type

• Return objects to pool when done (resource released,

reference count is zero)

• Can process all the pool in one go
• Better cache efficiency
• Set restrictions on object count
OBJECT POOLS
• Particle systems
• Components
• Game entities
• Sounds
• etc.
RESOURCE LIFETIME
• Use registers for resources of same type (fonts,

textures, etc.)

• Use reference counters only as last resort:
• Thrash CPU cache
• Unnecessary work
• Unbounded pauses on deallocation cascades
RESOURCE LIFETIME

• Don’t leave some resource hanging if it will be reused

in some other level

• Usually its ok to unload and load stuff again to avoid

heap fragmentation
REDUCE MEMORY USAGE

• ‘Prototype’ pattern:
• Extract some part to be shared by all objects
• Usually used as a template for creating stuff
• Best allocation is no allocation at all
‘ P R O T O T Y P E ’ PAT T E R N

• Animations
• Game entities (Similar to prefabs in Unity)
• Anything that could share an immutable part between

instances
REDUCE MEMORY USAGE
• Unity:
• Use value types (structs, primitive types)
• Avoid boxing/unboxing
• Don’t use default GUI
• Reuse buffers and objects where possible
• Always base your decisions on data

• USE PROFILER
• Don’t use this rules as a dogma, think for yourself
S TA R T P R E A L L O C AT I N G
AND
STOP WORRYING
QUESTIONS?

M A X K LY G A
E M A I L : M A X . K LY G A @ G M A I L . C O M
TWITTER: @NEKU42

More Related Content

Similar to Pooling is magic, Максим Клыга

Linux Performance Tools 2014
Linux Performance Tools 2014Linux Performance Tools 2014
Linux Performance Tools 2014
Brendan Gregg
 
Introduction to DRBD
Introduction to DRBDIntroduction to DRBD
Introduction to DRBD
dawnlua
 
Linux Performance Tools
Linux Performance ToolsLinux Performance Tools
Linux Performance Tools
Brendan Gregg
 
Erasure Code at Scale - Thomas William Byrne
Erasure Code at Scale - Thomas William ByrneErasure Code at Scale - Thomas William Byrne
Erasure Code at Scale - Thomas William Byrne
Ceph Community
 
Internet of Things, TYBSC IT, Semester 5, Unit IV
Internet of Things, TYBSC IT, Semester 5, Unit IVInternet of Things, TYBSC IT, Semester 5, Unit IV
Internet of Things, TYBSC IT, Semester 5, Unit IV
Arti Parab Academics
 
CPU Caches
CPU CachesCPU Caches
CPU Caches
shinolajla
 
Micro control idsecconf2010
Micro control idsecconf2010Micro control idsecconf2010
Micro control idsecconf2010
idsecconf
 
Running & Scaling Large Elasticsearch Clusters
Running & Scaling Large Elasticsearch ClustersRunning & Scaling Large Elasticsearch Clusters
Running & Scaling Large Elasticsearch Clusters
Fred de Villamil
 
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Community
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency Trading
Viktor Sovietov
 
London devops logging
London devops loggingLondon devops logging
London devops logging
Tomas Doran
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
Jacob Pimental
 
Intro to Cassandra
Intro to CassandraIntro to Cassandra
Intro to Cassandra
Jon Haddad
 
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Lars Marowsky-Brée
 
Lessons learned from building Demand Side Platform
Lessons learned from building Demand Side PlatformLessons learned from building Demand Side Platform
Lessons learned from building Demand Side Platform
bbogacki
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL-Consulting
 
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Nikolay Savvinov
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
Decima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnDecima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero Dawn
Guerrilla
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memory
Shivam Mitra
 

Similar to Pooling is magic, Максим Клыга (20)

Linux Performance Tools 2014
Linux Performance Tools 2014Linux Performance Tools 2014
Linux Performance Tools 2014
 
Introduction to DRBD
Introduction to DRBDIntroduction to DRBD
Introduction to DRBD
 
Linux Performance Tools
Linux Performance ToolsLinux Performance Tools
Linux Performance Tools
 
Erasure Code at Scale - Thomas William Byrne
Erasure Code at Scale - Thomas William ByrneErasure Code at Scale - Thomas William Byrne
Erasure Code at Scale - Thomas William Byrne
 
Internet of Things, TYBSC IT, Semester 5, Unit IV
Internet of Things, TYBSC IT, Semester 5, Unit IVInternet of Things, TYBSC IT, Semester 5, Unit IV
Internet of Things, TYBSC IT, Semester 5, Unit IV
 
CPU Caches
CPU CachesCPU Caches
CPU Caches
 
Micro control idsecconf2010
Micro control idsecconf2010Micro control idsecconf2010
Micro control idsecconf2010
 
Running & Scaling Large Elasticsearch Clusters
Running & Scaling Large Elasticsearch ClustersRunning & Scaling Large Elasticsearch Clusters
Running & Scaling Large Elasticsearch Clusters
 
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency Trading
 
London devops logging
London devops loggingLondon devops logging
London devops logging
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
 
Intro to Cassandra
Intro to CassandraIntro to Cassandra
Intro to Cassandra
 
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
 
Lessons learned from building Demand Side Platform
Lessons learned from building Demand Side PlatformLessons learned from building Demand Side Platform
Lessons learned from building Demand Side Platform
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
 
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
 
Decima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnDecima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero Dawn
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memory
 

More from IT Share

Cоветs по оптимизации игр, Александр Дежурко
Cоветs по оптимизации игр, Александр ДежуркоCоветs по оптимизации игр, Александр Дежурко
Cоветs по оптимизации игр, Александр Дежурко
IT Share
 
Citrus Game Engine, Юрий Шумовский
Citrus Game Engine, Юрий ШумовскийCitrus Game Engine, Юрий Шумовский
Citrus Game Engine, Юрий Шумовский
IT Share
 
Святослав Панкратов - Оптимизация арта для браузерных проектов на юнити
Святослав Панкратов - Оптимизация арта для браузерных проектов на юнитиСвятослав Панкратов - Оптимизация арта для браузерных проектов на юнити
Святослав Панкратов - Оптимизация арта для браузерных проектов на юнитиIT Share
 
Иван Воронов - Пара вещей, которые упростили бы мою гейм-дизайнерскую жизнь, ...
Иван Воронов - Пара вещей, которые упростили бы мою гейм-дизайнерскую жизнь, ...Иван Воронов - Пара вещей, которые упростили бы мою гейм-дизайнерскую жизнь, ...
Иван Воронов - Пара вещей, которые упростили бы мою гейм-дизайнерскую жизнь, ...IT Share
 
Александр Яцукевич - Визуальные эффекты в гейм-дизайне
Александр Яцукевич - Визуальные эффекты в гейм-дизайнеАлександр Яцукевич - Визуальные эффекты в гейм-дизайне
Александр Яцукевич - Визуальные эффекты в гейм-дизайнеIT Share
 
Клевакичев и Кравченко - Игровой баланс, методы его поиска и последующее тира...
Клевакичев и Кравченко - Игровой баланс, методы его поиска и последующее тира...Клевакичев и Кравченко - Игровой баланс, методы его поиска и последующее тира...
Клевакичев и Кравченко - Игровой баланс, методы его поиска и последующее тира...IT Share
 
Сергей Сверчков - Оцениваем решения NoSQL: какая база данных подходит для ваш...
Сергей Сверчков - Оцениваем решения NoSQL: какая база данных подходит для ваш...Сергей Сверчков - Оцениваем решения NoSQL: какая база данных подходит для ваш...
Сергей Сверчков - Оцениваем решения NoSQL: какая база данных подходит для ваш...
IT Share
 
Роман Белешев - Online backup: технологии хранения больших объемов данных
Роман Белешев - Online backup: технологии хранения больших объемов данных Роман Белешев - Online backup: технологии хранения больших объемов данных
Роман Белешев - Online backup: технологии хранения больших объемов данных
IT Share
 
Кирилл Алешин - Big Data и Lambda архитектура на практике
Кирилл Алешин - Big Data и Lambda архитектура на практикеКирилл Алешин - Big Data и Lambda архитектура на практике
Кирилл Алешин - Big Data и Lambda архитектура на практике
IT Share
 
Максим Мельников - Wargaming Web
Максим Мельников - Wargaming WebМаксим Мельников - Wargaming Web
Максим Мельников - Wargaming Web
IT Share
 
Юрий Жлоба - Опыт использования Erlang в разработке многопользовательской игры.
Юрий Жлоба -  Опыт использования Erlang в разработке многопользовательской игры.Юрий Жлоба -  Опыт использования Erlang в разработке многопользовательской игры.
Юрий Жлоба - Опыт использования Erlang в разработке многопользовательской игры.
IT Share
 
Никита Вельмаскин - Интерпретатор или думаем над скриптовым движком для Ваше...
Никита Вельмаскин -  Интерпретатор или думаем над скриптовым движком для Ваше...Никита Вельмаскин -  Интерпретатор или думаем над скриптовым движком для Ваше...
Никита Вельмаскин - Интерпретатор или думаем над скриптовым движком для Ваше...
IT Share
 
«​Масштабируемый DevOps​» Александр Колесень
«​Масштабируемый DevOps​» Александр Колесень«​Масштабируемый DevOps​» Александр Колесень
«​Масштабируемый DevOps​» Александр Колесень
IT Share
 
«От CMS к Highload: работа с backend» Алексей Сазанов, Александр Каскевич
«От CMS к Highload: работа с backend» Алексей Сазанов, Александр Каскевич«От CMS к Highload: работа с backend» Алексей Сазанов, Александр Каскевич
«От CMS к Highload: работа с backend» Алексей Сазанов, Александр Каскевич
IT Share
 

More from IT Share (14)

Cоветs по оптимизации игр, Александр Дежурко
Cоветs по оптимизации игр, Александр ДежуркоCоветs по оптимизации игр, Александр Дежурко
Cоветs по оптимизации игр, Александр Дежурко
 
Citrus Game Engine, Юрий Шумовский
Citrus Game Engine, Юрий ШумовскийCitrus Game Engine, Юрий Шумовский
Citrus Game Engine, Юрий Шумовский
 
Святослав Панкратов - Оптимизация арта для браузерных проектов на юнити
Святослав Панкратов - Оптимизация арта для браузерных проектов на юнитиСвятослав Панкратов - Оптимизация арта для браузерных проектов на юнити
Святослав Панкратов - Оптимизация арта для браузерных проектов на юнити
 
Иван Воронов - Пара вещей, которые упростили бы мою гейм-дизайнерскую жизнь, ...
Иван Воронов - Пара вещей, которые упростили бы мою гейм-дизайнерскую жизнь, ...Иван Воронов - Пара вещей, которые упростили бы мою гейм-дизайнерскую жизнь, ...
Иван Воронов - Пара вещей, которые упростили бы мою гейм-дизайнерскую жизнь, ...
 
Александр Яцукевич - Визуальные эффекты в гейм-дизайне
Александр Яцукевич - Визуальные эффекты в гейм-дизайнеАлександр Яцукевич - Визуальные эффекты в гейм-дизайне
Александр Яцукевич - Визуальные эффекты в гейм-дизайне
 
Клевакичев и Кравченко - Игровой баланс, методы его поиска и последующее тира...
Клевакичев и Кравченко - Игровой баланс, методы его поиска и последующее тира...Клевакичев и Кравченко - Игровой баланс, методы его поиска и последующее тира...
Клевакичев и Кравченко - Игровой баланс, методы его поиска и последующее тира...
 
Сергей Сверчков - Оцениваем решения NoSQL: какая база данных подходит для ваш...
Сергей Сверчков - Оцениваем решения NoSQL: какая база данных подходит для ваш...Сергей Сверчков - Оцениваем решения NoSQL: какая база данных подходит для ваш...
Сергей Сверчков - Оцениваем решения NoSQL: какая база данных подходит для ваш...
 
Роман Белешев - Online backup: технологии хранения больших объемов данных
Роман Белешев - Online backup: технологии хранения больших объемов данных Роман Белешев - Online backup: технологии хранения больших объемов данных
Роман Белешев - Online backup: технологии хранения больших объемов данных
 
Кирилл Алешин - Big Data и Lambda архитектура на практике
Кирилл Алешин - Big Data и Lambda архитектура на практикеКирилл Алешин - Big Data и Lambda архитектура на практике
Кирилл Алешин - Big Data и Lambda архитектура на практике
 
Максим Мельников - Wargaming Web
Максим Мельников - Wargaming WebМаксим Мельников - Wargaming Web
Максим Мельников - Wargaming Web
 
Юрий Жлоба - Опыт использования Erlang в разработке многопользовательской игры.
Юрий Жлоба -  Опыт использования Erlang в разработке многопользовательской игры.Юрий Жлоба -  Опыт использования Erlang в разработке многопользовательской игры.
Юрий Жлоба - Опыт использования Erlang в разработке многопользовательской игры.
 
Никита Вельмаскин - Интерпретатор или думаем над скриптовым движком для Ваше...
Никита Вельмаскин -  Интерпретатор или думаем над скриптовым движком для Ваше...Никита Вельмаскин -  Интерпретатор или думаем над скриптовым движком для Ваше...
Никита Вельмаскин - Интерпретатор или думаем над скриптовым движком для Ваше...
 
«​Масштабируемый DevOps​» Александр Колесень
«​Масштабируемый DevOps​» Александр Колесень«​Масштабируемый DevOps​» Александр Колесень
«​Масштабируемый DevOps​» Александр Колесень
 
«От CMS к Highload: работа с backend» Алексей Сазанов, Александр Каскевич
«От CMS к Highload: работа с backend» Алексей Сазанов, Александр Каскевич«От CMS к Highload: работа с backend» Алексей Сазанов, Александр Каскевич
«От CMS к Highload: работа с backend» Алексей Сазанов, Александр Каскевич
 

Recently uploaded

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 

Recently uploaded (20)

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 

Pooling is magic, Максим Клыга

  • 1. PRACTICAL RESOURCE MANAGEMENT FOR MOBILE DEVICES POOLING IS MAGIC
  • 2. W H AT D O W E K N O W A B O U T M O B I L E
  • 3. W H AT D O W E K N O W A B O U T M O B I L E • Battery is limited
  • 4. W H AT D O W E K N O W A B O U T M O B I L E • Battery is limited • Processing power is limited
  • 5. W H AT D O W E K N O W A B O U T M O B I L E • Battery is limited • Processing power is limited • Storage is limited
  • 6. W H AT D O W E K N O W A B O U T M O B I L E • Battery is limited • Processing power is limited • Storage is limited • RAM is limited
  • 7. W H AT D O W E K N O W A B O U T M O B I L E • Battery is limited • Processing power is limited • Storage is limited • RAM is limited • Ubiquitous
  • 8. W H AT D O W E K N O W A B O U T G A M E S
  • 9. W H AT D O W E K N O W A B O U T G A M E S • Consume all of the CPU
  • 10. W H AT D O W E K N O W A B O U T G A M E S • Consume all of the CPU • Consume all of the GPU
  • 11. W H AT D O W E K N O W A B O U T G A M E S • Consume all of the CPU • Consume all of the GPU • Can consume a lot of storage space
  • 12. W H AT D O W E K N O W A B O U T G A M E S • Consume all of the CPU • Consume all of the GPU • Can consume a lot of storage space • Consume all of RAM
  • 13. W H AT D O W E K N O W A B O U T G A M E S • Consume all of the CPU • Consume all of the GPU • Can consume a lot of storage space • Consume all of RAM • Thats what people do on mobile
  • 14.
  • 15. R E D U C E B AT T E R Y C O N S U M P T I O N • Reduce your network activity • Every time cell radio is activated for 20-30 seconds • Batch requests • Prefetch as much data as possible • Maximize bandwidth usage • Reduce storage activity • Don’t keep threads busy for no reason
  • 16. R E D U C E A P P L I C AT I O N S I Z E • Different assets for different device categories • Use a smaller runtime if available • Use texture atlases • Enable batch drawing • Less memory • Use compressed textures where possible • Use WebP for uncompressed images
  • 18. GAMES ARE DIFFERENT • A lot is known in advance: • Usage patterns are known • Data dependencies are known • Asset restrictions are known
  • 20. USE YOUR KNOWLEDGE • Set restrictions for designers and artists • Custom build process: • Use available tools • Write your own
  • 21. M E M O R Y A L L O C AT I O N PAT T E R S • Application scope (allocated at app start, freed on shutdown) • Level scope (allocated at level start, freed on level end) • Frame scope (allocated for one frame, sometimes for two) • Temporary allocations
  • 22. M E M O R Y A L L O C AT I O N PAT T E R N S • Grab all required memory once on app start - this is all you will have • Divide it between several heaps for different subsystems (avoids fragmentation, decoupling) • Use stack allocations where possible (alloca, structs, static arrays)
  • 23. G O T TA G O F A S T • Linear allocator: • Just increase the pointer and adjust for alignment • As fast as it can get • Free all memory at once (reset pointer)
  • 24. L I N E A R A L L O C AT O R • Can only free in reverse order (better free all at once at scope exit) • How do we deal with temporary allocations? • Separate heap for temporaries? • Nope! Double-ended linear allocator • What about cleanup? • Scope stack (http://dice.se/publications/scope-stack- allocation/)
  • 25. B U T W A I T, W H AT A B O U T • Objects with undefined lifetime: • Use object pools • Objects with variable size: • Custom allocator (several free-lists for different sizes)
  • 26. OBJECT POOLS • Preallocate certain number of objects of same type • Use objects from pool whenever one needs an object of that type • Return objects to pool when done (resource released, reference count is zero) • Can process all the pool in one go • Better cache efficiency • Set restrictions on object count
  • 27. OBJECT POOLS • Particle systems • Components • Game entities • Sounds • etc.
  • 28. RESOURCE LIFETIME • Use registers for resources of same type (fonts, textures, etc.) • Use reference counters only as last resort: • Thrash CPU cache • Unnecessary work • Unbounded pauses on deallocation cascades
  • 29. RESOURCE LIFETIME • Don’t leave some resource hanging if it will be reused in some other level • Usually its ok to unload and load stuff again to avoid heap fragmentation
  • 30. REDUCE MEMORY USAGE • ‘Prototype’ pattern: • Extract some part to be shared by all objects • Usually used as a template for creating stuff • Best allocation is no allocation at all
  • 31. ‘ P R O T O T Y P E ’ PAT T E R N • Animations • Game entities (Similar to prefabs in Unity) • Anything that could share an immutable part between instances
  • 32. REDUCE MEMORY USAGE • Unity: • Use value types (structs, primitive types) • Avoid boxing/unboxing • Don’t use default GUI • Reuse buffers and objects where possible
  • 33. • Always base your decisions on data • USE PROFILER • Don’t use this rules as a dogma, think for yourself
  • 34. S TA R T P R E A L L O C AT I N G AND STOP WORRYING
  • 35. QUESTIONS? M A X K LY G A E M A I L : M A X . K LY G A @ G M A I L . C O M TWITTER: @NEKU42