Add more narrowly-scoped TimeBoundLoggers around syscalls#7836
Merged
achamayou merged 2 commits intomicrosoft:mainfrom Apr 22, 2026
Merged
Add more narrowly-scoped TimeBoundLoggers around syscalls#7836achamayou merged 2 commits intomicrosoft:mainfrom
achamayou merged 2 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds more narrowly-scoped asynchost::TimeBoundLogger instrumentation around IO syscalls/filesystem operations so slow host-side disk operations can be identified with more precise log messages.
Changes:
- Wraps snapshot and ledger file operations (open/read/write/fsync/close/rename/remove) in
TimeBoundLoggerscopes with more specific messages. - Adds similar slow-IO logging around LFS index file reads/writes and file cleanup operations.
- Makes
TimeBoundLogger::default_max_timea header-definedstatic inlinewith a 10ms default, removing per-TU definitions.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/snapshots/snapshot_manager.h | Adds TimeBoundLogger scopes around snapshot directory creation, snapshot file open/write/close/fsync/rename. |
| src/snapshots/filenames.h | Adds TimeBoundLogger around snapshot ignore-file rename. |
| src/host/time_bound_logger.h | Moves default_max_time to static inline with default initial value. |
| src/host/test/ledger.cpp | Removes out-of-line definition of default_max_time. |
| src/host/run.cpp | Removes earlier out-of-line initialization (runtime config assignment remains elsewhere). |
| src/host/lfs_file_handler.h | Adds TimeBoundLogger around LFS index dir operations and file read/write streams. |
| src/host/ledger.h | Adds TimeBoundLogger around many stdio/filesystem operations while reading/writing/truncating/committing ledgers. |
| src/host/files_cleanup_timer.h | Adds TimeBoundLogger around file open/read-loop hashing and remove() operations. |
Comments suppressed due to low confidence (1)
src/host/lfs_file_handler.h:89
- The get handler assumes ifstream open/seek/read always succeed once is_regular_file() is true. In practice open/seek/tellg/read can still fail (permissions, concurrent deletion, IO errors), and tellg() may return -1 leading to a huge allocation for LFSEncryptedContents. Add checks for
fstate and for tellg()/read success before allocating/reading, and fall back to not_found or an error response/log.
TimeBoundLogger log_if_slow(
fmt::format("Reading LFS file - ifstream({})", target_path));
std::ifstream f(target_path, std::ios::binary);
f.seekg(0, f.end);
const auto file_size = f.tellg();
LOG_TRACE_FMT(
"Reading {} byte file from {}",
static_cast<size_t>(file_size),
target_path);
f.seekg(0, f.beg);
ccf::indexing::LFSEncryptedContents blob(file_size);
f.read(reinterpret_cast<char*>(blob.data()), blob.size());
f.close();
Member
Author
|
I think all of copilot's comments are pre-existing. Potentially worth exploring, but out-of-scope for this PR. |
achamayou
approved these changes
Apr 22, 2026
Member
Let's fire off copilot fixes for the ones we think are worthwhile. Worth doing a quick bench a/b to confirm this comes at a negligible cost? |
Member
Looks good. |
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.
No description provided.