Skip to content

Commit

Permalink
Remove the unused file-per-thread-logger dependencies from `wasmtim…
Browse files Browse the repository at this point in the history
…e-cache` (#6910)
  • Loading branch information
sandhose authored Aug 25, 2023
1 parent 968d3a9 commit 1d4766f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ anyhow = { workspace = true }
base64 = "0.21.0"
bincode = "1.1.4"
directories-next = "2.0"
file-per-thread-logger = { workspace = true }
log = { workspace = true }
serde = { version = "1.0.94", features = ["derive"] }
sha2 = "0.10.2"
Expand Down
2 changes: 1 addition & 1 deletion crates/cache/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl CacheConfig {

fn spawn_worker(&mut self) {
if self.enabled {
self.worker = Some(Worker::start_new(self, None));
self.worker = Some(Worker::start_new(self));
}
}

Expand Down
13 changes: 3 additions & 10 deletions crates/cache/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ enum CacheEvent {
}

impl Worker {
pub(super) fn start_new(
cache_config: &CacheConfig,
init_file_per_thread_logger: Option<&'static str>,
) -> Self {
pub(super) fn start_new(cache_config: &CacheConfig) -> Self {
let queue_size = match cache_config.worker_event_queue_size() {
num if num <= usize::max_value() as u64 => num as usize,
_ => usize::max_value(),
Expand All @@ -76,7 +73,7 @@ impl Worker {
// when self is dropped, sender will be dropped, what will cause the channel
// to hang, and the worker thread to exit -- it happens in the tests
// non-tests binary has only a static worker, so Rust doesn't drop it
thread::spawn(move || worker_thread.run(init_file_per_thread_logger));
thread::spawn(move || worker_thread.run());

Self {
sender: tx,
Expand Down Expand Up @@ -192,11 +189,7 @@ macro_rules! unwrap_or_warn {
}

impl WorkerThread {
fn run(self, init_file_per_thread_logger: Option<&'static str>) {
if let Some(prefix) = init_file_per_thread_logger {
file_per_thread_logger::initialize(prefix);
}

fn run(self) {
debug!("Cache worker thread started.");

Self::lower_thread_priority();
Expand Down
20 changes: 10 additions & 10 deletions crates/cache/src/worker/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn test_on_get_create_stats_file() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);

let mod_file = cache_dir.join("some-mod");
worker.on_cache_get_async(mod_file);
Expand Down Expand Up @@ -47,7 +47,7 @@ fn test_on_get_update_usage_counter() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);

let mod_file = cache_dir.join("some-mod");
let stats_file = cache_dir.join("some-mod.stats");
Expand Down Expand Up @@ -84,7 +84,7 @@ fn test_on_get_recompress_no_mod_file() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);

let mod_file = cache_dir.join("some-mod");
let stats_file = cache_dir.join("some-mod.stats");
Expand Down Expand Up @@ -126,7 +126,7 @@ fn test_on_get_recompress_with_mod_file() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);

let mod_file = cache_dir.join("some-mod");
let mod_data = "some test data to be compressed";
Expand Down Expand Up @@ -203,7 +203,7 @@ fn test_on_get_recompress_lock() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);

let mod_file = cache_dir.join("some-mod");
let mod_data = "some test data to be compressed";
Expand Down Expand Up @@ -271,7 +271,7 @@ fn test_on_update_fresh_stats_file() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);

let mod_file = cache_dir.join("some-mod");
let stats_file = cache_dir.join("some-mod.stats");
Expand Down Expand Up @@ -325,7 +325,7 @@ fn test_on_update_cleanup_limits_trash_locks() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);
let content_1k = "a".repeat(1_000);
let content_10k = "a".repeat(10_000);

Expand Down Expand Up @@ -462,7 +462,7 @@ fn test_on_update_cleanup_lru_policy() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);
let content_1k = "a".repeat(1_000);
let content_5k = "a".repeat(5_000);
let content_10k = "a".repeat(10_000);
Expand Down Expand Up @@ -595,7 +595,7 @@ fn test_on_update_cleanup_future_files() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);
let content_1k = "a".repeat(1_000);

let mods_files_dir = cache_dir.join("target-triple").join("compiler-version");
Expand Down Expand Up @@ -700,7 +700,7 @@ fn test_on_update_cleanup_self_lock() {
cache_dir
);
assert!(cache_config.enabled());
let worker = Worker::start_new(&cache_config, None);
let worker = Worker::start_new(&cache_config);

let mod_file = cache_dir.join("some-mod");
let trash_file = cache_dir.join("trash-file.txt");
Expand Down

0 comments on commit 1d4766f

Please sign in to comment.