Skip to content

Commit

Permalink
Rename 'initial_repl_sleep_delay' to 'initial_repl_sleep_delay_usec'
Browse files Browse the repository at this point in the history
  • Loading branch information
arosh committed Jan 29, 2024
1 parent 36f6e2d commit 47776d4
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ These options are to configure memcache protocol:
Objects larger than this will be stored in temporary files.
* `repl_buffer_size` (Default: 30)
The replication buffer size. Unit is MiB.
* `initial_repl_sleep_delay` (Default: 0)
* `initial_repl_sleep_delay_usec` (Default: 0)
Slow down the scan of the entire hash by the GC thread to prevent errors with the message "Replication buffer is full." during the initial replication. The GC thread sleeps for the time specified here for each scan of the hash bucket. Unit is microseconds.
* `secure_erase` (Default: false)
If `true`, object memory will be cleared as soon as the object is removed.
Expand Down
2 changes: 1 addition & 1 deletion etc/yrmcds.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ repl_buffer_size = 30
# errors with the message "Replication buffer is full." during the initial
# replication. The GC thread sleeps for the time specified here for each
# scan of the hash bucket. Unit is microseconds.
initial_repl_sleep_delay = 0
initial_repl_sleep_delay_usec = 0

# Clear memory used by deleted or expired objects securely.
# This ensures confidential data such as crypto keys will not be
Expand Down
8 changes: 4 additions & 4 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const char MAX_DATA_SIZE[] = "max_data_size";
const char HEAP_DATA_LIMIT[] = "heap_data_limit";
const char MEMORY_LIMIT[] = "memory_limit";
const char REPL_BUFSIZE[] = "repl_buffer_size";
const char INITIAL_REPL_SLEEP_DELAY[] = "initial_repl_sleep_delay";
const char INITIAL_REPL_SLEEP_DELAY_USEC[] = "initial_repl_sleep_delay_usec";
const char SECURE_ERASE[] = "secure_erase";
const char LOCK_MEMORY[] = "lock_memory";
const char WORKERS[] = "workers";
Expand Down Expand Up @@ -207,9 +207,9 @@ void config::load(const std::string& path) {
m_repl_bufsize = bufs;
}

if( cp.exists(INITIAL_REPL_SLEEP_DELAY) ) {
std::uint64_t n = cp.get_as_uint64(INITIAL_REPL_SLEEP_DELAY);
m_initial_repl_sleep_delay = n;
if( cp.exists(INITIAL_REPL_SLEEP_DELAY_USEC) ) {
std::uint64_t n = cp.get_as_uint64(INITIAL_REPL_SLEEP_DELAY_USEC);
m_initial_repl_sleep_delay_usec = n;
}

if( cp.exists(SECURE_ERASE) ) {
Expand Down
6 changes: 3 additions & 3 deletions src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class config {
unsigned int repl_bufsize() const noexcept {
return m_repl_bufsize;
}
std::uint64_t initial_repl_sleep_delay() const noexcept {
return m_initial_repl_sleep_delay;
std::uint64_t initial_repl_sleep_delay_usec() const noexcept {
return m_initial_repl_sleep_delay_usec;
}
bool secure_erase() const noexcept {
return m_secure_erase;
Expand Down Expand Up @@ -155,7 +155,7 @@ class config {
std::size_t m_heap_data_limit = DEFAULT_HEAP_DATA_LIMIT;
std::size_t m_memory_limit = DEFAULT_MEMORY_LIMIT;
unsigned int m_repl_bufsize = DEFAULT_REPL_BUFSIZE;
uint64_t m_initial_repl_sleep_delay = DEFAULT_INITIAL_REPL_SLEEP_DELAY;
uint64_t m_initial_repl_sleep_delay_usec = DEFAULT_INITIAL_REPL_SLEEP_DELAY_USEC;
bool m_secure_erase = false;
bool m_lock_memory = false;
unsigned int m_workers = DEFAULT_WORKER_THREADS;
Expand Down
2 changes: 1 addition & 1 deletion src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const std::size_t DEFAULT_MAX_DATA_SIZE = static_cast<std::size_t>(1) << 20;
const std::size_t DEFAULT_HEAP_DATA_LIMIT= 256 << 10;
const std::size_t DEFAULT_MEMORY_LIMIT = static_cast<std::size_t>(1) << 30;
const unsigned int DEFAULT_REPL_BUFSIZE = 30;
const std::uint64_t DEFAULT_INITIAL_REPL_SLEEP_DELAY = 0;
const std::uint64_t DEFAULT_INITIAL_REPL_SLEEP_DELAY_USEC = 0;
const int DEFAULT_WORKER_THREADS = 8;
const unsigned int DEFAULT_GC_INTERVAL = 10;
const unsigned int DEFAULT_SLAVE_TIMEOUT = 10;
Expand Down
4 changes: 2 additions & 2 deletions src/memcache/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void gc_thread::gc() {
};

// Putting the thread to sleep tens of microseconds with each loop is desired, but due to the precision of the timer,
// it's not appropriate to do sleep with each loop. The `initial_repl_sleep_delay` is accumulated until it
// it's not appropriate to sleep with each loop. The `initial_repl_sleep_delay_usec` is accumulated until it
// exceeds 10000 microseconds (10 milliseconds), and then the thread is put to sleep all at once when this limit is exceeded.
const std::uint64_t SLEEP_THRESHOLD = 10000;
std::uint64_t sleep_sum = 0;
Expand All @@ -134,7 +134,7 @@ void gc_thread::gc() {
m_flushers.clear();

if( ! m_new_slaves.empty() ) {
sleep_sum += g_config.initial_repl_sleep_delay();
sleep_sum += g_config.initial_repl_sleep_delay_usec();
if( sleep_sum >= SLEEP_THRESHOLD ) {
std::this_thread::sleep_for(
std::chrono::microseconds(sleep_sum));
Expand Down
2 changes: 1 addition & 1 deletion test/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AUTOTEST(config) {
cybozu_assert(g_config.group() == "nogroup");
cybozu_assert(g_config.memory_limit() == (1024 << 20));
cybozu_assert(g_config.repl_bufsize() == 100);
cybozu_assert(g_config.initial_repl_sleep_delay() == 40);
cybozu_assert(g_config.initial_repl_sleep_delay_usec() == 40);
cybozu_assert(g_config.secure_erase() == true);
cybozu_assert(g_config.lock_memory() == true);
cybozu_assert(g_config.threshold() == cybozu::severity::warning);
Expand Down
2 changes: 1 addition & 1 deletion test/test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ max_data_size = 5M
heap_data_limit = 16K
memory_limit = 1024M
repl_buffer_size= 100
initial_repl_sleep_delay = 40
initial_repl_sleep_delay_usec = 40
secure_erase = true
lock_memory = true
workers = 10
Expand Down

0 comments on commit 47776d4

Please sign in to comment.