Commit e4d49c4
feat: Add FileIoTracer for tracking IO operations with call stack context (facebookincubator#422)
Summary:
Pull Request resolved: facebookincubator#422
X-link: facebookincubator/velox#16012
This diff introduces a file IO tracing infrastructure to capture IO operations along with their call stack context using thread-local storage. This enables debugging and performance analysis by providing visibility into where IO operations originate in the code.
- **IoTag**: A linked structure representing tags in the IO call stack, forming a stack trace. Supports `toString()` for human-readable output (e.g., "TableScan -> ColumnReader -> PrefixEncoding") and `depth()` for stack depth.
- **ScopedIoTag**: RAII helper that automatically pushes a tag onto the thread-local stack on construction and pops it on destruction. This allows capturing IO context without modifying function signatures.
- **threadIoTag()**: Thread-local accessor function returning reference to the current IO tag pointer. Each thread maintains its own independent tag stack.
- **FileIoTracer**: Abstract base class defining the interface for IO tracing implementations with `record()` and `finish()` methods.
- **InMemoryFileIoTracer**: Thread-safe concrete implementation that records IO operations to a `std::vector<IoRecord>`. Protected by mutex for concurrent access from multiple threads.
- **IoRecord**: Struct capturing a single IO operation with type (Read/AsyncRead/Write/AsyncWrite), offset, length, and tag string.
Other Changes
- Renamed `FileStorageContext` to `FileIoContext` and added `ioTracer` field for optionally attaching a tracer to file operations.
- Renamed `Utils.h/cpp` to `FileUtils.h/cpp` for clarity and consistency with other file-related utilities.
Reviewed By: tanjialiang
Differential Revision: D90657574
fbshipit-source-id: 7f2a8f176ea002c963c98fb4a5fe5e63e3723a4b1 parent 0dd2144 commit e4d49c4
1 file changed
+7
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
307 | 307 | | |
308 | | - | |
| 308 | + | |
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
| 314 | + | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
| 342 | + | |
347 | 343 | | |
348 | 344 | | |
349 | 345 | | |
| |||
0 commit comments