Skip to content

Commit

Permalink
Merge pull request #224 from nyx-space/223-measure-performance-in-git…
Browse files Browse the repository at this point in the history
…hub-workflow

Measure performance with flamegraph
  • Loading branch information
ChristopherRabotin authored Sep 1, 2023
2 parents 978ece5 + 3fce28a commit 8c543ee
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
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

0 comments on commit 8c543ee

Please sign in to comment.