# Llama2.🔥 performance degradation after updating code to the latest Mojo compiler

**URL:** <https://forum.modular.com/t/llama2-performance-degradation-after-updating-code-to-the-latest-mojo-compiler/2465>\
**Category:** Mojo\
**Tags:** performance\
**Created:** [November 20, 2025, 1:41am UTC](https://forum.modular.com/t/llama2-performance-degradation-after-updating-code-to-the-latest-mojo-compiler/2465 "2025-11-20T01:41:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Aydyn](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Aydyn](https://forum.modular.com/u/Aydyn)\
**Post date:** [November 21, 2025, 8:58pm UTC](https://forum.modular.com/t/llama2-performance-degradation-after-updating-code-to-the-latest-mojo-compiler/2465/2 "2025-11-21T20:58:14Z")

</div>

After doing a deep round of profiling on macOS with Instruments (which was actually new to me - didn’t know it exist), I finally tracked down an issue.  
With a mix of manual profiling and a few back-and-forths with Gemini 3.0, I found the culprit: an Accumulator struct that was being allocated on the heap and tanking performance.  
After switching it to `stack_allocation`, the performance actually ended up _higher_ than before 🔥 👏

> **[Improve performance v0.25.7 (#99) · tairov/llama2.mojo@1b2c4cf](https://github.com/tairov/llama2.mojo/commit/1b2c4cf5e493229c2724c01d741925cdc9a07fa5#diff-af5736db4561f0d7a64e3b673fcbbd9e51118ed5094195d2557425d6074402caL158-L383)**
>
> \* Get rid of Accumulator allocating on the heap and use stack\_allocations instead
> Fixed performance
> 
> \* Remove performance note as performance is fixed

 ![image](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/542efee674f41727093e49581d45bb495653688b.jpeg)

---

_[View the full topic](https://forum.modular.com/t/llama2-performance-degradation-after-updating-code-to-the-latest-mojo-compiler/2465)._
