Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Lee <busyjaylee@gmail.com>
  • Loading branch information
BusyJay committed Jul 14, 2024
2 parents 3b21b21 + f260a80 commit 0c9e8d9
Show file tree
Hide file tree
Showing 18 changed files with 337 additions and 109 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
pull_request:
branches:
branches:
- 'master'
- 'main'
push:
Expand All @@ -16,11 +16,11 @@ jobs:
strategy:
matrix:
include:
- name: aarch64-unknown-linux-gnu
target: aarch64-unknown-linux-gnu
- name: x86_64-apple-darwin
target: x86_64-apple-darwin
nobgt: 0
no_tests: 1
tag: arm64
tag: macos-13
- name: x86_64-unknown-linux-gnu (nightly)
target: x86_64-unknown-linux-gnu
nobgt: 0
Expand All @@ -38,11 +38,17 @@ jobs:
nobgt: 1
no_tests: 1
tag: ubuntu-latest
- name: x86_64-apple-darwin (stable)
target: x86_64-apple-darwin
- name: aarch64-apple-darwin (stable)
target: aarch64-apple-darwin
nobgt: 0
no_tests: 1
tag: macos-latest
- name: x86_64-unknown-linux-gnu (msrv)
target: x86_64-unknown-linux-gnu
nobgt: 0
no_tests: 0
rust: msrv
tag: ubuntu-latest
runs-on: ${{ matrix.tag }}
env:
TARGET: ${{ matrix.target }}
Expand All @@ -57,6 +63,9 @@ jobs:
if [[ "${{ matrix.rust }}" == "nightly" ]]; then
rustup default nightly
fi
if [[ "${{ matrix.rust }}" == "msrv" ]]; then
rustup default `grep rust-version jemalloc-sys/Cargo.toml | cut -d '"' -f 2`
fi
rustup target add ${{ matrix.target }}
if [[ "$TARGET" == "x86_64-unknown-linux-musl" ]]; then
sudo apt install -y musl-tools
Expand Down Expand Up @@ -85,5 +94,5 @@ jobs:
- run: cargo clippy -p jemallocator -- -D clippy::all
- run: cargo clippy -p jemallocator-global -- -D clippy::all
- run: cargo clippy -p jemalloc-ctl -- -D clippy::all
- run: env RUSTDOCFLAGS="--cfg jemallocator_docs" cargo doc
- run: env RUSTDOCFLAGS="--cfg jemallocator_docs" cargo doc --features stats,profiling,use_std
- run: shellcheck ci/*.sh
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "jemalloc-sys/jemalloc"]
path = jemalloc-sys/jemalloc
url = https://github.com/jemalloc/jemalloc
url = https://github.com/tikv/jemalloc
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 0.6.0 - 2024-07-14

- Fix build on riscv64gc-unknown-linux-musl (#67) (#75)
- Allow jemalloc-sys to be the default allocator on musl linux (#70)
- Add Chimera Linux to gmake targets (#73)
- Add profiling options to jemalloc-ctl (#74)
- Fix jemalloc version not shown in API (#77)
- Fix jemalloc stats is still enabled when stats feature is disabled (#82)
- Fix duplicated symbol when build and link on aarch64-linux-android (#83)
- Revise CI runner platform on macOS (#86)
- Allow setting per-target env (#91)
- Remove outdated clippy allows (#94)
- Set MSRV to 1.71.0 (#95)

Note since 0.6.0, if you want to use jemalloc stats, you have to enable the
feature explicitly.

# 0.5.4 - 2023-07-22

- Add disable_initial_exec_tls feature for jemalloc-ctl (#59)
Expand Down
9 changes: 6 additions & 3 deletions jemalloc-ctl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jemalloc-ctl"
version = "0.5.4"
version = "0.6.0"
authors = [
"Steven Fackler <sfackler@gmail.com>",
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
Expand All @@ -26,17 +26,20 @@ is-it-maintained-open-issues = { repository = "tikv/jemallocator" }
maintenance = { status = "actively-developed" }

[dependencies]
jemalloc-sys = { path = "../jemalloc-sys", version = "0.5.0" }
jemalloc-sys = { path = "../jemalloc-sys", version = "0.6.0" }
libc = { version = "0.2", default-features = false }
paste = "1"

[dev-dependencies]
jemallocator = { path = "../jemallocator", version = "0.5.0" }
jemallocator = { path = "../jemallocator", version = "0.6.0" }

[features]
default = []
stats = ["jemalloc-sys/stats"]
profiling = ["jemalloc-sys/profiling"]
use_std = [ "libc/use_std" ]
disable_initial_exec_tls = ["jemalloc-sys/disable_initial_exec_tls"]

[package.metadata.docs.rs]
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
features = ["stats", "profiling", "use_std"]
4 changes: 0 additions & 4 deletions jemalloc-ctl/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
//! Error type
#![cfg_attr(
feature = "cargo-clippy",
allow(clippy::cast_sign_loss, clippy::cast_possible_wrap)
)]

use crate::{fmt, num, result};
use libc::c_int;
Expand Down
111 changes: 59 additions & 52 deletions jemalloc-ctl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,66 @@
//! `$op::{read(), write(x), update(x)}` on the type calls `mallctl` with the
//! string-based API. If the operation will be repeatedly performed, a MIB for
//! the operation can be obtained using `$op.mib()`.
//!
//! # Examples
//!
//! Repeatedly printing allocation statistics:
//!
//! ```no_run
//! use std::thread;
//! use std::time::Duration;
//! use jemalloc_ctl::{stats, epoch};
//!
//! #[global_allocator]
//! static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
//!
//! fn main() {
//! loop {
//! // many statistics are cached and only updated when the epoch is advanced.
//! epoch::advance().unwrap();
//!
//! let allocated = stats::allocated::read().unwrap();
//! let resident = stats::resident::read().unwrap();
//! println!("{} bytes allocated/{} bytes resident", allocated, resident);
//! thread::sleep(Duration::from_secs(10));
//! }
//! }
//! ```
//!
//! Doing the same with the MIB-based API:
//!
//! ```no_run
//! use std::thread;
//! use std::time::Duration;
//! use jemalloc_ctl::{stats, epoch};
//!
//! #[global_allocator]
//! static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
//!
//! fn main() {
//! let e = epoch::mib().unwrap();
//! let allocated = stats::allocated::mib().unwrap();
//! let resident = stats::resident::mib().unwrap();
//! loop {
//! // many statistics are cached and only updated when the epoch is advanced.
//! e.advance().unwrap();
//!
//! let allocated = allocated.read().unwrap();
//! let resident = resident.read().unwrap();
//! println!("{} bytes allocated/{} bytes resident", allocated, resident);
//! thread::sleep(Duration::from_secs(10));
//! }
//! }
//! ```
#![cfg_attr(
feature = "stats",
doc = r##"
# Examples
Repeatedly printing allocation statistics:
```no_run
use std::thread;
use std::time::Duration;
use jemalloc_ctl::{stats, epoch};
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
fn main() {
loop {
// many statistics are cached and only updated when the epoch is advanced.
epoch::advance().unwrap();
let allocated = stats::allocated::read().unwrap();
let resident = stats::resident::read().unwrap();
println!("{} bytes allocated/{} bytes resident", allocated, resident);
thread::sleep(Duration::from_secs(10));
}
}
```
Doing the same with the MIB-based API:
```no_run
use std::thread;
use std::time::Duration;
use jemalloc_ctl::{stats, epoch};
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
fn main() {
let e = epoch::mib().unwrap();
let allocated = stats::allocated::mib().unwrap();
let resident = stats::resident::mib().unwrap();
loop {
// many statistics are cached and only updated when the epoch is advanced.
e.advance().unwrap();
let allocated = allocated.read().unwrap();
let resident = resident.read().unwrap();
println!("{} bytes allocated/{} bytes resident", allocated, resident);
thread::sleep(Duration::from_secs(10));
}
}
```
"##
)]
// TODO: rename the following lint on next minor bump
#![allow(renamed_and_removed_lints)]
#![deny(missing_docs, broken_intra_doc_links)]
#![cfg_attr(not(feature = "use_std"), no_std)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::module_name_repetitions))]

#[cfg(test)]
#[global_allocator]
Expand All @@ -88,7 +92,10 @@ pub mod config;
mod error;
mod keys;
pub mod opt;
#[cfg(feature = "profiling")]
pub mod profiling;
pub mod raw;
#[cfg(feature = "stats")]
pub mod stats;
#[cfg(feature = "use_std")]
pub mod stats_print;
Expand Down
Loading

0 comments on commit 0c9e8d9

Please sign in to comment.