Skip to content

Commit 98d49df

Browse files
imorlxsvgvassilev
andauthored
Add blog and fix poster (#260)
* Add blog and fix poster * Add acknowledges and improve some other parts * Update _posts/2024-10-17-improving-performance-of-biodynamo-using-cpp-modules.md --------- Co-authored-by: Vassil Vassilev <[email protected]>
1 parent d8c8db8 commit 98d49df

File tree

5 files changed

+106
-2
lines changed

5 files changed

+106
-2
lines changed

_data/preslist.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
- title: "Improving BioDynamo's Performance using ROOT C++ Modules"
22
description: |
3-
Poster presented at the FOURTH Mode Workshop on Differentiable Programming for Experiment Desing
3+
Poster presented at the FOURTH Mode Workshop on Differentiable Programming for Experiment Design
44
location: "[Fourth MODE Workshop](https://indico.cern.ch/event/1380163/)"
55
date: 2024-09-24
66
speaker: Isaac Morales Santana
77
id: "FOURTHMODEBDM"
88
artifacts: |
99
[Link to poster](/assets/presentations/Fourth_MODE_Isaac_Morales.pdf)
10-
highlight: 1
10+
highlight: 0
1111

1212
- title: "Accelerating Large Scientific Workflows Using Source Transformation Automatic Differentiation"
1313
description: |
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: "Wrapping up GSoC'24: Improving performance of BioDynaMo using ROOT C++ Modules"
3+
layout: post
4+
excerpt: "This project, part of Google Summer of Code 2024, aims to reduce the header parsing in BioDynaMo using the ROOT C++ Modules"
5+
sitemap: false
6+
author: Isaac Morales Santana
7+
permalink: blogs/gsoc24_isaac_morales_wrapup_blog/
8+
banner_image: /images/blog/gsoc-banner.png
9+
date: 2024-10-17
10+
tags: gsoc root cmake c++
11+
---
12+
13+
### Introduction
14+
15+
I am Isaac Morales, a Computer Engineering student at the University of Granada, Spain.
16+
This summer I had the opportunity to participate in Google Summer of Code 2024. My project
17+
revolved around enhancing BioDynaMo's performance using the ROOT C++ Modules.
18+
19+
**Mentors**: Vassil Vassilev, Lukas Breitwieser.
20+
21+
22+
### Project overview
23+
24+
BioDynaMo is an agent-based simulation platform designed to facilitate complex simulations,
25+
particularly in fields like cancer research, epidemiology, and social sciences. It leverages
26+
ROOT—a framework widely used in high-energy physics—for statistical analysis, random number
27+
generation, C++ Jupyter notebooks, and I/O operations. However, enhancing BioDynaMo’s performance
28+
remains a key challenge. This is where this Google Summer of Code 2024 (GSoC ‘24) project comes
29+
into play, focusing on optimizing the platform through ROOT C++ Modules.
30+
31+
### The Challenge: Performance Bottlenecks in BioDynaMo
32+
BioDynaMo’s reflection system, which utilizes Cling (an interactive C++ interpreter from ROOT),
33+
experiences significant runtime performance and memory usage issues. The repeated parsing of library
34+
descriptors by Cling introduces inefficiencies that slow down the startup phase and consume excessive
35+
memory. These bottlenecks are especially evident in simulations with a low number of time steps, as
36+
a substantial portion of the time is spent on parsing rather than on actual computations.
37+
38+
### The Solution: Integrating ROOT C++ Modules.
39+
The primary goal of the GSoC project was to integrate ROOT’s C++ Modules into BioDynaMo to minimize
40+
these performance issues. C++ Modules offer an efficient on-disk representation of C++ code,
41+
reducing the need for repeated parsing of invariant code. By implementing these modules,
42+
the project aimed to optimize runtime memory usage and improve overall performance
43+
44+
## What I did?:
45+
1. **Reworking CMake Rules:** The project incorporated ROOT and another packages
46+
efficiently using FetchContent, modifying CMake rules accordingly (e.g., PR [#365](https://github.com/BioDynaMo/biodynamo/pull/365)
47+
and [#387](https://github.com/BioDynaMo/biodynamo/pull/387), both merged)
48+
2. **Replacing genreflex with rootcling:** This switch was crucial to enable C++ Modules and
49+
streamline the generation of reflection information (PR [#379](https://github.com/BioDynaMo/biodynamo/pull/379))
50+
3. **C++ Modules changes** Among other things, I used automatic generation for the module map with relative paths,
51+
modified the `selection.xml` file to support the new dictionaries and fixed headers with missing includes (PR [#385](https://github.com/BioDynaMo/biodynamo/pull/385).
52+
4. **Updated some CI workflows** I fixed some failing workflows in PR [#377](https://github.com/BioDynaMo/biodynamo/pull/377).
53+
Also, I did some minor changes in some flags in PR's [#378](https://github.com/BioDynaMo/biodynamo/pull/378) and [#367](https://github.com/BioDynaMo/biodynamo/pull/367)
54+
55+
### Promising Results
56+
The results have been promising, showcasing significant performance gains. Benchmarking revealed
57+
improvements ranging from 18% reduction in peak memory usage with the default modules.idx to 25% with the
58+
updated one.
59+
![Plot of the peak memory usage in various demos](/images/blog/bdm-peak-memory.png)
60+
61+
62+
Moreover, the startup phase saw an impressive 80% reduction in time, thanks to the optimized
63+
handling of header parsing. That highlights the efficiency of C++ Modules in minimizing
64+
Cling’s parsing overhead
65+
![Plot of the startup time in various demos](/images/blog/bdm-startup-time.png)
66+
67+
As expected, the simulation time did not show an appreciable improvement. However, in the
68+
unit tests, the time was 33% lower. I believe this is because unit tests involve a lot of parsing and Cling calls.
69+
70+
### Future Steps and Challenges Ahead
71+
Despite these advances, several challenges remain. PR's #365 is ready to merge and #385 needs some changes. For instance, memory leaks have been observed when using the new
72+
`ROOT_GENERATE_DICTIONARY`, even with C++ Modules disabled. Additionally, the build system for individual demos has
73+
caused compatibility issues with the main build system. Also, there is a problem with the Jupyter notebooks.
74+
Resolving these issues and finalizing the integration of C++ Modules will be essential for ensuring long-term stability and reliability.
75+
76+
Looking ahead, further optimizations are planned, including potential module-based optimizations for BioDynaMo’s
77+
core components. Collaboration with the BioDynaMo team continues, with upcoming meetings scheduled
78+
to align efforts and resolve outstanding issues.
79+
80+
### Conclusion
81+
The integration of C++ Modules has proven effective in reducing memory usage and startup time, although some hurdles remain.
82+
Continued collaboration and testing will be crucial to fully realize the performance potential of BioDynaMo,
83+
enabling more efficient simulations for researchers in computational biology.
84+
85+
### Acknowledges
86+
First of all, I would like to thank Google Summer of Code for the opportunity to work on this project.
87+
But above all, my most sincere gratitude goes to Vassil. He has been an exceptional mentor, always attentive
88+
and ready to help with anything I needed. His encouragement during weekly meetings and his constant support in all areas,
89+
from soft skills to technical expertise, have truly inspired me and earned my admiration.
90+
91+
Many thanks also to the BioDynaMo team: to Lukas Breitweiser for guiding me through the final stages and helping
92+
me understand the complexities of BioDynaMo; to Tobias Duswald for reviewing my PRs and assisting me in analyzing
93+
my results; and to Fons Rademakers for his support when I faced challenges compiling ROOT in debug mode.
94+
95+
Lastly, a special thanks to my colleagues from Compiler Research, particularly David, Atel and Maksym, whom I had
96+
the pleasure of meeting at the Fourth MODE in Valencia, for making this experience unforgettable.
97+
98+
### Related Links
99+
100+
- [ROOT website](https://root.cern)
101+
- [BioDynaMo website](https://www.biodynamo.org/)
102+
- [My GitHub Profile](https://github.com/imorlxs)
103+
104+

images/blog/bdm-peak-memory.png

21.1 KB
Loading

images/blog/bdm-startup-time.png

21.3 KB
Loading

images/pubpic/FOURTHMODEBDM.png

226 KB
Loading

0 commit comments

Comments
 (0)