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:
2025-07-28 01:01:27 +02:00
parent d15a5e91b9
commit 155c08d735
4 changed files with 485 additions and 17 deletions

View File

@@ -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
}