# Need help testing significant memory optimizations

**URL:** <https://mediasoup.discourse.group/t/need-help-testing-significant-memory-optimizations/3302>\
**Category:** mediasoup libraries\
**Created:** [September 15, 2021, 7:43am UTC](https://mediasoup.discourse.group/t/need-help-testing-significant-memory-optimizations/3302 "2021-09-15T07:43:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [September 15, 2021, 7:43am UTC](https://mediasoup.discourse.group/t/need-help-testing-significant-memory-optimizations/3302/1 "2021-09-15T07:43:43Z")

</div>

I was working on some memory optimizations and got exciting results, but since changes are very invasive I’d like for more people to test them.

The results are **3x** decrease in calls to system allocator ( **35x** decrease in temporary allocations), **6x** decrease in memory consumption by worker and slight improvement in CPU usage too.  
Most of remaining allocations are coming from bandwidth estimation code of libwebrtc which I decided to skip for now.

With that in Rust videoroom example a room with **5 participants** , each of which has **audio and 720p@30 video** sent to everyone else, the whole application (WebSocket server, worker, everything) consumes roughly **6.5 MiB** of residential memory.

Please test it in your projects if possible and I’d like to know any feedback about issues you may encounter.

Branch to use: [GitHub - nazar-pc/mediasoup at memory-optimizations](https://github.com/nazar-pc/mediasoup/tree/memory-optimizations)

UPD: Halved memory consumption again (savings on audio packets)!

---

<div class="post-metadata">

**Author:** ![ea167](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ea167/32/404_2.png) [@ea167](https://mediasoup.discourse.group/u/ea167)\
**Post date:** [September 18, 2021, 1:26am UTC](https://mediasoup.discourse.group/t/need-help-testing-significant-memory-optimizations/3302/2 "2021-09-18T01:26:04Z")

</div>

Sounds great Nazar, congrats!!

What’s the easiest way to install your branch on a server? Could you provide some instructions?

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [September 18, 2021, 6:56am UTC](https://mediasoup.discourse.group/t/need-help-testing-significant-memory-optimizations/3302/3 "2021-09-18T06:56:02Z")

</div>

Standard way you install something from GitHub, just replace mediasoup version with `github:nazar-pc/mediasoup#memory-optimizations` and it should pull the right version.

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [September 24, 2021, 8:42pm UTC](https://mediasoup.discourse.group/t/need-help-testing-significant-memory-optimizations/3302/4 "2021-09-24T20:42:12Z")

</div>

Did you have a chance to test yet?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [September 24, 2021, 9:37pm UTC](https://mediasoup.discourse.group/t/need-help-testing-significant-memory-optimizations/3302/5 "2021-09-24T21:37:30Z")

</div>

I’ll test it next week

---

<div class="post-metadata">

**Author:** ![prlanzarin](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/prlanzarin/32/826_2.png) [@prlanzarin](https://mediasoup.discourse.group/u/prlanzarin)\
**Post date:** [January 6, 2022, 6:29pm UTC](https://mediasoup.discourse.group/t/need-help-testing-significant-memory-optimizations/3302/6 "2022-01-06T18:29:33Z")

</div>

Hey all, I’ve been running a few load/validation tests over the PR branch for the past couple of days to help with the testing process a bit.

Been talking with @nazar-pc via mail about the testing process but would like to share the results I’ve got so far here.

It’d be a fairly long one if I dumped everything on a Discourse post, so I’ll put a tl;dr with a link to a Notion page with more detailed test infos.

- Comparison tests were done against the 3.9.2 release tag
- Current branch HEAD (`e534014`) seems to have a memory leak regression (@nazar-pc pinpointed the commit/is aware)
- Commit `3f8d0e6` behaves as expected
  - Improvements in overall memory usage for the test plans I ran were massive (up to, roughly, 10% of total used memory seen in 3.9.2 depending on the scenario [see Test 1 in the Notion link down below])
  - I’ve seen no crashes or unexpected behavior from workers in that commit
  - There seems to be a marginal CPU usage improvement as well [see Test 1 in the Notion link down below]; but the margin it’s too small to assert anything. However, it’s safe to assert that there shouldn’t be any regressions on that area.

- The test data (graphs, test scenarios etc) can be accessed through: [mediasoup: testing memory improvements](https://mconf.notion.site/mediasoup-testing-memory-improvements-38bba8a9e95641e597cd648cab260ef1)

* * *

s,

prlanzarin
