perf: inline public getters/setters, and use non-generic inner functions
To reduce compile-times and avoid some overhead to binary size, this will modify some of our generic functions to use non-generic inner functions where possible. The inner functions are marked carefully with `#[inline(never)]` to prevent being inlined by LLVM at their callsites While looking for generic functions to optimize, I have also taken the opportunity to annotate public non-generic getters and setters with `#[inline]` to ensure that LLVM will inline them across crate boundaries. By default, only generic functions are automatically inlined, and only when enabling fat LTO are constant functions reliably inlined across crate boundaries.
This commit is contained in:
parent
c538d672df
commit
8cf372c9b9
55 changed files with 702 additions and 255 deletions
|
|
@ -11,6 +11,7 @@ unsafe extern "C" {
|
|||
fn mallopt(param: c_int, value: c_int) -> c_int;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn trim(pad: usize) {
|
||||
unsafe {
|
||||
malloc_trim(pad);
|
||||
|
|
@ -18,6 +19,7 @@ pub fn trim(pad: usize) {
|
|||
}
|
||||
|
||||
/// Prevents glibc from hoarding memory via memory fragmentation.
|
||||
#[inline]
|
||||
pub fn limit_mmap_threshold(threshold: i32) {
|
||||
unsafe {
|
||||
mallopt(M_MMAP_THRESHOLD, threshold as c_int);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue