Skip to content

Commit eceb7f0

Browse files
authored
Use Jemalloc (#189)
Jemalloc performs better than the standard allocator in various metrics (http://ithare.com/testing-memory-allocators-ptmalloc2-tcmalloc-hoard-jemalloc-while-trying-to-simulate-real-world-loads/). This PR makes changes to use Jemalloc as the global allocator for Pgcat. Windows is not officially supported by Pgcat but it should still compile but without Jemalloc as the allocator.
1 parent 83fd639 commit eceb7f0

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

Cargo.lock

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ rustls-pemfile = "1"
3434
hyper = { version = "0.14", features = ["full"] }
3535
phf = { version = "0.11.1", features = ["macros"] }
3636
exitcode = "1.1.2"
37+
38+
[target.'cfg(not(target_env = "msvc"))'.dependencies]
39+
jemallocator = "0.3.2"

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ extern crate tokio;
3737
extern crate tokio_rustls;
3838
extern crate toml;
3939

40+
#[cfg(not(target_env = "msvc"))]
41+
use jemallocator::Jemalloc;
42+
43+
#[cfg(not(target_env = "msvc"))]
44+
#[global_allocator]
45+
static GLOBAL: Jemalloc = Jemalloc;
46+
4047
use log::{error, info, warn};
4148
use parking_lot::Mutex;
4249
use pgcat::format_duration;

0 commit comments

Comments
 (0)