Skip to content

Commit

Permalink
Fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
s0me0ne-unkn0wn committed Aug 30, 2023
1 parent 47ecf58 commit 58330de
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion polkadot/node/core/pvf/prepare-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rayon = "1.5.1"
tikv-jemalloc-ctl = { version = "0.5.0", optional = true }
tokio = { version = "1.24.2", features = ["fs", "process"] }
tracking-allocator = { path = "../../../tracking-allocator", optional = true }
tikv-jemallocator = { version = "0.5.0", optional = true }

parity-scale-codec = { version = "3.6.1", default-features = false, features = ["derive"] }

Expand All @@ -34,7 +35,7 @@ tikv-jemalloc-ctl = "0.5.0"
[features]
builder = []
jemalloc-allocator = ["dep:tikv-jemalloc-ctl"]
tracking-allocator = ["dep:tracking-allocator"]
tracking-allocator = ["dep:tracking-allocator", "dep:tikv-jemallocator"]

[dev-dependencies]
criterion = { version = "0.4.0", default-features = false, features = ["cargo_bench_support"] }
Expand Down
8 changes: 7 additions & 1 deletion polkadot/node/core/pvf/prepare-worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ use std::{
time::Duration,
};
use tokio::{io, net::UnixStream};

#[cfg(feature = "tracking-allocator")]
use tikv_jemallocator::Jemalloc;
#[cfg(feature = "tracking-allocator")]
use tracking_allocator::TrackingAllocator;
#[cfg(feature = "tracking-allocator")]
use tracking_allocator::ALLOC;
#[global_allocator]
static ALLOC: TrackingAllocator<Jemalloc> = TrackingAllocator(Jemalloc);

/// Contains the bytes for a successfully compiled artifact.
pub struct CompiledArtifact(Vec<u8>);
Expand Down
3 changes: 0 additions & 3 deletions polkadot/node/tracking-allocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ description = "Tracking allocator to control amount of memory consumed by PVF pr
version.workspace = true
authors.workspace = true
edition.workspace = true

[dependencies]
tikv-jemallocator = "0.5.0"
6 changes: 1 addition & 5 deletions polkadot/node/tracking-allocator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use core::alloc::{GlobalAlloc, Layout};
use std::sync::atomic::{AtomicBool, Ordering};
use tikv_jemallocator::Jemalloc;

struct TrackingAllocatorData {
lock: AtomicBool,
Expand Down Expand Up @@ -82,7 +81,7 @@ impl TrackingAllocatorData {
static mut ALLOCATOR_DATA: TrackingAllocatorData =
TrackingAllocatorData { lock: AtomicBool::new(false), current: 0, peak: 0 };

pub struct TrackingAllocator<A: GlobalAlloc>(A);
pub struct TrackingAllocator<A: GlobalAlloc>(pub A);

impl<A: GlobalAlloc> TrackingAllocator<A> {
// SAFETY:
Expand Down Expand Up @@ -131,6 +130,3 @@ unsafe impl<A: GlobalAlloc> GlobalAlloc for TrackingAllocator<A> {
self.0.realloc(ptr, layout, new_size)
}
}

#[global_allocator]
pub static ALLOC: TrackingAllocator<Jemalloc> = TrackingAllocator(Jemalloc);

0 comments on commit 58330de

Please sign in to comment.