mirror of
https://github.com/Zenithsiz/ftmemsim.git
synced 2026-02-04 02:08:39 +00:00
Added page-temperature histogram.
Added page accesses data.
This commit is contained in:
parent
7eeffde12a
commit
e41b3ae395
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -6,6 +6,7 @@
|
||||
"ftmemsim",
|
||||
"hemem",
|
||||
"itertools",
|
||||
"linejoin",
|
||||
"minmax",
|
||||
"optane",
|
||||
"pico",
|
||||
|
||||
@ -24,6 +24,7 @@ pub struct Args {
|
||||
}
|
||||
|
||||
/// Sub-command
|
||||
#[expect(clippy::enum_variant_names)] // It's a coincidence, we'll add more varied names
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
pub enum SubCmd {
|
||||
/// Creates a graph for page locations
|
||||
@ -75,4 +76,17 @@ pub enum SubCmd {
|
||||
#[clap(short = 'o', long = "output")]
|
||||
output_file: PathBuf,
|
||||
},
|
||||
|
||||
/// Page temperature
|
||||
///
|
||||
/// Uses the `page_accesses.yaml` data
|
||||
#[clap(name = "page-temperature")]
|
||||
PageTemperature {
|
||||
/// Input
|
||||
input_file: PathBuf,
|
||||
|
||||
/// Output
|
||||
#[clap(short = 'o', long = "output")]
|
||||
output_file: PathBuf,
|
||||
},
|
||||
}
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
//! Creates graphs from `ftmemsim`'s output
|
||||
|
||||
// Features
|
||||
#![feature(lint_reasons)]
|
||||
|
||||
use plotlib::style::{LineJoin, LineStyle};
|
||||
|
||||
// Modules
|
||||
mod args;
|
||||
|
||||
@ -125,19 +130,67 @@ fn main() -> Result<(), anyhow::Error> {
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Finally build the histogram and render it
|
||||
let hist = Histogram::from_slice(&data, HistogramBins::Count(max_migrations - 1))
|
||||
let hist = Histogram::from_slice(&data, HistogramBins::Count(20.min(max_migrations) - 1))
|
||||
.style(&BoxStyle::new().fill("burlywood"));
|
||||
|
||||
let x_scale = 5;
|
||||
let view = ContinuousView::new()
|
||||
.add(hist)
|
||||
.x_max_ticks((max_migrations + 1).min(20 * (x_scale as usize)))
|
||||
.x_max_ticks(20.min(max_migrations))
|
||||
.y_max_ticks(6)
|
||||
.x_label("Migrations")
|
||||
.y_label("Occurrences");
|
||||
|
||||
Page::single(&view)
|
||||
.dimensions(640 * x_scale, 480)
|
||||
.dimensions(640, 480)
|
||||
.save(output_file)
|
||||
.map_err(|err| anyhow::anyhow!("Unable to save output file: {err:?}"))?;
|
||||
},
|
||||
args::SubCmd::PageTemperature {
|
||||
input_file,
|
||||
output_file,
|
||||
} => {
|
||||
// Parse the page accesses
|
||||
let page_accesses = {
|
||||
let page_accesses_file = std::fs::File::open(input_file).context("Unable to open input file")?;
|
||||
serde_json::from_reader::<_, ftmemsim_util::PageAccesses>(page_accesses_file)
|
||||
.context("Unable to parse input file")?
|
||||
};
|
||||
|
||||
let (min_time, max_time) = page_accesses
|
||||
.accesses
|
||||
.iter()
|
||||
.map(|page_access| page_access.time)
|
||||
.minmax()
|
||||
.into_option()
|
||||
.unwrap_or((0, 1));
|
||||
|
||||
let mut temp_cur_average = 0.0;
|
||||
let temp_points = page_accesses
|
||||
.accesses
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(idx, page_access)| {
|
||||
temp_cur_average += page_access.cur_temp as f64;
|
||||
(
|
||||
(page_access.time - min_time) as f64 / (max_time - min_time) as f64,
|
||||
temp_cur_average / (idx as f64 + 1.0),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Finally build the plot and render it
|
||||
let temp_plot = Plot::new(temp_points)
|
||||
.line_style(LineStyle::new().width(1.0).colour("#000000").linejoin(LineJoin::Round));
|
||||
|
||||
let view = ContinuousView::new()
|
||||
.add(temp_plot)
|
||||
.x_max_ticks(6)
|
||||
.y_max_ticks(6)
|
||||
.x_label("Time")
|
||||
.y_label("Temperature");
|
||||
|
||||
Page::single(&view)
|
||||
.dimensions(640, 480)
|
||||
.save(output_file)
|
||||
.map_err(|err| anyhow::anyhow!("Unable to save output file: {err:?}"))?;
|
||||
},
|
||||
|
||||
@ -9,8 +9,35 @@ pub mod logger;
|
||||
// Imports
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Page accesses
|
||||
#[derive(Debug)]
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct PageAccesses {
|
||||
pub accesses: Vec<PageAccess>,
|
||||
}
|
||||
|
||||
/// Serialized page location
|
||||
/// Page access
|
||||
#[derive(Debug)]
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct PageAccess {
|
||||
pub page_ptr: u64,
|
||||
pub time: u64,
|
||||
pub mem_idx: usize,
|
||||
pub faulted: bool,
|
||||
pub kind: PageAccessKind,
|
||||
pub prev_temp: usize,
|
||||
pub cur_temp: usize,
|
||||
}
|
||||
|
||||
/// Page access kind
|
||||
#[derive(Debug)]
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub enum PageAccessKind {
|
||||
Read,
|
||||
Write,
|
||||
}
|
||||
|
||||
/// Page locations
|
||||
#[derive(Debug)]
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct PageLocations {
|
||||
|
||||
@ -203,6 +203,32 @@ impl HeMem {
|
||||
.context("Unable to migrate page to faster memory")
|
||||
}
|
||||
|
||||
/// Returns the page accesses so far
|
||||
pub fn page_accesses(&self) -> ftmemsim_util::PageAccesses {
|
||||
ftmemsim_util::PageAccesses {
|
||||
accesses: self
|
||||
.statistics
|
||||
.accesses()
|
||||
.iter()
|
||||
.map(|page_access| ftmemsim_util::PageAccess {
|
||||
page_ptr: page_access.page_ptr.to_u64(),
|
||||
time: page_access.time,
|
||||
mem_idx: match page_access.mem {
|
||||
statistics::AccessMem::Mapped(mem_idx) | statistics::AccessMem::Resided(mem_idx) =>
|
||||
mem_idx.to_usize(),
|
||||
},
|
||||
faulted: matches!(page_access.mem, statistics::AccessMem::Mapped(_)),
|
||||
kind: match page_access.kind {
|
||||
statistics::AccessKind::Read => ftmemsim_util::PageAccessKind::Read,
|
||||
statistics::AccessKind::Write => ftmemsim_util::PageAccessKind::Write,
|
||||
},
|
||||
prev_temp: page_access.prev_temperature,
|
||||
cur_temp: page_access.cur_temperature,
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the page locations so far
|
||||
pub fn page_locations(&self) -> ftmemsim_util::PageLocations {
|
||||
ftmemsim_util::PageLocations {
|
||||
|
||||
@ -58,11 +58,21 @@ fn main() -> Result<(), anyhow::Error> {
|
||||
sim.run(&mut pin_trace_reader, &mut hemem)
|
||||
.context("Unable to run simulator")?;
|
||||
|
||||
// TODO: Make location configurable
|
||||
let page_locations_file =
|
||||
fs::File::create("resources/data/page_locations.json").context("Unable to create page locations file")?;
|
||||
let page_locations = hemem.page_locations();
|
||||
serde_json::to_writer(page_locations_file, &page_locations).context("Unable to write to page locations file")?;
|
||||
// TODO: Make locations configurable
|
||||
{
|
||||
let page_locations_file =
|
||||
fs::File::create("resources/data/page_locations.json").context("Unable to create page locations file")?;
|
||||
let page_locations = hemem.page_locations();
|
||||
serde_json::to_writer(page_locations_file, &page_locations)
|
||||
.context("Unable to write to page locations file")?;
|
||||
}
|
||||
|
||||
{
|
||||
let page_accesses_file =
|
||||
fs::File::create("resources/data/page_accesses.json").context("Unable to create page accesses file")?;
|
||||
let page_accesses = hemem.page_accesses();
|
||||
serde_json::to_writer(page_accesses_file, &page_accesses).context("Unable to write to page accesses file")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
12
run.sh
12
run.sh
@ -5,6 +5,9 @@ set -e
|
||||
RUST_FILE_LOG="trace,ftmemsim::classifiers::hemem=debug"
|
||||
LOG_FILE="latest.log"
|
||||
|
||||
PROFILE="dev"
|
||||
#PROFILE="release"
|
||||
|
||||
#TRACE_FILE="resources/traces/bfs.g5.n5.trace"
|
||||
TRACE_FILE="resources/traces/bfs.g17.n100.t1.trace"
|
||||
#TRACE_FILE="resources/traces/bc.g18.n100.t1.trace"
|
||||
@ -12,12 +15,15 @@ TRACE_FILE="resources/traces/bfs.g17.n100.t1.trace"
|
||||
rm -rf "$LOG_FILE"
|
||||
|
||||
echo "Simulating"
|
||||
cargo run --release -p ftmemsim -- --log-file-append --log-file "$LOG_FILE" \
|
||||
cargo run --profile "$PROFILE" -p ftmemsim -- --log-file-append --log-file "$LOG_FILE" \
|
||||
"$TRACE_FILE"
|
||||
|
||||
echo "Creating graphs"
|
||||
cargo run --release -p ftmemsim-graphs -- --log-file-append --log-file "$LOG_FILE" \
|
||||
cargo run --profile "$PROFILE" -p ftmemsim-graphs -- --log-file-append --log-file "$LOG_FILE" \
|
||||
page-locations "resources/data/page_locations.json" --output "resources/data/page_locations.svg"
|
||||
|
||||
cargo run --release -p ftmemsim-graphs -- --log-file-append --log-file "$LOG_FILE" \
|
||||
cargo run --profile "$PROFILE" -p ftmemsim-graphs -- --log-file-append --log-file "$LOG_FILE" \
|
||||
page-migrations "resources/data/page_locations.json" --output "resources/data/page_migrations.svg"
|
||||
|
||||
cargo run --profile "$PROFILE" -p ftmemsim-graphs -- --log-file-append --log-file "$LOG_FILE" \
|
||||
page-temperature "resources/data/page_accesses.json" --output "resources/data/page_temperature.svg"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user