Repository navigation
Fix: keep forked host log records intact #1691
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,7 @@ | |
| * both TIMING and WARN thresholds to CANN WARN. | ||
| */ | ||
|
|
||
| #ifndef PLATFORM_HOST_LOG_H_ | ||
| #define PLATFORM_HOST_LOG_H_ | ||
| #pragma once | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider. This guard swap is unrelated to the fix. The repo carries both styles (67 files use The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping this one, but flagging the reason rather than just overruling you — happy to revert if you still disagree.
"On sight during routine edits" is exactly this case — the PR already modifies this header for the I read |
||
|
|
||
| #include <cstdarg> | ||
| #include <cstdio> | ||
|
|
@@ -32,9 +31,8 @@ class HostLogger { | |
|
|
||
| void log(simpler::log::LogLevel level, const char *func, const char *fmt, ...); | ||
|
|
||
| // va_list-taking primitives — used by unified_log_* adapters to forward | ||
| // a caller's variadic args without an intermediate vsnprintf-to-buffer | ||
| // round-trip. Caller is responsible for `va_start` / `va_end`. | ||
| // va_list-taking primitive used by unified_log_* adapters. Caller is | ||
| // responsible for `va_start` / `va_end`. | ||
| void vlog(simpler::log::LogLevel level, const char *func, const char *fmt, va_list args); | ||
|
|
||
| void set_level(simpler::log::LogLevel level); | ||
|
|
@@ -66,5 +64,3 @@ class HostLogger { | |
| simpler::log::LogLevel current_level_; | ||
| std::mutex mutex_; | ||
| }; | ||
|
|
||
| #endif // PLATFORM_HOST_LOG_H_ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should fix. This covers the first half of suggestion (2) in #1690 — find multiple markers on a line — but not the second, detecting malformed/torn input. A record torn mid-write still yields nothing and produces no signal at all, which is precisely how #1690 manifested:
effective_us=0.0with no way to distinguish instrumentation loss from a real measurement.Suggestion: count record heads per line and compare against the number of spans actually yielded; if the totals differ, print one warning to stderr in
main()before the table. Cheap, and it converts a silent data loss into something the operator can see.Matching the head (
[STRACE] v=) rather than the bare[STRACE]literal keeps false positives away from prose that happens to mention the marker.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in dffab7e, taking your suggestion as described.
count_record_heads(lines)counts[STRACE] v=heads independently of whether the rest of the record survived, andmain()prints one stderr warning before the table when that total exceeds the spans actually parsed:Matching the head rather than the bare
[STRACE]literal, as you suggested.test_count_record_heads_sees_a_torn_record_that_parse_spans_dropscovers it.