Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure performance with flamegraph #224

Merged
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
65 changes: 65 additions & 0 deletions .github/workflows/performance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Rust performance

on:
push:
branches:
- master
tags:
- "*"
workflow_dispatch:

env:
RUST_BACKTRACE: 1

jobs:

test:
runs-on: ubuntu-latest

strategy:
matrix:
test: [od_robust_test_ekf_realistic_two_way, traj_spacecraft, gmat_val_leo_day_adaptive, stop_cond_nrho_apo]

steps:
- uses: actions/checkout@v2

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.72

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: perf-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: perf-cargo-

- name: Run cargo test
run: cargo test --no-run ${{ matrix.test }}

- name: Parse executable
id: executable
run: |
executable=$(echo "${{ steps.test.outputs.stdout }}" | awk '/^ Executable / { match($0, /Executable .* (\S+) \(/, groups); print groups[1] }')
echo "::set-output name=exec::$executable"

- name: Install flamegraph
run: |
apt install linux-tools-common linux-tools-generic linux-tools-`uname -r`
cargo install flamegraph

- name: Run flamegraph
run: flamegraph -o flame-${{ matrix.test }}.svg -- ${{ steps.executable.outputs.exec }} ${{ matrix.test }}

- name: Upload python tests HTMLs
uses: actions/upload-artifact@v3
with:
name: flamegraph
path: flame-*.svg
14 changes: 11 additions & 3 deletions src/od/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ where
info!("Processing {num_msrs} measurements with covariance mapping");

// We'll build a trajectory of the estimated states. This will be used to compute the measurements.
let mut traj = Traj::new();
let mut traj: Traj<S> = Traj::new();

let mut msr_accepted_cnt = 0;

Expand All @@ -493,8 +493,16 @@ where
self.prop.details.step
});

// Remove old states from the trajectory
traj.states.retain(|state: &S| state.epoch() <= epoch);
// Remove old states from the trajectory (this is a manual implementation of `retaint` because we know it's a sorted vec)
// traj.states.retain(|state: &S| state.epoch() <= epoch);
let mut index = traj.states.len();
while index > 0 {
index -= 1;
if traj.states[index].epoch() > epoch {
break;
}
}
traj.states.truncate(index);

debug!("advancing propagator by {next_step_size} (Δt to next msr: {delta_t})");
let (_, traj_covar) = self.prop.for_duration_with_traj(next_step_size)?;
Expand Down