Implement batched database operations for improved performance
- Add BatchedDatabaseHandler that batches prefix, ASN, and peering operations - Add BatchedPeerHandler that batches peer update operations - Batch operations are deduped and flushed every 100-200ms or when batch size is reached - Add EnableBatchedDatabaseWrites config option (enabled by default) - Properly flush remaining batches on shutdown - This significantly reduces database write pressure and improves throughput
This commit is contained in:
@@ -24,6 +24,9 @@ type Config struct {
|
||||
|
||||
// MaxRuntime is the maximum runtime (0 = run forever)
|
||||
MaxRuntime time.Duration
|
||||
|
||||
// EnableBatchedDatabaseWrites enables batched database operations for better performance
|
||||
EnableBatchedDatabaseWrites bool
|
||||
}
|
||||
|
||||
// New creates a new Config with default paths based on the OS
|
||||
@@ -34,8 +37,9 @@ func New() (*Config, error) {
|
||||
}
|
||||
|
||||
return &Config{
|
||||
StateDir: stateDir,
|
||||
MaxRuntime: 0, // Run forever by default
|
||||
StateDir: stateDir,
|
||||
MaxRuntime: 0, // Run forever by default
|
||||
EnableBatchedDatabaseWrites: true, // Enable batching by default for better performance
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user