Skip to content
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

Simplify TraceAnalyzer #8697

Closed
wants to merge 11 commits into from
Closed

Conversation

autopear
Copy link
Contributor

@autopear autopear commented Aug 24, 2021

Handler functions now use a common output function to output to stdout/files.

Test:
trace_analyzer_test can pass.

if (!ta_[TraceOperationType::kGet].enabled) {
return Status::OK();
}
value_size = 10;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhichao-cao Why change value size to 10?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Get trace record, we do not collect the value. So, we do not have the "value" part. In order to simplify the later on calculation, we just give a fixed value. Maybe it would be better to add a comments here to make it more clear

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more question, why we don't do the same thing for other key only operations (seeks, deletes, etc.)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obviously, we forgot to do the same thing for other non-value recorded operations........

@autopear autopear marked this pull request as draft August 24, 2021 08:30
@autopear autopear marked this pull request as ready for review August 24, 2021 18:07
class TraceAnalysisResult : public TraceRecordResult {
public:
// All operations must have the same timestamp and trace type, e.g, MultiGet.
TraceAnalysisResult(TraceOperationType op_type, std::vector<uint32_t> cf_ids,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if in the future, we wan to get some special results from different types? E.g., for iterator, we my need to get the lower and upper bound? So, is a general TraceAnalysisResult enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A general TraceAnalysisResult may not be enough for all potential special requirements, but at least now it's better to have individual functions with mostly the same code for each operation type.

As for iterator's lower/upper bound, they are used when creating an iterator. I guess later we may need to have some iterator creation trace type, then, the 2 bounds can be handled there.

return write_result_->Accept(this);
}

Status TraceAnalyzer::Handle(const TraceAnalysisResult& result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some comments here to explain what is the job of this "Handle".

Copy link
Contributor Author

@autopear autopear Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

It is used to handle the generic analysis result for outputting purpose. If we don't use TraceAnalysisResult, we can probably replace it with a single function that does the same job (actually this should be better).

@autopear autopear changed the title Refactor TraceAnalyzer to use TraceRecordResult Simplify TraceAnalyzer Aug 24, 2021
@@ -169,6 +168,8 @@ DEFINE_double(sample_ratio, 1.0,

namespace ROCKSDB_NAMESPACE {

const size_t kShadowValueSize = 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add comment to explain why we need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a brief description in the header file.

Copy link
Contributor

@zhichao-cao zhichao-cao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the code change, which makes it more clear and simplier.

@facebook-github-bot
Copy link
Contributor

@autopear has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@autopear has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@autopear has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@autopear merged this pull request in 785faf2.

@autopear autopear deleted the trace_analyzer branch August 25, 2021 01:37
yoori pushed a commit to yoori/rocksdb that referenced this pull request Nov 26, 2023
Summary:
Handler functions now use a common output function to output to stdout/files.

Pull Request resolved: facebook/rocksdb#8697

Test Plan: `trace_analyzer_test` can pass.

Reviewed By: zhichao-cao

Differential Revision: D30527696

Pulled By: autopear

fbshipit-source-id: c626cf4d53a39665a9c4bcf0cb019c448434abe4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants