Skip to content

Commit

Permalink
Add load profile to logrotate FS (#1092)
Browse files Browse the repository at this point in the history
### What does this PR do?

We have a need for some experiments to ramp their load up over time.
Current configuration is constant over the lifetime of the experiment,
this change introduces linear growth in addition to constant.

A new release version will be required as this is a breaking change to
logrotate_fs configuration.

REF SMPTNG-517
  • Loading branch information
blt authored Nov 5, 2024
1 parent e0ed8d7 commit 8357826
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 70 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## Added
- Introduced load profile configuration for logrotate FS. This is a breaking
configuration change.

## [0.23.5]
### Fixed
- Target pid watcher will not report 0 for containers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# everyone who runs the test benefits from these saved cases.
cc 14b817f8f064c889dabecae41294027ede294a5e51f613ddba46d8bb352f47f5 # shrinks to seed = 18077722532471589563, state = State { nodes: {2: Directory { name: "BUndwQB7", dir: Directory { children: {3}, parent: Some(1) } }, 1: Directory { name: "/", dir: Directory { children: {2}, parent: None } }, 3: File { file: File { parent: 2, bytes_written: 0, bytes_read: 0, access_tick: 0, modified_tick: 0, status_tick: 0, bytes_per_tick: 72, read_only: false, peer: None, ordinal: 0, group_id: 0, open_handles: 0, unlinked: false } }}, root_inode: 1, now: 0, max_rotations: 8, max_bytes_per_file: 32273, group_names: [["77sYYEM2_0.log", "77sYYEM2_0.log.1", "77sYYEM2_0.log.2", "77sYYEM2_0.log.3", "77sYYEM2_0.log.4", "77sYYEM2_0.log.5", "77sYYEM2_0.log.6", "77sYYEM2_0.log.7", "77sYYEM2_0.log.8"]], next_inode: 4, .. }, operations = [GetAttr, Read { offset: 873, size: 578 }, GetAttr, Wait { ticks: 67 }, Close, Open, Close, GetAttr, GetAttr, Open, GetAttr, Wait { ticks: 76 }, Wait { ticks: 90 }, Open, Wait { ticks: 73 }, Wait { ticks: 94 }, Close, Lookup { name: Some("¥'?*:𐠸𝜒A£⳾6?𐢬_Ѩ%ౝ0?{`.𑌂dM") }, Wait { ticks: 63 }, Open, Open, Open, Lookup { name: Some(";0$Ѩ¥𐖘Ⱥ.${*_:gn`Ⱥ\u{113d8}*Z") }, Open, Read { offset: 596, size: 401 }, Read { offset: 314, size: 229 }, Read { offset: 876, size: 934 }, Read { offset: 899, size: 782 }, Read { offset: 871, size: 732 }, Wait { ticks: 3 }, Read { offset: 986, size: 52 }, Lookup { name: None }, Lookup { name: None }, Read { offset: 586, size: 180 }, Close, Open, Lookup { name: Some("𞹾&Ⱥ<") }, GetAttr, Read { offset: 499, size: 626 }, Lookup { name: Some("𑥗%@�^ೋ𝄓") }, Read { offset: 625, size: 519 }, Open, Read { offset: 26, size: 857 }, GetAttr, Read { offset: 530, size: 378 }, Read { offset: 95, size: 717 }, GetAttr, Close, Read { offset: 119, size: 956 }, Open, GetAttr, Read { offset: 760, size: 956 }, Close, Wait { ticks: 98 }, Wait { ticks: 12 }, Read { offset: 138, size: 227 }, Wait { ticks: 41 }, GetAttr]
cc 84a14bb361e5846589558e1fc52c5dee33d22e789034ef13c61f30ca4856d5da # shrinks to seed = 1512443422463708349, state = State { nodes: {1: Directory { name: "/", dir: Directory { children: {2}, parent: None } }, 2: Directory { name: "eKZTyj4p", dir: Directory { children: {3}, parent: Some(1) } }, 3: File { file: File { parent: 2, bytes_written: 0, bytes_read: 0, access_tick: 0, modified_tick: 0, status_tick: 0, bytes_per_tick: 4, read_only: false, peer: None, ordinal: 0, group_id: 0, open_handles: 0, unlinked: false } }}, root_inode: 1, now: 0, max_rotations: 2, max_bytes_per_file: 196227, group_names: [["F5Anm0dg_0.log", "F5Anm0dg_0.log.1", "F5Anm0dg_0.log.2"]], next_inode: 4, .. }, operations = [Wait { ticks: 40 }, Lookup { name: Some("𑌷C&𞺡\"?\"$<&%{$౿ோ") }, GetAttr, GetAttr, GetAttr, GetAttr, GetAttr, GetAttr, Wait { ticks: 17 }, Close, Read { offset: 225, size: 373 }, Wait { ticks: 34 }, Lookup { name: Some("ኻࠕN?¥<q*=%É\u{1d244}₹") }, Lookup { name: None }, Read { offset: 161, size: 111 }, Open, Lookup { name: None }, Wait { ticks: 24 }, Lookup { name: None }, Open, Lookup { name: Some("!*Ѩ𑼍ᛵﮩꬌῼ𞋿יּ:\"") }, Read { offset: 692, size: 769 }, Lookup { name: None }, Lookup { name: Some("𞅅.Ѩf$🉑{lⴧ\\\\?𞸻;સ./⋢ꚱÆᏽ`𐰃𖽻𐖇p𞋿h𝓂m{Z") }, Wait { ticks: 85 }, Open, Read { offset: 220, size: 438 }, Read { offset: 991, size: 393 }, Read { offset: 793, size: 379 }, Lookup { name: None }, GetAttr, Read { offset: 108, size: 606 }, Lookup { name: None }, Lookup { name: Some("𐖠\"n.[") }, Read { offset: 207, size: 867 }, Read { offset: 995, size: 862 }, GetAttr, Read { offset: 633, size: 542 }, Close, Close, Lookup { name: Some("Vպ۞.\"\"𐤈\\磌῞k`'𛲔\"�*|\\'{\u{b82}₻FᱤZP🕴.\\Ⱥ") }, GetAttr, GetAttr, Read { offset: 138, size: 921 }, Wait { ticks: 45 }]
cc a0f297919ada1079a80f8e7b2207fb5068dbe284c131b97ef3be4b371f2cd633 # shrinks to seed = 0, state = State { nodes: {1: Directory { name: "/", dir: Directory { children: {2}, parent: None } }, 2: Directory { name: "lfURbM5a", dir: Directory { children: {3}, parent: Some(1) } }, 3: File { file: File { parent: 2, bytes_written: 0, bytes_read: 0, created_tick: 1, access_tick: 1, modified_tick: 1, status_tick: 1, bytes_per_tick: 0, read_only: false, read_only_since: None, peer: None, ordinal: 0, group_id: 0, open_handles: 0, unlinked: false, max_offset_observed: 0 } }}, root_inode: 1, now: 1, max_rotations: 1, max_bytes_per_file: 1024, group_names: [["olvicJh4_0.log", "olvicJh4_0.log.1"]], next_inode: 4, .. }, operations = [Wait { ticks: 19 }, Wait { ticks: 60 }, Wait { ticks: 0 }, Wait { ticks: 0 }]
38 changes: 35 additions & 3 deletions lading/src/generator/file_gen/logrotate_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ pub struct Config {
max_depth: u8,
/// Sets the [`crate::payload::Config`] of this template.
variant: lading_payload::Config,
/// Defines the number of bytes that written in each log file.
bytes_per_second: byte_unit::Byte,
/// Defines the maximum internal cache of this log target. `file_gen` will
/// pre-build its outputs up to the byte capacity specified here.
maximum_prebuild_cache_size_bytes: byte_unit::Byte,
Expand All @@ -57,6 +55,39 @@ pub struct Config {
maximum_block_size: byte_unit::Byte,
/// The mount-point for this filesystem
mount_point: PathBuf,
/// The load profile, controlling bytes per second as a function of time.
load_profile: LoadProfile,
}

/// Profile for load in this filesystem.
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum LoadProfile {
/// Constant bytes per second
Constant(byte_unit::Byte),
/// Linear growth of bytes per second
Linear {
/// Starting point for bytes per second
initial_bytes_per_second: byte_unit::Byte,
/// Amount to increase per second
rate: byte_unit::Byte,
},
}

impl LoadProfile {
fn to_model(self) -> model::LoadProfile {
// For now, one tick is one second.
match self {
LoadProfile::Constant(bpt) => model::LoadProfile::Constant(bpt.get_bytes() as u64),
LoadProfile::Linear {
initial_bytes_per_second,
rate,
} => model::LoadProfile::Linear {
start: initial_bytes_per_second.get_bytes() as u64,
rate: rate.get_bytes() as u64,
},
}
}
}

#[derive(thiserror::Error, Debug)]
Expand Down Expand Up @@ -117,15 +148,16 @@ impl Server {

let start_time = std::time::Instant::now();
let start_time_system = std::time::SystemTime::now();

let state = model::State::new(
&mut rng,
start_time.elapsed().as_secs(),
config.bytes_per_second.get_bytes() as u64,
config.total_rotations,
config.maximum_bytes_per_log.get_bytes() as u64,
block_cache,
config.max_depth,
config.concurrent_logs,
config.load_profile.to_model(),
);

info!(
Expand Down
Loading

0 comments on commit 8357826

Please sign in to comment.