"percent-encoding",
]
+[[package]]
+name = "fs_extra"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
+
[[package]]
name = "fsevent"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
+[[package]]
+name = "jemalloc-ctl"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7"
+dependencies = [
+ "jemalloc-sys",
+ "libc",
+ "paste",
+]
+
+[[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 = "jod-thread"
version = "0.1.2"
"drop_bomb",
]
+[[package]]
+name = "paste"
+version = "0.1.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880"
+dependencies = [
+ "paste-impl",
+ "proc-macro-hack",
+]
+
+[[package]]
+name = "paste-impl"
+version = "0.1.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6"
+dependencies = [
+ "proc-macro-hack",
+]
+
[[package]]
name = "paths"
version = "0.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
+[[package]]
+name = "proc-macro-hack"
+version = "0.5.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
+
[[package]]
name = "proc-macro2"
version = "1.0.24"
version = "0.0.0"
dependencies = [
"cfg-if 1.0.0",
+ "jemalloc-ctl",
"la-arena",
"libc",
"once_cell",
"ide",
"ide_db",
"itertools 0.10.0",
+ "jemallocator",
"jod-thread",
"log",
"lsp-server",
cfg-if = "1"
libc = "0.2.73"
la-arena = { version = "0.2.0", path = "../../lib/arena" }
+jemalloc-ctl = { version = "0.3.3", optional = true }
[target.'cfg(target_os = "linux")'.dependencies]
perf-event = "0.4"
[features]
cpu_profiler = []
+jemalloc = ["jemalloc-ctl"]
# Uncomment to enable for the whole crate graph
# default = [ "cpu_profiler" ]
impl MemoryUsage {
pub fn current() -> MemoryUsage {
cfg_if! {
- if #[cfg(all(target_os = "linux", target_env = "gnu"))] {
+ if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] {
+ jemalloc_ctl::epoch::advance().unwrap();
+ MemoryUsage {
+ allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap() as isize),
+ }
+ } else if #[cfg(all(target_os = "linux", target_env = "gnu"))] {
// Note: This is incredibly slow.
let alloc = unsafe { libc::mallinfo() }.uordblks as isize;
MemoryUsage { allocated: Bytes(alloc) }
[target.'cfg(windows)'.dependencies]
winapi = "0.3.8"
+[target.'cfg(not(target_env = "msvc"))'.dependencies]
+jemallocator = { version = "0.3.2", optional = true }
+
[dev-dependencies]
expect-test = "1.1"
test_utils = { path = "../test_utils" }
mbe = { path = "../mbe" }
tt = { path = "../tt" }
+
+[features]
+jemalloc = ["jemallocator", "profile/jemalloc"]
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
+#[cfg(all(feature = "jemalloc", not(target_env = "msvc")))]
+#[global_allocator]
+static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
+
fn main() {
if let Err(err) = try_main() {
eprintln!("{}", err);
pub enum Malloc {
System,
Mimalloc,
+ Jemalloc,
}
impl InstallCmd {
let features = match opts.malloc {
Malloc::System => &[][..],
Malloc::Mimalloc => &["--features", "mimalloc"],
+ Malloc::Jemalloc => &["--features", "jemalloc"],
};
let cmd = cmd!("cargo install --path crates/rust-analyzer --locked --force {features...}");
--client[=CLIENT] Install only VS Code plugin.
CLIENT is one of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss'
--server Install only the language server
- --mimalloc Use mimalloc for server
+ --mimalloc Use mimalloc allocator for server
+ --jemalloc Use jemalloc allocator for server
-h, --help Prints help information
"
);
return Ok(());
}
- let malloc =
- if args.contains("--mimalloc") { Malloc::Mimalloc } else { Malloc::System };
+ let malloc = if args.contains("--mimalloc") {
+ Malloc::Mimalloc
+ } else if args.contains("--jemalloc") {
+ Malloc::Jemalloc
+ } else {
+ Malloc::System
+ };
let client_opt = args.opt_value_from_str("--client")?;