remove `heim` dependency

It doesn't work on Android, and I can't fault it for that (Platform difference)
but it also drags in `uom` which has a bunch of template magic that takes
forever to compile, and I'm pretty sure it's dragging down my compile times.

I tried to build `ptth_server` on nightly to get compile timings, and heim
depends on `socket2` which failed to compile.

And I never ended up using the CPU monitoring. So heim is gone now.
main
_ 2021-07-11 12:17:36 +00:00
parent 277c00b753
commit 6f45f5105e
6 changed files with 7 additions and 508 deletions

451
Cargo.lock generated
View File

@ -55,105 +55,6 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "async-channel"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319"
dependencies = [
"concurrent-queue",
"event-listener",
"futures-core",
]
[[package]]
name = "async-executor"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb877970c7b440ead138f6321a3b5395d6061183af779340b65e20c0fede9146"
dependencies = [
"async-task",
"concurrent-queue",
"fastrand",
"futures-lite",
"once_cell",
"vec-arena",
]
[[package]]
name = "async-fs"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b3ca4f8ff117c37c278a2f7415ce9be55560b846b5bc4412aaa5d29c1c3dae2"
dependencies = [
"async-lock",
"blocking",
"futures-lite",
]
[[package]]
name = "async-io"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9315f8f07556761c3e48fec2e6b276004acf426e6dc068b2c2251854d65ee0fd"
dependencies = [
"concurrent-queue",
"fastrand",
"futures-lite",
"libc",
"log",
"nb-connect",
"once_cell",
"parking",
"polling",
"vec-arena",
"waker-fn",
"winapi",
]
[[package]]
name = "async-lock"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1996609732bde4a9988bc42125f55f2af5f3c36370e27c778d5191a4a1b63bfb"
dependencies = [
"event-listener",
]
[[package]]
name = "async-net"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06de475c85affe184648202401d7622afb32f0f74e02192857d0201a16defbe5"
dependencies = [
"async-io",
"blocking",
"fastrand",
"futures-lite",
]
[[package]]
name = "async-process"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef37b86e2fa961bae5a4d212708ea0154f904ce31d1a4a7f47e1bbc33a0c040b"
dependencies = [
"async-io",
"blocking",
"cfg-if 1.0.0",
"event-listener",
"futures-lite",
"once_cell",
"signal-hook",
"winapi",
]
[[package]]
name = "async-task"
version = "4.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0"
[[package]]
name = "async-trait"
version = "0.1.48"
@ -165,12 +66,6 @@ dependencies = [
"syn",
]
[[package]]
name = "atomic-waker"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a"
[[package]]
name = "atty"
version = "0.2.14"
@ -236,20 +131,6 @@ dependencies = [
"byte-tools",
]
[[package]]
name = "blocking"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9"
dependencies = [
"async-channel",
"async-task",
"atomic-waker",
"fastrand",
"futures-lite",
"once_cell",
]
[[package]]
name = "bumpalo"
version = "3.6.1"
@ -274,12 +155,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
[[package]]
name = "cache-padded"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba"
[[package]]
name = "cc"
version = "1.0.67"
@ -327,15 +202,6 @@ dependencies = [
"vec_map",
]
[[package]]
name = "concurrent-queue"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3"
dependencies = [
"cache-padded",
]
[[package]]
name = "constant_time_eq"
version = "0.1.5"
@ -374,30 +240,10 @@ version = "3.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c15b8ec3b5755a188c141c1f6a98e76de31b936209bf066b647979e2a84764a9"
dependencies = [
"nix 0.20.0",
"nix",
"winapi",
]
[[package]]
name = "darwin-libproc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc629b7cf42586fee31dae31f9ab73fa5ff5f0170016aa61be5fcbc12a90c516"
dependencies = [
"darwin-libproc-sys",
"libc",
"memchr",
]
[[package]]
name = "darwin-libproc-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef0aa083b94c54aa4cfd9bbfd37856714c139d1dc511af80270558c7ba3b4816"
dependencies = [
"libc",
]
[[package]]
name = "dashmap"
version = "4.0.2"
@ -470,27 +316,12 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "event-listener"
version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59"
[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "fastrand"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3"
dependencies = [
"instant",
]
[[package]]
name = "fnv"
version = "1.0.7"
@ -570,21 +401,6 @@ version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59"
[[package]]
name = "futures-lite"
version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"memchr",
"parking",
"pin-project-lite",
"waker-fn",
]
[[package]]
name = "futures-macro"
version = "0.3.13"
@ -609,12 +425,6 @@ version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80"
[[package]]
name = "futures-timer"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
[[package]]
name = "futures-util"
version = "0.3.13"
@ -674,12 +484,6 @@ dependencies = [
"wasi",
]
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "h2"
version = "0.3.2"
@ -728,125 +532,6 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "heim"
version = "0.1.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8a653442b9bdd11a77d3753a60443c60c4437d3acac8e6c3d4a6a9acd7cceed"
dependencies = [
"heim-common",
"heim-process",
"heim-runtime",
]
[[package]]
name = "heim-common"
version = "0.1.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d767e6e47cf88abe7c9a5ebb4df82f180d30d9c0ba0269b6d166482461765834"
dependencies = [
"cfg-if 1.0.0",
"core-foundation",
"futures-core",
"futures-util",
"lazy_static",
"libc",
"mach",
"nix 0.19.1",
"pin-utils",
"uom",
"winapi",
]
[[package]]
name = "heim-cpu"
version = "0.1.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ba5fb13a3b90581d22b4edf99e87c54316444622ae123d36816a227a7caa6df"
dependencies = [
"cfg-if 1.0.0",
"futures",
"glob",
"heim-common",
"heim-runtime",
"lazy_static",
"libc",
"mach",
"ntapi",
"smol",
"winapi",
]
[[package]]
name = "heim-host"
version = "0.1.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9abf6cd02bc4f6e6aa31a7f80702a2d0e574f4f2c6156a93c3550eb036304722"
dependencies = [
"cfg-if 1.0.0",
"heim-common",
"heim-runtime",
"lazy_static",
"libc",
"log",
"mach",
"ntapi",
"platforms",
"winapi",
]
[[package]]
name = "heim-net"
version = "0.1.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d13afa5e9b71c813c1e087bb27f51ae87d3a6d68a2bdd045bae4322dfae4948b"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
"heim-common",
"heim-runtime",
"libc",
"macaddr",
"nix 0.19.1",
]
[[package]]
name = "heim-process"
version = "0.1.1-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "386870aac75d29b817fe709f1ef4303553e0af369e3c71d04beceeb50ae2cf39"
dependencies = [
"async-trait",
"cfg-if 1.0.0",
"darwin-libproc",
"futures",
"heim-common",
"heim-cpu",
"heim-host",
"heim-net",
"heim-runtime",
"lazy_static",
"libc",
"mach",
"memchr",
"ntapi",
"ordered-float",
"smol",
"winapi",
]
[[package]]
name = "heim-runtime"
version = "0.1.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54ec7e5238c8f0dd0cc60914d31a5a7aadd4cde74c966a76c1caed1f5224e9b8"
dependencies = [
"futures",
"futures-timer",
"once_cell",
"smol",
]
[[package]]
name = "hermit-abi"
version = "0.1.18"
@ -1032,21 +717,6 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "macaddr"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baee0bbc17ce759db233beb01648088061bf678383130602a298e6998eedb2d8"
[[package]]
name = "mach"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
dependencies = [
"libc",
]
[[package]]
name = "maplit"
version = "1.0.2"
@ -1128,28 +798,6 @@ dependencies = [
"tempfile",
]
[[package]]
name = "nb-connect"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19900e7eee95eb2b3c2e26d12a874cc80aaf750e31be6fcbe743ead369fa45d"
dependencies = [
"libc",
"socket2",
]
[[package]]
name = "nix"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2"
dependencies = [
"bitflags",
"cc",
"cfg-if 1.0.0",
"libc",
]
[[package]]
name = "nix"
version = "0.20.0"
@ -1181,17 +829,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
@ -1256,21 +893,6 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "ordered-float"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dacdec97876ef3ede8c50efc429220641a0b11ba0048b4b0c357bccbc47c5204"
dependencies = [
"num-traits",
]
[[package]]
name = "parking"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
[[package]]
name = "parking_lot"
version = "0.11.1"
@ -1383,25 +1005,6 @@ version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
name = "platforms"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc77a3fc329982cbf3ea772aa265b742a550998bad65747c630406ee52dac425"
[[package]]
name = "polling"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fc12d774e799ee9ebae13f4076ca003b40d18a11ac0f3641e6f899618580b7b"
dependencies = [
"cfg-if 1.0.0",
"libc",
"log",
"wepoll-sys",
"winapi",
]
[[package]]
name = "ppv-lite86"
version = "0.2.10"
@ -1601,7 +1204,6 @@ dependencies = [
"chrono",
"futures",
"handlebars",
"heim",
"http",
"lazy_static",
"maplit",
@ -1623,7 +1225,6 @@ dependencies = [
"tracing",
"tracing-futures",
"tracing-subscriber",
"uom",
]
[[package]]
@ -1979,16 +1580,6 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "signal-hook"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6aa894ef3fade0ee7243422f4fbbd6c2b48e6de767e621d37ef65f2310f53cea"
dependencies = [
"libc",
"signal-hook-registry",
]
[[package]]
name = "signal-hook-registry"
version = "1.3.0"
@ -2010,24 +1601,6 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "smol"
version = "1.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85cf3b5351f3e783c1d79ab5fc604eeed8b8ae9abd36b166e8b87a089efd85e4"
dependencies = [
"async-channel",
"async-executor",
"async-fs",
"async-io",
"async-lock",
"async-net",
"async-process",
"blocking",
"futures-lite",
"once_cell",
]
[[package]]
name = "socket2"
version = "0.4.0"
@ -2421,7 +1994,6 @@ version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e76503e636584f1e10b9b3b9498538279561adcef5412927ba00c2b32c4ce5ed"
dependencies = [
"num-rational",
"num-traits",
"typenum",
]
@ -2444,12 +2016,6 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
[[package]]
name = "vec-arena"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34b2f665b594b07095e3ac3f718e13c2197143416fae4c5706cffb7b1af8d7f1"
[[package]]
name = "vec_map"
version = "0.8.2"
@ -2462,12 +2028,6 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
[[package]]
name = "waker-fn"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
[[package]]
name = "want"
version = "0.3.0"
@ -2581,15 +2141,6 @@ dependencies = [
"webpki",
]
[[package]]
name = "wepoll-sys"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fcb14dea929042224824779fbc82d9fab8d2e6d3cbc0ac404de8edf489e77ff"
dependencies = [
"cc",
]
[[package]]
name = "winapi"
version = "0.3.9"

View File

@ -1,3 +1,8 @@
pub use std::{
sync::Arc,
time::{Duration, Instant},
};
pub use tracing::{
debug, error, info, trace, warn,
instrument,

View File

@ -22,7 +22,6 @@ blake3 = "0.3.7"
chrono = {version = "0.4.19", features = ["serde"]}
futures = "0.3.7"
handlebars = "3.5.1"
heim = { version = "0.1.0-rc.1", features = ["process"] }
http = "0.2.1"
lazy_static = "1.4.0"
percent-encoding = "2.1.0"
@ -41,7 +40,6 @@ tracing = "0.1.25"
tracing-futures = "0.2.5"
tracing-subscriber = "0.2.16"
toml = "0.5.7"
uom = "0.30.0"
always_equal = { path = "../always_equal", version = "1.0.0" }
ptth_core = { path = "../ptth_core", version = "2.0.0" }

View File

@ -23,15 +23,6 @@ pub enum FileServerError {
#[error ("Invalid URI")]
InvalidUri (#[from] http::uri::InvalidUri),
#[error ("Heim process error")]
HeimProcess,
#[error(transparent)]
Other (#[from] anyhow::Error),
}
impl From <heim::process::ProcessError> for FileServerError {
fn from (_: heim::process::ProcessError) -> Self {
FileServerError::HeimProcess
}
}

View File

@ -1,14 +1,7 @@
use std::{
sync::Arc,
time::{Duration, Instant},
};
use arc_swap::ArcSwap;
use chrono::{DateTime, Utc};
use ptth_core::prelude::*;
use rusty_ulid::Ulid;
use tracing::{
debug, error, trace,
};
// Metrics are named for when they're updated:
// - Startup (Once, when the server state is initialized)
@ -41,10 +34,6 @@ pub struct Interval {
#[serde (skip)]
pub at: Instant,
pub utc: DateTime <Utc>,
pub rss_mib: u64,
#[serde (skip)]
pub cpu_usage: heim::process::CpuUsage,
}
pub struct Events {
@ -78,29 +67,9 @@ fn serialize_ulid <S: serde::Serializer> (t: &Ulid, s: S)
impl Interval {
pub async fn new () -> Result <Self, super::FileServerError> {
use tokio::join;
use heim::process;
use uom::si::{
information::mebibyte,
};
let our_process = process::current ().await?;
let cpu_usage = our_process.cpu_usage ();
let (cpu_usage, mem) = join! {
cpu_usage,
our_process.memory ()
};
let cpu_usage = cpu_usage?;
let mem = mem?;
let rss_mib = mem.rss ().get::<mebibyte> ();
let x = Self {
at: Instant::now (),
utc: Utc::now (),
rss_mib,
cpu_usage,
};
Ok (x)
@ -108,8 +77,6 @@ impl Interval {
pub async fn monitor (interval_writer: Arc <ArcSwap <Option <Interval>>>)
{
use uom::si::ratio::percent;
#[derive (Default)]
struct Window {
window_length: u64,
@ -132,15 +99,6 @@ impl Interval {
new_metrics: &Arc <Option <Interval>>
) {
if counter >= self.next_interval {
if let (Some (old), Some (new)) = (&*self.last_metrics, &**new_metrics) {
let diff = new.cpu_usage.clone () - old.cpu_usage.clone ();
trace! (
"CPU usage over {} s: {}%",
(new.at - old.at).as_secs (),
diff.get::<percent> (),
);
}
self.next_interval += self.window_length;
self.last_metrics = new_metrics.clone ();
}
@ -167,8 +125,6 @@ impl Interval {
Ok (x) => x,
};
trace! ("RSS: {} MiB", new_interval_metrics.rss_mib);
let new_interval_metrics = Arc::new (Some (new_interval_metrics));
for window in &mut windows {

View File

@ -349,8 +349,6 @@ impl State {
{
use std::convert::TryInto;
use arc_swap::ArcSwap;
let asset_root = asset_root.unwrap_or_else (PathBuf::new);
info! ("Server name is {}", config_file.name);