Skip to content

Commit d93216f

Browse files
author
wuxianrong
committed
Revert "braft Performance optimization"
This reverts commit 7ad42a2.
1 parent 7ad42a2 commit d93216f

10 files changed

Lines changed: 86 additions & 577 deletions

File tree

conf/pika.conf

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -656,35 +656,11 @@ raft-peers :
656656
# Raft election timeout in milliseconds
657657
# This is the time to wait before starting a new election if no heartbeat is received
658658
# A larger value reduces the chance of unnecessary elections but increases failover time
659-
# Optimized default: 300ms (for faster failover, was 1000ms)
660-
# Range: 100-5000ms, Recommended: 300-500ms for LAN
661-
raft-election-timeout-ms : 300
659+
# Default value is 1000ms (1 second)
660+
raft-election-timeout-ms : 1000
662661

663662
# Raft snapshot interval in seconds
664663
# This determines how often Raft takes snapshots of the state machine
665664
# Snapshots are used to compact the log and speed up node recovery
666665
# Default value is 3600 seconds (1 hour)
667666
raft-snapshot-interval-s : 3600
668-
669-
## Raft Performance Tuning (批处理性能优化)
670-
671-
# Enable request batching for better throughput
672-
# When enabled, multiple client requests are batched into a single Raft log entry
673-
# This significantly reduces Raft consensus overhead
674-
# Default: yes (enabled for optimal performance)
675-
raft-enable-batching : yes
676-
677-
# Batch timeout in milliseconds
678-
# How long to wait before flushing a batch (if max-batch-size not reached)
679-
# Lower values = lower latency but less batching benefit
680-
# Higher values = more batching but higher P99 latency
681-
# Range: 1-10ms, Recommended: 2-5ms
682-
# Default: 2ms
683-
raft-batch-timeout-ms : 2
684-
685-
# Maximum number of requests in a single batch
686-
# When this limit is reached, the batch is flushed immediately
687-
# Higher values = more batching but higher memory usage
688-
# Range: 100-10000, Recommended: 500-2000
689-
# Default: 1000
690-
raft-max-batch-size : 1000

include/pika_conf.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -906,20 +906,6 @@ class PikaConf : public pstd::BaseConf {
906906
return raft_snapshot_interval_s_;
907907
}
908908

909-
// Raft 性能优化相关配置
910-
bool raft_enable_batching() {
911-
std::shared_lock l(rwlock_);
912-
return raft_enable_batching_;
913-
}
914-
int raft_batch_timeout_ms() {
915-
std::shared_lock l(rwlock_);
916-
return raft_batch_timeout_ms_;
917-
}
918-
int raft_max_batch_size() {
919-
std::shared_lock l(rwlock_);
920-
return raft_max_batch_size_;
921-
}
922-
923909
int Load();
924910
int ConfigRewrite();
925911
int ConfigRewriteSlaveOf();
@@ -1107,13 +1093,8 @@ class PikaConf : public pstd::BaseConf {
11071093
bool raft_enabled_ = false;
11081094
std::string raft_group_id_;
11091095
std::string raft_peers_;
1110-
int raft_election_timeout_ms_ = 300; // 优化后的默认值:300ms
1096+
int raft_election_timeout_ms_ = 1000;
11111097
int raft_snapshot_interval_s_ = 3600;
1112-
1113-
// Raft 性能优化配置
1114-
bool raft_enable_batching_ = true; // 启用批处理(默认开启)
1115-
int raft_batch_timeout_ms_ = 2; // 批处理超时:2ms
1116-
int raft_max_batch_size_ = 1000; // 最大批量大小:1000
11171098
};
11181099

11191100
#endif

src/pika_conf.cc

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -717,26 +717,13 @@ int PikaConf::Load() {
717717

718718
GetConfInt("raft-election-timeout-ms", &raft_election_timeout_ms_);
719719
if (raft_election_timeout_ms_ <= 0) {
720-
raft_election_timeout_ms_ = 300; // 优化后的默认值
720+
raft_election_timeout_ms_ = 1000;
721721
}
722722

723723
GetConfInt("raft-snapshot-interval-s", &raft_snapshot_interval_s_);
724724
if (raft_snapshot_interval_s_ <= 0) {
725725
raft_snapshot_interval_s_ = 3600;
726726
}
727-
728-
// Raft 性能优化配置
729-
GetConfBool("raft-enable-batching", &raft_enable_batching_);
730-
731-
GetConfInt("raft-batch-timeout-ms", &raft_batch_timeout_ms_);
732-
if (raft_batch_timeout_ms_ <= 0) {
733-
raft_batch_timeout_ms_ = 2; // 默认 2ms
734-
}
735-
736-
GetConfInt("raft-max-batch-size", &raft_max_batch_size_);
737-
if (raft_max_batch_size_ <= 0) {
738-
raft_max_batch_size_ = 1000; // 默认 1000
739-
}
740727

741728
return ret;
742729
}

src/praft/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ add_dependencies(binlog_pb protobuf)
2121
# Collect all source files (excluding binlog.proto which is in binlog_pb)
2222
aux_source_directory(./src DIR_SRCS)
2323

24-
# Add batch_manager source files explicitly
25-
set(DIR_SRCS ${DIR_SRCS}
26-
${CMAKE_CURRENT_SOURCE_DIR}/batch_manager.cc
27-
)
28-
2924
# Create static library (WITHOUT binlog protobuf sources, link binlog_pb instead)
3025
add_library(praft STATIC ${DIR_SRCS})
3126

src/praft/batch_manager.cc

Lines changed: 0 additions & 191 deletions
This file was deleted.

0 commit comments

Comments
 (0)