Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ web-sys = "^0.3.77"
getrandom = "0.3.4"
fern = "^0.7.1"
wasm-bindgen = "^0.2.100"
progress_bar = "^1.2.1"
anyhow = "^1.0.28"
sysinfo = "^0.37.0"
humantime = "^2.2.0"
Expand All @@ -74,10 +73,9 @@ homepage.workspace = true
authors.workspace = true

[features]
default = ["logging", "progress_bar"]
default = ["logging"]

logging = ["log4rs", "fern", "wasm-bindgen", "web-sys"]
progress_bar = ["dep:progress_bar", "anyhow"]

profiling = ["dep:sysinfo", "dep:bytesize"]

Expand Down Expand Up @@ -119,10 +117,6 @@ indexmap = "2.13.0"
# Logging
log4rs = { workspace = true, optional = true }

# Progress Bar
progress_bar = { workspace = true, optional = true, features = ["logger"] }
anyhow = { workspace = true, optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
fern = { workspace = true, optional = true }
# Required here only to enable the js backend:
Expand Down
1 change: 0 additions & 1 deletion docs/book/src/cli-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Default cli arguments for ixa runner
* `--warn` — Set logging to WARN level. Shortcut for `--log-level warn`
* `--debug` — Set logging to DEBUG level. Shortcut for `--log-level DEBUG`
* `--trace` — Set logging to TRACE level. Shortcut for `--log-level TRACE`
* `-t`, `--timeline-progress-max <TIMELINE_PROGRESS_MAX>` — Enable the timeline progress bar with a maximum time
* `--no-stats` — Suppresses the printout of summary statistics at the end of the simulation


Expand Down
88 changes: 0 additions & 88 deletions docs/book/src/topics/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,94 +162,6 @@ fn load_population_data(path: &str, context: &mut Context) {
}
```

This pattern is especially useful to pair with a progress bar as in the next
section.

## Progress Bar

Provides functions to set up and update a progress bar.

A progress bar has a label, a maximum progress value, and its current progress,
which starts at zero. The maximum and current progress values are constrained to
be of type `usize`. However, convenience methods are provided for the common
case of a progress bar for the timeline that take `f64` time values and rounds
them to nearest integers for you.

Only one progress bar can be active at a time. If you try to set a second
progress bar, the new progress bar will replace this first. This is useful if
you want to track the progress of a simulation in multiple phases. Keep in mind,
however, that if you define a timeline progress bar, the `Context` will try to
update it in its event loop with the current time, which might not be what you
want if you have replaced the progress bar with a new one.

### Timeline Progress Bar

```rust
/// Initialize the progress bar with the maximum time until the simulation ends.
pub fn init_timeline_progress_bar(max_time: f64);
/// Updates the progress bar with the current time. Finalizes the progress bar when
/// `current_time >= max_time`.
pub fn update_timeline_progress(mut current_time: f64);
```

### Custom Progress Bar

If the timeline is not a good indication of progress for your simulation, you
can set up a custom progress bar.

```rust
/// Initializes a custom progress bar with the given label and max value.
pub fn init_custom_progress_bar(label: &str, max_value: usize);

/// Updates the current value of the custom progress bar.
pub fn update_custom_progress(current_value: usize);

/// Increments the custom progress bar by 1. Use this if you don't want to keep track of the
/// current value.
pub fn increment_custom_progress();
```

### Custom Example: People Infected

Suppose you want a progress bar that tracks how much of the population has been
infected (or infected and then recovered). You first initialize a custom
progress bar before executing the simulation.

```rust
use crate::progress_bar::{init_custom_progress_bar};

init_custom_progress_bar("People Infected", POPULATION_SIZE);
```

To update the progress bar, we need to listen to the infection status property
change event.

```rust
use crate::progress_bar::{increment_custom_progress};

// You might already have this event defined for other purposes.
pub type InfectionStatusEvent = PropertyChangeEvent<Person, InfectionStatus>;

// This will handle the status change event, updating the progress bar
// if there is a new infection.
fn handle_infection_status_change(context: &mut Context, event: InfectionStatusEvent) {
// We only increment the progress bar when a new infection occurs.
if (InfectionStatusValue::Susceptible, InfectionStatusValue::Infected)
== (event.previous, event.current)
{
increment_custom_progress();
}
}

// Be sure to subscribe to the event when you initialize the context.
pub fn init(context: &mut Context) -> Result<(), IxaError> {
// ... other initialization code ...
context.subscribe_to_event::<InfectionStatusEvent>(handle_infection_status_change);
// ...
Ok(())
}
```

## Additional Resources

For an in-depth look at performance in Rust programming, including many advanced
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ixa-runner-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage.workspace = true
authors.workspace = true

[dependencies]
ixa = { path = "../../", features = ["logging", "progress_bar", "profiling"] }
ixa = { path = "../../", features = ["logging", "profiling"] }
clap.workspace = true

[dev-dependencies]
Expand Down
28 changes: 0 additions & 28 deletions integration-tests/ixa-runner-tests/tests/progress_bar.rs

This file was deleted.

7 changes: 0 additions & 7 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use crate::execution_stats::{
};
use crate::global_properties::get_global_property_count;
use crate::plan::{PlanId, Queue};
#[cfg(feature = "progress_bar")]
use crate::progress::update_timeline_progress;
use crate::{get_data_plugin_count, trace, warn, HashMap, HashMapExt};

/// The common callback used by multiple [`Context`] methods for future events
Expand Down Expand Up @@ -422,11 +420,6 @@ impl Context {

// Start plan loop
loop {
#[cfg(feature = "progress_bar")]
if crate::progress::MAX_TIME.get().is_some() {
update_timeline_progress(self.get_current_time());
}

if self.shutdown_requested {
self.shutdown_requested = false;
break;
Expand Down
9 changes: 0 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
//! ## Features
//!
//! - **`logging`**: enables structured logging for native and wasm targets.
//! - **`progress_bar`**: enables the timeline progress bar for long-running simulations.
//! - **`profiling`**: enables collection and reporting of execution profiling statistics. Disabled by default.

#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/docs/book/src/cli-usage.md"))]
Expand Down Expand Up @@ -71,9 +70,6 @@ pub use log::{
set_module_filters, trace, warn, LevelFilter,
};

#[cfg(feature = "progress_bar")]
pub mod progress;

pub mod hashing;
pub mod numeric;

Expand Down Expand Up @@ -111,11 +107,6 @@ pub mod profiling;

pub mod data_structures;

#[cfg(all(target_arch = "wasm32", feature = "progress_bar"))]
compile_error!(
"Target `wasm32` and feature `progress_bar` are mutually exclusive — enable at most one."
);

// The following is a workaround for an ICE involving wasm-bindgen:
// https://github.com/CDCgov/ixa/actions/runs/16283417455/job/45977349528?pr=464
#[cfg(target_family = "wasm")]
Expand Down
2 changes: 0 additions & 2 deletions src/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ mod wasm_logger;

#[cfg(not(feature = "logging"))]
mod null_logger;
#[cfg(feature = "progress_bar")]
mod progress_bar_encoder;

use std::collections::hash_map::Entry;
use std::sync::{LazyLock, Mutex, MutexGuard};
Expand Down
28 changes: 0 additions & 28 deletions src/log/progress_bar_encoder.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/log/standard_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use log4rs::config::{Appender, Logger, Root};
use log4rs::encode::pattern::PatternEncoder;
use log4rs::Config;

#[cfg(feature = "progress_bar")]
use super::progress_bar_encoder::PBWrapperEncoder;
use crate::log::{LogConfiguration, ModuleLogConfiguration};

// Use an ISO 8601 timestamp format and color coded level tag
Expand All @@ -21,9 +19,6 @@ impl LogConfiguration {
/// Sets the global logger to conform to this [`LogConfiguration`].
pub(in crate::log) fn set_config(&mut self) {
let encoder = Box::new(PatternEncoder::new(DEFAULT_LOG_PATTERN));
// Appends an ANSI escape code to clear to end of line.
#[cfg(feature = "progress_bar")]
let encoder = Box::new(PBWrapperEncoder::new(encoder));
let stdout: ConsoleAppender = ConsoleAppender::builder().encoder(encoder).build();
let mut config: ConfigBuilder =
Config::builder().appender(Appender::builder().build("stdout", Box::new(stdout)));
Expand Down
Loading
Loading