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

Add the support of ANALYZE command to inspect the performance of RocksDB #1943

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

chrisxu333
Copy link
Contributor

@chrisxu333 chrisxu333 commented Dec 18, 2023

This pr tries to close #783 .

To expose essential perf_context and iostats_context from rocksdb, a new command ANALYZE is introduced.

A typical usage would be as follows:
perf

src/commands/cmd_server.cc Outdated Show resolved Hide resolved
src/commands/cmd_server.cc Outdated Show resolved Hide resolved
Copy link
Member

@mapleFU mapleFU left a comment

Choose a reason for hiding this comment

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

This is a bit confusing because it does far less than PROFILE in SQL. Also it might break the previous config about perflevel, so I wonder whether we have better way for this...

src/commands/cmd_server.cc Outdated Show resolved Hide resolved
src/commands/cmd_server.cc Show resolved Hide resolved
src/commands/cmd_server.cc Outdated Show resolved Hide resolved
@mapleFU
Copy link
Member

mapleFU commented Dec 19, 2023

Maybe it's better to first having a RAII guard like TiKV: https://github.com/tikv/tikv/blob/master/src/coprocessor/tracker.rs ( We can be easier than them) ?

@chrisxu333
Copy link
Contributor Author

Maybe it's better to first having a RAII guard like TiKV: https://github.com/tikv/tikv/blob/master/src/coprocessor/tracker.rs ( We can be easier than them) ?

Can you elaborate more on this? I didn't quite get the point.

src/commands/cmd_server.cc Outdated Show resolved Hide resolved
src/server/redis_reply.cc Outdated Show resolved Hide resolved
@mapleFU
Copy link
Member

mapleFU commented Dec 20, 2023

Maybe it's better to first having a RAII guard like TiKV: https://github.com/tikv/tikv/blob/master/src/coprocessor/tracker.rs ( We can be easier than them) ?

Can you elaborate more on this? I didn't quite get the point.

Hmm we can just leave it here in this patch. I believe something like a :

class StoragePerfContext {
  
  void close();
  ~StoragePerfContext() {
      if (!reset_) {
         rocksdb::Perfcontext // resume
      }
   }
private:
  Storage* // or rocksdb?
  bool reseted_ = false;
};

Might be better? If other command want to debugging, they can also uses this tool? Also we can considering RAII here.

@chrisxu333
Copy link
Contributor Author

Maybe it's better to first having a RAII guard like TiKV: https://github.com/tikv/tikv/blob/master/src/coprocessor/tracker.rs ( We can be easier than them) ?

Can you elaborate more on this? I didn't quite get the point.

Hmm we can just leave it here in this patch. I believe something like a :

class StoragePerfContext {
  
  void close();
  ~StoragePerfContext() {
      if (!reset_) {
         rocksdb::Perfcontext // resume
      }
   }
private:
  Storage* // or rocksdb?
  bool reseted_ = false;
};

Might be better? If other command want to debugging, they can also uses this tool? Also we can considering RAII here.

I see what you meant. So just to be clear, do we still need to do this in this patch? Or we wait until when it's actually needed to do so?

@mapleFU
Copy link
Member

mapleFU commented Dec 21, 2023

do we still need to do this in this patch

I agree it's not neccessary in this patch. Personally I think metrics can be widely used, but lets first get it in used...

cc @PragmaTwice @git-hulk This command looks like SQL "PROFILE" with rocksdb io/perf stats enabled and output. It can be used in some cases, but for some blocking command I don't know whether it's ok. Would you mind take a look?

@chrisxu333
Copy link
Contributor Author

do we still need to do this in this patch

I agree it's not neccessary in this patch. Personally I think metrics can be widely used, but lets first get it in used...

cc @PragmaTwice @git-hulk This command looks like SQL "PROFILE" with rocksdb io/perf stats enabled and output. It can be used in some cases, but for some blocking command I don't know whether it's ok. Would you mind take a look?

@git-hulk @PragmaTwice Hello guys, if you have time could you help review this pr? Thank you :)

@git-hulk
Copy link
Member

Sure, sorry for missing this message. I will take a look recently.

@git-hulk
Copy link
Member

@chrisxu333 Can rename true_args_ to command_args_, rest are good to me. Sorry for missing this point.

@git-hulk git-hulk changed the title expose rocksdb perf/iostat context with ANALYZE command Add the support of ANALYZE command to inspect the performance of RocksDB Dec 25, 2023
@chrisxu333 chrisxu333 force-pushed the expose_perf_io_context branch 2 times, most recently from ce3220b to 614672d Compare December 25, 2023 09:45
git-hulk
git-hulk previously approved these changes Dec 25, 2023
@mapleFU
Copy link
Member

mapleFU commented Dec 25, 2023

Would you mind fix the lint first?

@torwig
Copy link
Contributor

torwig commented Dec 25, 2023

@chrisxu333 ./x.py format should do the trick.

@chrisxu333
Copy link
Contributor Author

Would you mind fix the lint first?

Sounds good I just did.

Comment on lines +1149 to +1156

auto s = cmd->Parse(command_args_);
Copy link
Member

Choose a reason for hiding this comment

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

Should we check the arity before Parse? Since wrong command_args_ might make our program crash

Copy link
Member

Choose a reason for hiding this comment

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

We need to reuse the code in ExecuteCommand rather than write them again here.

Copy link
Contributor Author

@chrisxu333 chrisxu333 Dec 26, 2023

Choose a reason for hiding this comment

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

I just pushed a newer version which added the arity checking logic. As for reusing / refactoring the code in ExecuteCommand, maybe it's better to do it in a separate pr? As the ExecuteCommand code needs to be dissected into several chunks for reusing purpose. @mapleFU @PragmaTwice

Comment on lines +1133 to +1135
for (int i = 1; i < args.size(); ++i) {
command_args_.push_back(args[i]);
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: we can directly insert rather than push back

@chrisxu333
Copy link
Contributor Author

@chrisxu333 ./x.py format should do the trick.

Hi @torwig, could you help review this pr whenever you're able to? Thx!

@chrisxu333
Copy link
Contributor Author

Hi @git-hulk @PragmaTwice,

Could you help review and approve this pr if possible? Thx!

@git-hulk
Copy link
Member

git-hulk commented Jan 2, 2024

@chrisxu333 Thanks for your follow-up. This PR looks good to me, to see if @PragmaTwice and @torwig has any comments, if not, we can move forward to merge.

Copy link

sonarcloud bot commented Jan 2, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@git-hulk git-hulk merged commit 6b9dcd1 into apache:unstable Jan 2, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose some stats in RocksDB Perf Context and IO Stats Context
5 participants