Skip to content

Commit

Permalink
WIP: work on fast multi-acquisition
Browse files Browse the repository at this point in the history
Meaning, work towards multiple acquisitions after another with minimal
delay inbetween.
  • Loading branch information
sk1p committed Nov 15, 2023
1 parent ff40f94 commit 989705c
Show file tree
Hide file tree
Showing 27 changed files with 971 additions and 482 deletions.
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions k2o/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ log = "0.4.18"
dbus = "0.9.7"
libc = "0.2.147"
env_logger = "0.10.0"
partialdebug = "0.2.0"

[features]
hdf5 = ["dep:hdf5"]
Expand Down
32 changes: 32 additions & 0 deletions k2o/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,38 @@
- => no change in performance, still spending 88% of our time in the page fault handler
- assembly of full frames is required to get a good access pattern!

# Notes on reworking the life cycles

To make sure we can quickly start acquisitions after another,
we need to make sure of some boundary conditions:

- The SHM area needs to be kept alive over multiple acquisitions, as well as
the "recycling" system for blocks, such that we don't have malloc/pagefault
caused jitter
- The sockets need to be kept open, otherwise the multicast traffic may only be
received after an initial delay (IIRC)
- That also means that switching between more fundamental settings may take longer
- changing network settings
- changing camera mode (IS/Summit)
- SHM socket path
- enabling / disabling the frame iterator
- What changes must be fast:
- file writer destination (filename) -> we may need to disable pre-allocation of files!
- number of frames per acquisition
- probably: camera sync mode (immediately vs. wait for sync flag)

## Action items
- [ ] Refactor...
- [x] The `AcquisitionRuntime` should be the object that lives over multiple acquisitions
- [x] On the Python side, the `Cam` already needs to start the `AcquisitionRuntime`
- [ ] For error handling, we should have the option to completely tear down
and re-create the `AcquisitionRuntime`, perform this step automatically such that
we don't have "restart the {script,notebook,app,server}" situations as often as currently
- [x] `WriterBuilder` must be set per acquisition, not when starting the runtime
- [x] Figure out where the acquisition ID should be generated
- probably in the `AcquisitionRuntime`, as that is the long-living object
which manages the background thread(s) etc.

# TODO
- [ ] fix busy waiting (one of the `try_recv` loops, I guess)
- [ ] fix subframe shtuff
4 changes: 2 additions & 2 deletions k2o/benches/assemble_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ fn criterion_benchmark(c: &mut Criterion) {

const TOTAL_INPUT_SIZE: usize = 1 * PACKET_SIZE;

let block = K2ISBlock::empty(42);
let mut frame: K2ISFrame = K2ISFrame::empty::<K2ISBlock>(42);
let block = K2ISBlock::empty(42, 0);
let mut frame: K2ISFrame = K2ISFrame::empty::<K2ISBlock>(42, 0);

let mut assign_block = c.benchmark_group("assign_block* functions");
assign_block.measurement_time(Duration::new(10, 0));
Expand Down
2 changes: 1 addition & 1 deletion k2o/benches/decode_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn criterion_benchmark(c: &mut Criterion) {
let in_chunks = input.chunks_exact(PACKET_SIZE);

for chunk in in_chunks {
K2ISBlock::from_bytes(black_box(chunk), 0);
K2ISBlock::from_bytes(black_box(chunk), 0, 0);
}
})
},
Expand Down
Loading

0 comments on commit 989705c

Please sign in to comment.