# ARM64 and jemalloc

**URL:** <https://meta.discourse.org/t/arm64-and-jemalloc/297721>\
**Category:** Bug\
**Tags:** arm\
**Created:** [March 3, 2024, 6:40pm UTC](https://meta.discourse.org/t/arm64-and-jemalloc/297721 "2024-03-03T18:40:09Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)\
**Post date:** [March 3, 2024, 6:40pm UTC](https://meta.discourse.org/t/arm64-and-jemalloc/297721/1 "2024-03-03T18:40:09Z")

</div>

I’m experimenting running Discourse in AWS’s graviton based instances as they are attractive price wise. I understand that aarch64 support is experimental, but the build message says to report issues, so this is it. I think many are running Discourse in AWS, so hopefully this can benefit others too.

I got an existing installation up and running in arm64 after a rebuild and some basic sanity check to make sure the frontend loads. However, a `./launcher logs web_only` shows that `rails.stderr.log` is constantly being filled with these:

```plaintext
ERROR: ld.so: object '/usr/lib/libjemalloc.so.1' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/libjemalloc.so.1' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

```

And, indeed, `/usr/lib/libjemalloc.so.1` doesn’t exist on arm64 like it does on the x84 images, but `/usr/lib/libjemalloc.so.2` does. I traced the difference of version in arm64 to this:

> <https://github.com/discourse/discourse_docker/blob/6765ecc554e994ad3973ba73acfdf73bef420624/image/base/install-jemalloc#L5-L22>

Side note: kudos for the good documentation of the change.

I think the error message comes from the specific mention to the non-existent `/usr/lib/libjemalloc.so.1` done here:

> <https://github.com/discourse/discourse_docker/blob/6765ecc554e994ad3973ba73acfdf73bef420624/image/base/slim.Dockerfile#L5-L10>

A quick&dirty override of `$RUBY_ALLOCATOR` on `templates/web.template.yml` seems to have successfully stopped the error message, so it appears rails (puma?) is now running with the proper libjemalloc.

Having said that, I don’t know if a proper fix may need more changes than this and if such change may have other implications for production systems. Still, wanted to share in case it affects others trying to use Discourse with arm64 in AWS. Perhaps the Discourse team can take a look too?

---

_[View the full topic](https://meta.discourse.org/t/arm64-and-jemalloc/297721)._
