Add benchmark tests and optimize database performance
- Introduced benchmark tests for various database operations, including event saving, querying, and fetching by serials, to assess performance. - Implemented optimizations to reduce memory allocations and improve efficiency by pre-allocating slices and maps in critical functions. - Enhanced the `FetchEventsBySerials`, `GetFullIdPubkeyBySerials`, and `QueryForIds` methods with pre-allocation strategies to minimize reallocations. - Documented performance improvements in the new PERFORMANCE_REPORT.md file, highlighting significant reductions in execution time and memory usage. - Bumped version to v0.23.1 to reflect these changes.
This commit is contained in:
@@ -13,6 +13,8 @@ import (
|
||||
func (d *D) GetSerialsByRange(idx Range) (
|
||||
sers types.Uint40s, err error,
|
||||
) {
|
||||
// Pre-allocate slice with estimated capacity to reduce reallocations
|
||||
sers = make(types.Uint40s, 0, 100) // Estimate based on typical range sizes
|
||||
if err = d.View(
|
||||
func(txn *badger.Txn) (err error) {
|
||||
it := txn.NewIterator(
|
||||
|
||||
Reference in New Issue
Block a user