Skip to content

Commit 70556c3

Browse files
committed
Enhance project configuration by adding .idea directory to .gitignore, streamline release workflow by removing unnecessary whitespace, and improve code readability by simplifying print statements in CLI commands. Adjust metrics implementation for clarity and consistency.
1 parent 59cd349 commit 70556c3

6 files changed

Lines changed: 26 additions & 31 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ jobs:
8080
cargo publish --package tracekit
8181
echo "Waiting for crates.io to index tracekit..."
8282
sleep 30
83-
83+
8484
cargo publish --package tracekit-formats
8585
cargo publish --package tracekit-cachekit
8686
echo "Waiting for crates.io to index dependencies..."
8787
sleep 30
88-
88+
8989
cargo publish --package tracekit-cli

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ target
1616
# Covers JetBrains IDEs: IntelliJ, GoLand, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
1717
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
1818

19+
# Ignore entire .idea directory
20+
.idea/
21+
1922
# User-specific stuff
2023
.idea/**/workspace.xml
2124
.idea/**/vcs.xml

tracekit-cli/src/cmd_simulate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn run(args: SimulateArgs) -> Result<(), Box<dyn std::error::Error>> {
3232
use std::collections::HashMap;
3333
use std::fs::File;
3434
use std::io::BufReader;
35-
use tracekit::{simulate, CacheModel};
35+
use tracekit::{CacheModel, simulate};
3636
use tracekit_formats::KeyOnlyReader;
3737

3838
// Simple LRU implementation for demonstration

tracekit-cli/src/cmd_tracegen.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,7 @@ pub fn run(args: TracegenArgs) -> Result<(), Box<dyn std::error::Error>> {
114114
}
115115

116116
if let Some(path) = &args.output {
117-
eprintln!(
118-
"Generated {} events to {}",
119-
args.count,
120-
path.display()
121-
);
117+
eprintln!("Generated {} events to {}", args.count, path.display());
122118
}
123119

124120
Ok(())

tracekit/src/metrics.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl LatencySampler {
188188
#[inline]
189189
pub fn record(&mut self, duration: Duration) {
190190
self.count += 1;
191-
if !self.count.is_multiple_of(self.sample_rate) {
191+
if self.count % self.sample_rate != 0 {
192192
return;
193193
}
194194

@@ -254,7 +254,6 @@ impl Default for BenchmarkConfig {
254254
}
255255
}
256256

257-
258257
// ============================================================================
259258
// Specialized Benchmarks
260259
// ============================================================================
@@ -263,7 +262,6 @@ impl Default for BenchmarkConfig {
263262
///
264263
/// Returns (baseline_hit_rate, scan_hit_rate, recovery_hit_rate).
265264
/// A scan-resistant policy should have recovery_hit_rate close to baseline_hit_rate.
266-
267265
/// Results from scan resistance measurement.
268266
#[derive(Debug, Clone, Copy)]
269267
pub struct ScanResistanceResult {
@@ -289,8 +287,6 @@ impl ScanResistanceResult {
289287
}
290288
}
291289

292-
293-
294290
/// Results from adaptation speed measurement.
295291
#[derive(Debug, Clone)]
296292
pub struct AdaptationResult {

tracekit/src/workload.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,19 @@ impl WorkloadGenerator {
155155
let bursty_zipfian = match workload {
156156
Workload::Bursty { base_exponent, .. } => {
157157
Some(Zipf::new(universe as f64, base_exponent).unwrap())
158-
},
158+
}
159159
_ => None,
160160
};
161161
let flash_zipfian = match workload {
162162
Workload::FlashCrowd { base_exponent, .. } => {
163163
Some(Zipf::new(universe as f64, base_exponent).unwrap())
164-
},
164+
}
165165
_ => None,
166166
};
167167
let scan_resistance_zipfian = match workload {
168168
Workload::ScanResistance { point_exponent, .. } => {
169169
Some(Zipf::new(universe as f64, point_exponent).unwrap())
170-
},
170+
}
171171
_ => None,
172172
};
173173
Self {
@@ -223,35 +223,35 @@ impl WorkloadGenerator {
223223
} else {
224224
hot_size + (self.rng.random::<u64>() % (self.universe - hot_size))
225225
}
226-
},
226+
}
227227

228228
Workload::Scan => {
229229
let key = self.scan_pos;
230230
self.scan_pos = (self.scan_pos + 1) % self.universe;
231231
key
232-
},
232+
}
233233

234234
Workload::Zipfian { .. } => {
235235
let zipf = self.zipfian.as_ref().unwrap();
236236
let sample: f64 = zipf.sample(&mut self.rng);
237237
(sample as u64).saturating_sub(1).min(self.universe - 1)
238-
},
238+
}
239239

240240
Workload::ScrambledZipfian { .. } => {
241241
let zipf = self.zipfian.as_ref().unwrap();
242242
let sample: f64 = zipf.sample(&mut self.rng);
243243
let key = (sample as u64).saturating_sub(1).min(self.universe - 1);
244244
// FNV-1a hash to scramble the key
245245
fnv_hash(key) % self.universe
246-
},
246+
}
247247

248248
Workload::Latest { .. } => {
249249
let zipf = self.zipfian.as_ref().unwrap();
250250
let sample: f64 = zipf.sample(&mut self.rng);
251251
let offset = (sample as u64).saturating_sub(1).min(self.universe - 1);
252252
// Access keys near the most recent insert, wrapping around
253253
self.insert_counter.wrapping_sub(offset) % self.universe
254-
},
254+
}
255255

256256
Workload::ShiftingHotspot {
257257
shift_interval,
@@ -271,23 +271,23 @@ impl WorkloadGenerator {
271271
} else {
272272
self.rng.random::<u64>() % self.universe
273273
}
274-
},
274+
}
275275

276276
Workload::Exponential { .. } => {
277277
let exp = self.exponential.as_ref().unwrap();
278278
let sample: f64 = exp.sample(&mut self.rng);
279279
// Map exponential sample to key space, favoring lower keys
280280
let key = (sample * (self.universe as f64 / 10.0)) as u64;
281281
key.min(self.universe - 1)
282-
},
282+
}
283283

284284
Workload::Pareto { .. } => {
285285
let pareto = self.pareto.as_ref().unwrap();
286286
let sample: f64 = pareto.sample(&mut self.rng);
287287
// Pareto samples start at scale (1.0), map to key space
288288
let key = ((sample - 1.0) * (self.universe as f64 / 10.0)) as u64;
289289
key.min(self.universe - 1)
290-
},
290+
}
291291

292292
Workload::ScanResistance {
293293
scan_fraction,
@@ -315,7 +315,7 @@ impl WorkloadGenerator {
315315
let sample: f64 = zipf.sample(&mut self.rng);
316316
(sample as u64).saturating_sub(1).min(self.universe - 1)
317317
}
318-
},
318+
}
319319

320320
Workload::Correlated {
321321
stride,
@@ -337,13 +337,13 @@ impl WorkloadGenerator {
337337
// Random access
338338
self.rng.random::<u64>() % self.universe
339339
}
340-
},
340+
}
341341

342342
Workload::Loop { working_set_size } => {
343343
let key = self.loop_pos % working_set_size.max(1);
344344
self.loop_pos = self.loop_pos.wrapping_add(1);
345345
key
346-
},
346+
}
347347

348348
Workload::WorkingSetChurn {
349349
working_set_size,
@@ -358,7 +358,7 @@ impl WorkloadGenerator {
358358
// Access within current working set
359359
let offset = self.rng.random::<u64>() % working_set_size;
360360
(self.working_set_base + offset) % self.universe
361-
},
361+
}
362362

363363
Workload::Bursty { hurst, .. } => {
364364
// Simplified bursty model using Hurst parameter to control burst probability
@@ -384,7 +384,7 @@ impl WorkloadGenerator {
384384
} else {
385385
key
386386
}
387-
},
387+
}
388388

389389
Workload::FlashCrowd {
390390
flash_prob,
@@ -422,7 +422,7 @@ impl WorkloadGenerator {
422422
let sample: f64 = zipf.sample(&mut self.rng);
423423
(sample as u64).saturating_sub(1).min(self.universe - 1)
424424
}
425-
},
425+
}
426426

427427
Workload::Mixture => {
428428
// Default mixture: 70% Zipfian, 20% Scan-like, 10% Uniform
@@ -441,7 +441,7 @@ impl WorkloadGenerator {
441441
// Uniform random
442442
self.rng.random::<u64>() % self.universe
443443
}
444-
},
444+
}
445445
}
446446
}
447447
}

0 commit comments

Comments
 (0)