facebook / facebook/rocksdb

The FileSystemTracingWrapper makes an extra ElapsedNanos call on every traced operation, and other issues.

Open
#7,504 1 comment 0 reactions 1 assignee Claimed by @akankshamahajan15 View on GitHub
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

This was found during code inspection. Most calls inside of the FileSystemTracingWrapper look like this:
StopWatchNano timer(Env::Default());
timer.Start();
IOStatus s = // Do something
uint64_t elapsed = timer.ElapsedNanos();
IOTraceRecord io_record(env_->NowNanos(), TraceType::kIOFileName, __func__,
elapsed, s.ToString(), fname);
io_tracer_->WriteIOOp(io_record);
return s;

This code has a couple of issues:
1 - NowNanos is called three times (one to start the timer, once for elapsed, and again to record the operation) when two calls would be sufficient.

2 - One place uses Env::Default and another uses the member variable env_. The TracingWrapper should allow the env_ to be overridden and should use the same env throughout (granted, the TracingWrapper sets env_ to Default, but that should not be the case).

3 - The __func__ is not going to be particularly useful, as it will say "FileSystemTracingWrapper::Method". What is really wanted is the name of the underlying FileSystem (e.g. target()->Name() ::Method).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.