fix: validate memory measurement is numeric before display#86
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens peak memory (RSS) reporting in the benchmark runner to avoid rendering malformed memory strings when measurement fails.
Changes:
- Add a Linux +
/usr/bin/timeavailability guard before attempting RSS measurement. - Validate that the extracted RSS value is numeric before converting/formatting it.
- In markdown output, only accept
.memvalues that match a numeric pattern before displaying them.
Comment on lines
+127
to
+130
| local raw | ||
| raw=$(/usr/bin/time -v "$@" 2>&1 >/dev/null | grep "Maximum resident" | awk '{print $6}') | ||
| if [[ -n "$raw" && "$raw" =~ ^[0-9]+$ ]]; then | ||
| awk "BEGIN {printf \"%.1f\", $raw/1024}" |
There was a problem hiding this comment.
With set -euo pipefail, the raw=$(...) pipeline can terminate the entire script if any stage returns non-zero (e.g., /usr/bin/time -v not supported, or the expected "Maximum resident" line isn’t present and grep exits 1). Since this function is intended to fall back to N/A, make the extraction pipeline non-fatal (e.g., append || true inside the command substitution, or avoid grep by using a single awk that yields empty output and exits 0 when no match is found).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
measure_memoryto check/usr/bin/timeexists before calling it.memvalues matching^[0-9]+\.?[0-9]*$46.6N/A MBdisplay when memory measurement partially fails in DockerTest plan