Skip to content

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

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...

@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.

@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 chrisxu333 force-pushed the expose_perf_io_context branch from 84c4794 to b71c53d Compare December 21, 2023 07:03
@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.

@chrisxu333 chrisxu333 force-pushed the expose_perf_io_context branch from b71c53d to cb470c0 Compare December 25, 2023 06:51
@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
@git-hulk git-hulk requested review from mapleFU and torwig December 25, 2023 10:00
@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

@chrisxu333 chrisxu333 force-pushed the expose_perf_io_context branch from 25392d3 to 682777c Compare December 26, 2023 06:48
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 chrisxu333 force-pushed the expose_perf_io_context branch from 682777c to 46957db Compare December 27, 2023 03:14
@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.

@sonarqubecloud
Copy link

sonarqubecloud 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
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