Add dhat and rayon
- Set up dhat, when dhat-heap feature, the dhap memory profiler will run. Due to this tokio needs to be manually built. - Rayon now explicitly built outside of tokio runtime.
This commit is contained in:
parent
5075c97faa
commit
ade661d5b8
84
Cargo.lock
generated
84
Cargo.lock
generated
@ -287,6 +287,22 @@ dependencies = [
|
||||
"powerfmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dhat"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98cd11d84628e233de0ce467de10b8633f4ddaecafadefc86e13b84b8739b827"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"lazy_static",
|
||||
"mintex",
|
||||
"parking_lot",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thousands",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
@ -785,6 +801,16 @@ version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
@ -829,6 +855,12 @@ dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mintex"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bec4598fddb13cc7b528819e697852653252b760f1228b7642679bf2ff2cd07"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.1"
|
||||
@ -1011,6 +1043,29 @@ dependencies = [
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pem-rfc7468"
|
||||
version = "0.7.0"
|
||||
@ -1129,6 +1184,7 @@ dependencies = [
|
||||
"base64",
|
||||
"bytes",
|
||||
"crossbeam-channel",
|
||||
"dhat",
|
||||
"digest 0.11.0-pre.9",
|
||||
"image",
|
||||
"log",
|
||||
@ -1143,6 +1199,7 @@ dependencies = [
|
||||
"pumpkin-text",
|
||||
"pumpkin-world",
|
||||
"rand",
|
||||
"rayon",
|
||||
"reqwest",
|
||||
"rsa",
|
||||
"rsa-der",
|
||||
@ -1300,6 +1357,15 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.12.5"
|
||||
@ -1393,6 +1459,12 @@ version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.34"
|
||||
@ -1461,6 +1533,12 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "2.11.1"
|
||||
@ -1721,6 +1799,12 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thousands"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820"
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.36"
|
||||
|
||||
@ -7,9 +7,10 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[profile.release]
|
||||
strip = true
|
||||
debug = 1
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
|
||||
[workspace.dependencies]
|
||||
tokio = { version = "1.39.2", features = ["net", "macros", "rt-multi-thread", "fs", "io-util"] }
|
||||
rayon = "1.10.0"
|
||||
|
||||
@ -4,7 +4,15 @@ version = "0.1.0-dev"
|
||||
description = "Empowering everyone to host fast and efficient Minecraft servers."
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
dhat-heap = ["dhat"]
|
||||
|
||||
[dependencies]
|
||||
# memory analysis
|
||||
dhat = { version = "0.3.3", optional = true }
|
||||
|
||||
# pumpkin
|
||||
pumpkin-text = { path = "../pumpkin-text" }
|
||||
pumpkin-inventory = { path = "../pumpkin-inventory"}
|
||||
pumpkin-world = { path = "../pumpkin-world"}
|
||||
@ -52,3 +60,4 @@ crossbeam-channel = "0.5.13"
|
||||
uuid = { version = "1.10", features = ["serde", "v3"]}
|
||||
|
||||
tokio.workspace = true
|
||||
rayon.workspace = true
|
||||
|
||||
@ -22,9 +22,23 @@ pub mod rcon;
|
||||
pub mod server;
|
||||
pub mod util;
|
||||
|
||||
#[cfg(feature = "dhat-heap")]
|
||||
#[global_allocator]
|
||||
static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||
|
||||
#[cfg(not(target_os = "wasi"))]
|
||||
#[tokio::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
fn main() -> io::Result<()> {
|
||||
#[cfg(feature = "dhat-heap")]
|
||||
let _profiler = dhat::Profiler::new_heap();
|
||||
#[cfg(feature = "dhat-heap")]
|
||||
println!("Using a memory profiler");
|
||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
// ensure rayon is built outside of tokio scope
|
||||
rayon::ThreadPoolBuilder::new().build_global().unwrap();
|
||||
rt.block_on(async {
|
||||
const SERVER: Token = Token(0);
|
||||
use std::{cell::RefCell, time::Instant};
|
||||
|
||||
@ -157,6 +171,7 @@ async fn main() -> io::Result<()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn next(current: &mut Token) -> Token {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user