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

[metric] fix metric ci #792

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions coverage_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ make -j
export LLVM_PROFILE_FILE="ylt_test-%m.profraw"
ls
cd output
./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize
./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize ./tests/metric_test ./tests/struct_pb_test ./tests/reflection_test
llvm-profdata merge -sparse ylt_test-*.profraw -o ylt_test.profdata
llvm-cov show ./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false
llvm-cov show ./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize ./tests/metric_test ./tests/struct_pb_test ./tests/reflection_test -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false
echo 'Done!!!'
fi
4 changes: 2 additions & 2 deletions include/ylt/metric/metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class static_metric : public metric_t {
};

inline std::chrono::seconds ylt_label_max_age{0};
inline std::chrono::seconds ylt_label_check_expire_duration{0};
inline std::chrono::seconds ylt_label_check_expire_duration{60};

inline std::atomic<int64_t> ylt_metric_capacity = 10000000;
inline int64_t ylt_label_capacity = 20000000;
Expand All @@ -210,7 +210,7 @@ inline void set_label_capacity(int64_t max_label_count) {

inline void set_label_max_age(
std::chrono::seconds max_age,
std::chrono::seconds check_duration = std::chrono::seconds(60 * 10)) {
std::chrono::seconds check_duration = std::chrono::seconds{60}) {
ylt_label_max_age = max_age;
ylt_label_check_expire_duration = check_duration;
}
Expand Down
14 changes: 10 additions & 4 deletions src/metric/benchmark/bench.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ void bench_mixed_impl(IMPL& impl, WRITE_OP&& op, size_t thd_num,
std::string val(36, ' ');
for (size_t i = 0; i < thd_num; i++) {
vec.push_back(std::thread([&, i] {
while (!stop) {
bench_clock_t clock;
bench_clock_t clock_loop;
auto dur = clock.duration<std::chrono::microseconds>();
while (!stop || dur < duration * 2) {
op();
auto t = clock.duration<std::chrono::microseconds>();
lantency_summary.observe(t.count() / 1000.0f);
auto new_dur = clock.duration<std::chrono::microseconds>();
lantency_summary.observe((new_dur - dur).count() / 1000.0f);
dur = new_dur;
}
}));
}
Expand All @@ -55,6 +57,10 @@ void bench_mixed_impl(IMPL& impl, WRITE_OP&& op, size_t thd_num,
} while (clock2.duration() < duration);
auto total_ms = clock.duration();
stop = true;
if constexpr (requires { impl.size(); }) {
std::cout << "size:" << impl.size() << "\n";
}

std::cout << "run " << total_ms.count() << "ms\n";
uint64_t cnt;
double sum;
Expand Down
Loading