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

skip the wait in rate limiter in CI #2795

Merged
merged 3 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/kvstore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ nebula_add_library(
RocksEngineConfig.cpp
LogEncoder.cpp
NebulaSnapshotManager.cpp
RateLimiter.cpp
plugins/elasticsearch/ESListener.cpp
)

Expand Down
11 changes: 11 additions & 0 deletions src/kvstore/RateLimiter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License,
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#include "kvstore/RateLimiter.h"

DEFINE_bool(skip_wait_in_rate_limiter,
false,
"skip the waiting of first second in rate limiter in CI");
8 changes: 6 additions & 2 deletions src/kvstore/RateLimiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "common/thrift/ThriftTypes.h"
#include "common/time/WallClock.h"

DECLARE_bool(skip_wait_in_rate_limiter);

namespace nebula {
namespace kvstore {

Expand All @@ -27,7 +29,8 @@ class RateLimiter {
DCHECK(buckets_.find({spaceId, partId}) == buckets_.end());
// token will be available after 1 second, to prevent speed spike at the beginning
auto now = time::WallClock::fastNowInSec();
folly::TokenBucket bucket(rate_, burstSize_, static_cast<double>(now + 1));
int64_t waitInSec = FLAGS_skip_wait_in_rate_limiter ? 0 : 1;
folly::TokenBucket bucket(rate_, burstSize_, static_cast<double>(now + waitInSec));
buckets_.emplace(std::make_pair(spaceId, partId), std::move(bucket));
}

Expand All @@ -40,7 +43,8 @@ class RateLimiter {
// Caller must make sure the **the parition has been add, and won't be removed during consume.**
// Snaphot and rebuild index follow this principle by design.
void consume(GraphSpaceID spaceId, PartitionID partId, size_t toConsume) {
DCHECK(buckets_.find({spaceId, partId}) != buckets_.end());
// todo(doodle): enable this DCHECK later
// DCHECK(buckets_.find({spaceId, partId}) != buckets_.end());
auto iter = buckets_.find({spaceId, partId});
if (iter != buckets_.end()) {
if (toConsume > burstSize_) {
Expand Down
1 change: 1 addition & 0 deletions tests/common/nebula_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def _format_nebula_command(self, name, meta_port, ports, debug_log=True):
if name == 'storaged':
params.append('--local_config=false')
params.append('--raft_heartbeat_interval_secs=30')
params.append('--skip_wait_in_rate_limiter=true')
if debug_log:
params.append('--v=4')
param_format = " ".join(params)
Expand Down