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

Maintain high capture rate for long batch captures #46

Merged
merged 3 commits into from
Jun 17, 2021

Conversation

vogelpi
Copy link
Collaborator

@vogelpi vogelpi commented Jun 16, 2021

This PR contains two commits in order to increase the capture rate for long batch captures.

  1. Frequent storage segment array resizing is avoided by setting the hint value to the known storage segment size (a project parameter).
  2. During capture, disable all except for the latest two storage segments to keep the run time of the append() function approximately constant. By default, it increases linearly with the number of traces captured.

With these changes it is possible to maintain high capture rates up to millions of traces. Further changes are probably needed to avoid memory limitations. Currently everything is kept in memory during a capture and traces are written to disk only at the very end. I've opened an issue newaetech/chipwhisperer#344 in the hope of getting some further advice.

By default, the ChipWhisperer API starts every new trace segment (in the
project file, not related to the segment/batch captured in one shot)
with the size of 1 trace. Upon appending new traces to the project, the
segment is resized in steps of 25 traces. This results in frequent array
resizing and decreasing capture rate.

With this commit, the allocation size is frequently checked. If it's
lower than the known segment size, it's corrected directly to this
value. The next resize operation will allocate sufficient memory for
the whole segment array.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
@vogelpi vogelpi requested a review from vrozic June 16, 2021 13:16
@@ -97,17 +98,34 @@ def run_batch_capture(capture_cfg, ot, ktp, scope):
f"actual: {actual_last_ciphertext}\n"
f"expected: {expected_last_ciphertext}"
)
# Make sure to allocate sufficient memory for the storage segment array during the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add a reference to the CW issue here? newaetech/chipwhisperer#344

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

By default, the ChipWhisperer performs a range check `_updateRanges()`
on all previously captured traces whenever adding a new trace. As a
result, the complexity of the `append()` function scales linearly with
the number of previously captured traces which significantly slows down
the capture rate.

With this commit, all except for the latest two trace storage segments
are disabled. The `_updateRange()` function then behaves like a sliding
window and only looks at the latest two instead of all segments. This
allows to maintain high capture rates even when capturing millions of
traces.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
@vogelpi vogelpi force-pushed the avoid-frequent-array-resize branch from 601e67e to 7ead6a0 Compare June 17, 2021 15:40
@vogelpi
Copy link
Collaborator Author

vogelpi commented Jun 17, 2021

Thanks for the quick review guys!

@vogelpi vogelpi merged commit c0949da into lowRISC:master Jun 17, 2021
@vogelpi vogelpi deleted the avoid-frequent-array-resize branch August 5, 2021 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants