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 bitmap control for perf context #237

Merged
merged 8 commits into from
Aug 13, 2021
Merged

Conversation

LemonHX
Copy link

@LemonHX LemonHX commented Jun 8, 2021

include/rocksdb/c.h Outdated Show resolved Hide resolved
Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

LGTM overall

db/c.cc Outdated Show resolved Hide resolved
include/rocksdb/perf_flag_defs.h Show resolved Hide resolved
SetPerfLevel(PerfLevel::kDisable);
EnablePerfFlag(flag_user_key_comparison_count);
},
{ ASSERT_GT(get_perf_context()->user_key_comparison_count, 0); });
Copy link
Member

Choose a reason for hiding this comment

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

Perf context is stored locally so that it may contain data from previous tests. I would suggest you to assert the delta value.

@yiwu-arbug
Copy link
Collaborator

/run-tests

@yiwu-arbug
Copy link
Collaborator

@LemonHX build fail. along with CMakeList.txt, you also need to add the new files and new tests to src.mk and https://github.com/tikv/rocksdb/blob/6.4.tikv/Makefile#L420

@yiwu-arbug
Copy link
Collaborator

/run-tests

@LemonHX
Copy link
Author

LemonHX commented Aug 2, 2021

@LemonHX build fail. along with CMakeList.txt, you also need to add the new files and new tests to src.mk and https://github.com/tikv/rocksdb/blob/6.4.tikv/Makefile#L420

done

@LemonHX
Copy link
Author

LemonHX commented Aug 2, 2021

/run-tests

1 similar comment
@yiwu-arbug
Copy link
Collaborator

/run-tests

CMakeLists.txt Outdated Show resolved Hide resolved
@yiwu-arbug
Copy link
Collaborator

The encryption_env test and Mac test in CI are broken. We can ignore them for now.

@LemonHX
Copy link
Author

LemonHX commented Aug 6, 2021

so could we merge it?

monitoring/perf_flag_test.cc Outdated Show resolved Hide resolved
monitoring/perf_flag_test.cc Outdated Show resolved Hide resolved
monitoring/perf_flag_test.cc Outdated Show resolved Hide resolved
monitoring/perf_flag.cc Outdated Show resolved Hide resolved
monitoring/perf_flag.cc Outdated Show resolved Hide resolved
monitoring/perf_context_imp.h Outdated Show resolved Hide resolved
monitoring/perf_context_imp.h Outdated Show resolved Hide resolved
include/rocksdb/perf_flag.h Outdated Show resolved Hide resolved
include/rocksdb/perf_flag.h Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@tabokie tabokie changed the title Perf Flags Add bitmap control for perf context Aug 6, 2021
db/c.cc Outdated Show resolved Hide resolved
@tabokie
Copy link
Member

tabokie commented Aug 6, 2021

@yiwu-arbug Are we running clang-format in CI right now? I wonder how these styling issues go unalerted.

@tabokie
Copy link
Member

tabokie commented Aug 9, 2021

@LemonHX Could you run this line in your repo to format this PR manually? I'm not sure if there's any issues I haven't sighted.

git diff -U0 f95aaf8dac667334bb6314bd06d80749f63177bb | python <(curl https://raw.githubusercontent.com/llvm-mirror/clang/master/tools/clang-format/clang-format-diff.py) -p1 -i

And a few commit signoffs need fixing.

LemonHX and others added 3 commits August 11, 2021 08:27
fix indentation error in `c.cc`
adding comment on `FLAG_END`
explain what does `& 0b111` does
fix a huge mistake in `CheckPerfFlag`
and writing the edge case tests for `perf_flag`

Signed-off-by: lemonhx <lemonhx@lemonhx.tech>
add test into `Makefile`
and removed unused variable.
fix indentation error in `CMakeLists`

Signed-off-by: lemonhx <lemonhx@lemonhx.tech>
Co-authored-by: Xinye Tao <xy.tao@outlook.com>
Signed-off-by: lemonhx <lemonhx@lemonhx.tech>
Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
Copy link
Member

@tabokie tabokie left a comment

Choose a reason for hiding this comment

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

I've manually resolved all the review comments. LGTM


#define FLAGS_LEN \
(((uint64_t)FLAG_END & (uint64_t)0b111) == 0 \
? ((uint64_t)FLAG_END >> (uint64_t)0b11) \
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
? ((uint64_t)FLAG_END >> (uint64_t)0b11) \
? ((uint64_t)FLAG_END >> (uint64_t)3) \

#define FLAGS_LEN \
(((uint64_t)FLAG_END & (uint64_t)0b111) == 0 \
? ((uint64_t)FLAG_END >> (uint64_t)0b11) \
: ((uint64_t)FLAG_END >> (uint64_t)0b11) + (uint64_t)1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
: ((uint64_t)FLAG_END >> (uint64_t)0b11) + (uint64_t)1)
: ((uint64_t)FLAG_END >> (uint64_t)3) + (uint64_t)1)

Signed-off-by: tabokie <xy.tao@outlook.com>
Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@tabokie tabokie merged commit 3de4cc2 into tikv:6.4.tikv Aug 13, 2021
tabokie pushed a commit that referenced this pull request Apr 2, 2022
This PR changes some bits of #237.

Considering our use cases in TiKV, _although not really necessary_, we frequently set perf levels around RocksDB operations. So, if we switch to perf flags, it requires us to set perf flags efficiently. And we have quite a few flags to set, setting flags one by one in #237 is not that efficient. 

All flags can be saved in two words. So, we **can** achieve similar efficiency by setting all flags all at once. And meanwhile, we can flexibly specify which metrics we care about at runtime.

This PR also changes to use `std::bitset` and a named enum instead of handmade int array and anonymous enum. Hopefully they will make the code cleaner.

See tikv/rust-rocksdb#682 for the companion Rust wrapper

Signed-off-by: Yilin Chen <sticnarf@gmail.com>
@tabokie tabokie mentioned this pull request May 9, 2022
39 tasks
tabokie added a commit to tabokie/rocksdb that referenced this pull request May 11, 2022
* `PerfFlag` implementation aside the `PerfLevel`
design spec in on: https://docs.google.com/document/d/1JYmWMIZwYV0AZW6rNv_oFVZLBCAkxLLYslt39eEZstM/edit?usp=sharing

Signed-off-by: lemonhx <lemonhx@lemonhx.tech>
Co-authored-by: Xinye Tao <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
tabokie pushed a commit to tabokie/rocksdb that referenced this pull request May 11, 2022
This PR changes some bits of tikv#237.

Considering our use cases in TiKV, _although not really necessary_, we frequently set perf levels around RocksDB operations. So, if we switch to perf flags, it requires us to set perf flags efficiently. And we have quite a few flags to set, setting flags one by one in tikv#237 is not that efficient.

All flags can be saved in two words. So, we **can** achieve similar efficiency by setting all flags all at once. And meanwhile, we can flexibly specify which metrics we care about at runtime.

This PR also changes to use `std::bitset` and a named enum instead of handmade int array and anonymous enum. Hopefully they will make the code cleaner.

See tikv/rust-rocksdb#682 for the companion Rust wrapper

Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
tabokie added a commit that referenced this pull request May 11, 2022
* `PerfFlag` implementation aside the `PerfLevel`
design spec in on: https://docs.google.com/document/d/1JYmWMIZwYV0AZW6rNv_oFVZLBCAkxLLYslt39eEZstM/edit?usp=sharing

Signed-off-by: lemonhx <lemonhx@lemonhx.tech>
Co-authored-by: Xinye Tao <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
tabokie pushed a commit that referenced this pull request May 11, 2022
This PR changes some bits of #237.

Considering our use cases in TiKV, _although not really necessary_, we frequently set perf levels around RocksDB operations. So, if we switch to perf flags, it requires us to set perf flags efficiently. And we have quite a few flags to set, setting flags one by one in #237 is not that efficient.

All flags can be saved in two words. So, we **can** achieve similar efficiency by setting all flags all at once. And meanwhile, we can flexibly specify which metrics we care about at runtime.

This PR also changes to use `std::bitset` and a named enum instead of handmade int array and anonymous enum. Hopefully they will make the code cleaner.

See tikv/rust-rocksdb#682 for the companion Rust wrapper

Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
v01dstar pushed a commit to v01dstar/rocksdb that referenced this pull request Feb 8, 2024
* `PerfFlag` implementation aside the `PerfLevel`
design spec in on: https://docs.google.com/document/d/1JYmWMIZwYV0AZW6rNv_oFVZLBCAkxLLYslt39eEZstM/edit?usp=sharing

Signed-off-by: lemonhx <lemonhx@lemonhx.tech>
Co-authored-by: Xinye Tao <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
v01dstar pushed a commit to v01dstar/rocksdb that referenced this pull request Feb 8, 2024
This PR changes some bits of tikv#237.

Considering our use cases in TiKV, _although not really necessary_, we frequently set perf levels around RocksDB operations. So, if we switch to perf flags, it requires us to set perf flags efficiently. And we have quite a few flags to set, setting flags one by one in tikv#237 is not that efficient.

All flags can be saved in two words. So, we **can** achieve similar efficiency by setting all flags all at once. And meanwhile, we can flexibly specify which metrics we care about at runtime.

This PR also changes to use `std::bitset` and a named enum instead of handmade int array and anonymous enum. Hopefully they will make the code cleaner.

See tikv/rust-rocksdb#682 for the companion Rust wrapper

Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
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.

5 participants