Skip to content

Commit

Permalink
rename performance_profiling to profilin
Browse files Browse the repository at this point in the history
change naming and api of loggin
adjust equil-config.yml
  • Loading branch information
janekdererste committed Dec 13, 2023
1 parent 96aeaa5 commit 032d974
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 37 deletions.
13 changes: 4 additions & 9 deletions assets/equil/config.yaml → assets/equil/equil-config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
modules:
xmlfiles:
type: XmlFiles
network: ./assets/equil/equil-network.xml
population: ./assets/equil/equil-plans.xml.gz
vehicles: ./assets/equil/equil-vehicles.xml
protfiles:
protofiles:
type: ProtoFiles
network: ./assets/equil/equil-network.binpb
population: ./assets/equil/equil-population.binpb
population: ./assets/equil/equil-plans.binpb
vehicles: ./assets/equil/equil-vehicles.binpb
ids: ./assets/equil/equil-ids.binpb
ids: ./assets/equil/ids.binpb
partitioning:
type: Partitioning
num_parts: 2
method: Metis
output:
type: Output
output_dir: ./output
output_dir: /Users/janek/Documents/equil-output/output
routing:
type: Routing
mode: UsePlans
Expand Down
4 changes: 2 additions & 2 deletions src/bin/merge_xml_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::Parser;
use tracing::info;

use rust_q_sim::simulation::io::xml_events::{XmlEventsReader, XmlEventsWriter};
use rust_q_sim::simulation::logging;
use rust_q_sim::simulation::logging::init_std_out_logging;
use rust_q_sim::simulation::messaging::events::EventsPublisher;
use rust_q_sim::simulation::wire_types::events::Event;

Expand All @@ -22,8 +22,8 @@ struct InputArgs {
}

fn main() {
init_std_out_logging();
let args = InputArgs::parse();
let _guards = logging::init_logging("./", "".to_string());
let mut readers = Vec::new();

for i in 0..args.num_parts {
Expand Down
23 changes: 10 additions & 13 deletions src/simulation/controller.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::ops::Sub;
use std::path::{Path, PathBuf};
use std::rc::Rc;
use std::thread::{sleep, JoinHandle};
use std::time::{Duration, Instant};
use std::time::Duration;
use std::{fs, thread};

use clap::Parser;
Expand All @@ -25,15 +24,15 @@ use crate::simulation::replanning::replanner::{DummyReplanner, ReRouteTripReplan
use crate::simulation::replanning::routing::travel_time_collector::TravelTimeCollector;
use crate::simulation::simulation::Simulation;
use crate::simulation::vehicles::garage::Garage;
use crate::simulation::{id, logging};
use crate::simulation::{id, logging, profiling};

pub fn run_channel() {
let args = CommandLineArgs::parse();
let config = Config::from_file(&args);

let _guards = logging::init_logging(
config.output().output_dir.as_ref(),
config.partitioning().num_parts.to_string(),
config.partitioning().num_parts.to_string().as_str(),
);

info!(
Expand Down Expand Up @@ -66,8 +65,10 @@ pub fn run_mpi() {
let args = CommandLineArgs::parse();
let config = Config::from_file(&args);

let _guards =
logging::init_logging(config.output().output_dir.as_ref(), comm.rank().to_string());
let _guards = logging::init_logging(
config.output().output_dir.as_ref(),
comm.rank().to_string().as_str(),
);

info!(
"Starting MPI Simulation with {} partitions",
Expand Down Expand Up @@ -160,13 +161,9 @@ fn execute_partition<C: SimCommunicator + 'static>(comm: C, args: &CommandLineAr
replanner,
);

let start = Instant::now();
simulation.run(start_time, end_time);
let end = Instant::now();
let duration = end.sub(start).as_millis() / 1000;
info!("#{rank} took: {duration}s");

//info!("output dir: {:?}", config.output_dir);
profiling::measure_duration(None, "Overall Execution Time", None, || {
simulation.run(start_time, end_time)
});
}

/// Have this more complicated join logic, so that threads in the back of the handle vec can also
Expand Down
1 change: 1 addition & 0 deletions src/simulation/id/id_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::simulation::wire_types::ids::ids_with_type::Data;
use crate::simulation::wire_types::ids::IdsWithType;

#[derive(Clone, Copy)]
#[allow(dead_code)] // allow dead code, because we never construct None. I still want to have it as option here.
enum IdCompression {
LZ4,
None,
Expand Down
21 changes: 9 additions & 12 deletions src/simulation/logging.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::io;
use std::path::Path;

use tracing::level_filters::LevelFilter;
use tracing::Level;
Expand All @@ -18,18 +19,15 @@ pub fn init_std_out_logging() {
tracing::subscriber::set_global_default(collector).expect("Unable to set a global collector");
}

pub fn init_logging(directory: &str, file_discriminant: String) -> (WorkerGuard, WorkerGuard) {
let mut file_name = String::from("mpi_qsim_");
file_name.push_str(file_discriminant.as_str());

let log_file_appender = rolling::never(directory, &file_name);
pub fn init_logging(dir: &Path, file_discriminant: &str) -> (WorkerGuard, WorkerGuard) {
let log_file_name = format!("log_process_{file_discriminant}.txt");
let log_file_appender = rolling::never(dir, &log_file_name);
let (log_file, _guard_log) = non_blocking(log_file_appender);

let mut performance_directory = String::from(directory);
performance_directory.push_str("/trace");

let performance_file_appender = rolling::never(performance_directory, &file_name);
let (performance_file, _guard_performance) = non_blocking(performance_file_appender);
let trace_dir = dir.join("trace");
let trace_file_name = format!("trace_process_{file_discriminant}.txt");
let trace_file_appender = rolling::never(&trace_dir, &trace_file_name);
let (trace_file, _guard_performance) = non_blocking(trace_file_appender);

let collector = tracing_subscriber::registry()
.with(
Expand All @@ -46,10 +44,9 @@ pub fn init_logging(directory: &str, file_discriminant: String) -> (WorkerGuard,
)
.with(
fmt::Layer::new()
.with_writer(performance_file.with_min_level(Level::TRACE))
.with_writer(trace_file.with_min_level(Level::TRACE))
.json(),
);
// do we need this? at least for test cases this is not usefull
tracing::subscriber::set_global_default(collector).expect("Unable to set a global collector");
(_guard_log, _guard_performance)
}
2 changes: 1 addition & 1 deletion src/simulation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub mod io;
pub mod logging;
pub mod messaging;
pub mod network;
pub mod performance_profiling;
pub mod population;
pub mod profiling;
mod replanning;
mod simulation;
pub mod time_queue;
Expand Down
File renamed without changes.

0 comments on commit 032d974

Please sign in to comment.