Using Ninja's pool feature - building with lower memory usage. #64087

Closed
opened 2019-05-02 16:14:41 +02:00 by Bastien Montagne · 3 comments

Building with e.g. 8 parallel tasks a full-featured debug Blender with ASAN and GTests enabled can use over 10GB of RAM at some points (both thanks to some C++ files - over 2.5GB for each cpp process in some cases - and linking - over 3.3GB to link blender and some of its gtests).

Ninja's pools allow to limit the amount of parallel processes, selectively for certain categories of jobs. CMake supports 'natively' settings for 'build' and 'link' jobs, and more refined ones can be used too as needed.

In that patch, I added an extra 'build_heavy' pool, used for the few C++ libs that require a huge amount of RAM (some from Cycles, libmv and openvdb).

With it, and setting NINJA_PARALLEL_COMPILE_HEAVY_JOBS to 1, NINJA_PARALLEL_COMPILE_JOBS to 7, and NINJA_PARALLEL_LINK_JOBS to 1, for me it compiles withing a 4GB memory footprint, with a time penalty of about 30% (from 15 mins to 20 mins).

Setting NINJA_PARALLEL_COMPILE_HEAVY_JOBS to 2, NINJA_PARALLEL_COMPILE_JOBS to 7, and NINJA_PARALLEL_LINK_JOBS to 1, it compiles within a 7GB memory footprint with no measurable time penalty.

To summarize, it allows a RAM usage reduction of 60% for a build time increase of 30% (mostly due to some libraries that are not often rebuilt, and Cycles), or a RAM usage reduction of 30% for no build time penalty.

Building with e.g. 8 parallel tasks a full-featured debug Blender with ASAN and GTests enabled can use over 10GB of RAM at some points (both thanks to some C++ files - over 2.5GB for each cpp process in some cases - and linking - over 3.3GB to link blender and some of its gtests). Ninja's pools allow to limit the amount of parallel processes, selectively for certain categories of jobs. CMake supports 'natively' settings for 'build' and 'link' jobs, and more refined ones can be used too as needed. In that patch, I added an extra 'build_heavy' pool, used for the few C++ libs that require a huge amount of RAM (some from Cycles, libmv and openvdb). With it, and setting `NINJA_PARALLEL_COMPILE_HEAVY_JOBS` to 1, `NINJA_PARALLEL_COMPILE_JOBS` to 7, and `NINJA_PARALLEL_LINK_JOBS` to 1, for me it compiles withing a 4GB memory footprint, with a time penalty of about 30% (from 15 mins to 20 mins). Setting `NINJA_PARALLEL_COMPILE_HEAVY_JOBS` to 2, `NINJA_PARALLEL_COMPILE_JOBS` to 7, and `NINJA_PARALLEL_LINK_JOBS` to 1, it compiles within a 7GB memory footprint with no measurable time penalty. To summarize, it allows a RAM usage reduction of 60% for a build time increase of 30% (mostly due to some libraries that are not often rebuilt, and Cycles), or a RAM usage reduction of 30% for no build time penalty.
Bastien Montagne self-assigned this 2019-05-02 16:14:41 +02:00
Author
Owner

Added subscriber: @mont29

Added subscriber: @mont29
Author
Owner

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Author
Owner

Grrr, that was supposed to be a differential… :(

Grrr, that was supposed to be a differential… :(
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#64087
No description provided.