---
updatedAt: 2026-09-16T22:25:40.000Z
agentTools:
  projectIndex: https://docs.thousandbrains.org/llms.txt
---

# Profile and Speed up Monty

The current implementation of Montys algorithm is suboptimal and can be optimized. This item includes identifying computational bottlenecks and addressing them.

We have profiled Monty a while ago and identified several computational bottlenecks. Some of them have been addressed but there are still many places where the Monty algorithm could be optimized. It has also been a long time since Monty was profiled, so repeating this now would be worthwhile.

> 📘
> One of the most significant computational bottlenecks in Monty at the moment is the KD-Tree search, which is tracked in a separate future work item to [find a faster alternative to KT-Tree search](https://docs.thousandbrains.org/docs/find-faster-alternative-to-kdtree-search).

For the profiling and speedup efforts from back then, see the following two videos:

[block:embed]
{
  "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJVz0Km98hLo%3Ffeature%3Doembed&display_name=YouTube&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJVz0Km98hLo&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJVz0Km98hLo%2Fhqdefault.jpg&type=text%2Fhtml&schema=youtube\" width=\"854\" height=\"480\" scrolling=\"no\" title=\"YouTube embed\" frameborder=\"0\" allow=\"autoplay; fullscreen; encrypted-media; picture-in-picture;\" allowfullscreen=\"true\"></iframe>",
  "url": "https://www.youtube.com/watch?v=JVz0Km98hLo",
  "title": "2023/02 - Speedup Discussions - Part 1 ",
  "favicon": "https://www.youtube.com/favicon.ico",
  "image": "https://i.ytimg.com/vi/JVz0Km98hLo/hqdefault.jpg",
  "provider": "https://www.youtube.com/",
  "href": "https://www.youtube.com/watch?v=JVz0Km98hLo",
  "typeOfEmbed": "youtube"
}
[/block]

[block:embed]
{
  "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FXSg6UwGti4c%3Ffeature%3Doembed&display_name=YouTube&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXSg6UwGti4c&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FXSg6UwGti4c%2Fhqdefault.jpg&type=text%2Fhtml&schema=youtube\" width=\"854\" height=\"480\" scrolling=\"no\" title=\"YouTube embed\" frameborder=\"0\" allow=\"autoplay; fullscreen; encrypted-media; picture-in-picture;\" allowfullscreen=\"true\"></iframe>",
  "url": "https://www.youtube.com/watch?v=XSg6UwGti4c",
  "title": "2023/03 - Speedup Discussions - Part 2 ",
  "favicon": "https://www.youtube.com/favicon.ico",
  "image": "https://i.ytimg.com/vi/XSg6UwGti4c/hqdefault.jpg",
  "provider": "https://www.youtube.com/",
  "href": "https://www.youtube.com/watch?v=XSg6UwGti4c",
  "typeOfEmbed": "youtube"
}
[/block]

You can also find some further discussion and ideas in [this thread](https://forum.thousandbrains.org/t/2023-03-speedup-discussions-part-2/348) on our Forum.

<style>
.contribution-button {
    border-radius: 5px;
    background-color: #EFEFEF;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 5px;
    padding-bottom: 5px;
    color: black;
    weight: bolder;
    display: inline-flex;
    margin-top: -10px;
    align-items: center;
    border: 1px solid #CCCCCC;
    text-decoration: none !important;
}
.contribution-button:hover {
    background-color: #DDDDDD;
    cursor: pointer;
    color: black;
}
</style>

<br><br>

***

#### Help Us Make This Page Better

All our docs are open-source. If something is wrong or unclear, submit a PR to fix it!

<a class="contribution-button" href="https://github.com/thousandbrainsproject/tbp.monty/edit/main/docs/future-work/framework-improvements/profile-and-optimize-monty.md" target="_blank">Make a Contribution</a>

[Learn how to contribute to our docs](https://docs.thousandbrains.org/docs/documentation)