Skip to content

Commit

Permalink
skip the wait in rate limiter in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
critical27 committed Sep 6, 2021
1 parent 4d04c15 commit d469631
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
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

0 comments on commit d469631

Please sign in to comment.