From d2582aac02b107e507c53122b19e914bb7f10483 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 12 Sep 2021 10:27:02 -0400 Subject: [PATCH] Use jemalloc instead of the system allocator for Rust --- docker/app/run-development | 3 +++ native/furbooru_markdown/Cargo.lock | 30 +++++++++++++++++++++++++++++ native/furbooru_markdown/Cargo.toml | 1 + native/furbooru_markdown/src/lib.rs | 4 ++++ 4 files changed, 38 insertions(+) diff --git a/docker/app/run-development b/docker/app/run-development index e257ddab..529fc9ca 100755 --- a/docker/app/run-development +++ b/docker/app/run-development @@ -1,5 +1,8 @@ #!/usr/bin/env sh +# For compatibility with musl libc +export CARGO_FEATURE_DISABLE_INITIAL_EXEC_TLS=1 + background() { while :; do mix run -e 'Philomena.Release.update_channels()' diff --git a/native/furbooru_markdown/Cargo.lock b/native/furbooru_markdown/Cargo.lock index 2a6e6bab..bf632bd9 100644 --- a/native/furbooru_markdown/Cargo.lock +++ b/native/furbooru_markdown/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "adler" version = "1.0.2" @@ -213,11 +215,18 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "fs_extra" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" + [[package]] name = "furbooru_markdown" version = "0.1.1" dependencies = [ "comrak", + "jemallocator", "lazy_static", "log", "pretty_env_logger", @@ -283,6 +292,27 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +[[package]] +name = "jemalloc-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45" +dependencies = [ + "cc", + "fs_extra", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69" +dependencies = [ + "jemalloc-sys", + "libc", +] + [[package]] name = "lazy_static" version = "1.4.0" diff --git a/native/furbooru_markdown/Cargo.toml b/native/furbooru_markdown/Cargo.toml index 9cbc1d94..7c21e352 100644 --- a/native/furbooru_markdown/Cargo.toml +++ b/native/furbooru_markdown/Cargo.toml @@ -16,6 +16,7 @@ regex = "1" log = "0" pretty_env_logger = "0" rustler = "0.22.0" +jemallocator = "0.3.2" [profile.release] opt-level = 3 diff --git a/native/furbooru_markdown/src/lib.rs b/native/furbooru_markdown/src/lib.rs index e01b9c88..7d834349 100644 --- a/native/furbooru_markdown/src/lib.rs +++ b/native/furbooru_markdown/src/lib.rs @@ -2,6 +2,10 @@ use comrak::{markdown_to_html, ComrakOptions}; use lazy_static::lazy_static; use regex::{Captures, Regex}; use rustler::Term; +use jemallocator::Jemalloc; + +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; mod atoms { rustler::atoms! {