Skip to content

fix tick error! [FATAL /mnt/e/test/timer-benchmarks/src/HashedWheelBu… #8

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ set (GOOGLETEST_PATH ${CMAKE_SOURCE_DIR}/3rd/googletest-1.12.1/googletest)
set (GTEST_ROOT_DIR ${GOOGLETEST_PATH})
set (GBENCH_ROOT_DIR ${CMAKE_SOURCE_DIR}/3rd/benchmark-1.8.2)

# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack_size,16777216")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=8192")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fsanitize=address")

include_directories(
src
${GTEST_ROOT_DIR}
Expand Down
7 changes: 4 additions & 3 deletions src/HashedWheelTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include "Logging.h"

const int WHEEL_SIZE = 512;
const int64_t TICK_DURATION = 100; // milliseconds
const int64_t TIME_UNIT = 10; // 10ms
const int64_t TICK_DURATION = 1; // 确定位置 milliseconds,2个都为1时,精度最高,ms级别
const int64_t TIME_UNIT = 1; // 1 ms 可以理解为精度 tick 数* unit == update持续时间


HashedWheelTimer::HashedWheelTimer()
{
Expand Down Expand Up @@ -97,7 +98,7 @@ int HashedWheelTimer::Update(int64_t now)
int HashedWheelTimer::tick()
{
int64_t deadline = started_at_ + TICK_DURATION * (ticks_ + 1);
int idx = ticks_ % (WHEEL_SIZE - 1);
int idx = ticks_ % (WHEEL_SIZE);
HashedWheelBucket* bucket = wheel_[idx];
std::vector<HashedWheelTimeout*> expired;
bucket->ExpireTimeouts(deadline, expired);
Expand Down
Loading