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:
@@ -82,8 +82,8 @@ func (d *D) GetSerialsByIdsWithFilter(
|
||||
) (serials map[string]*types.Uint40, err error) {
|
||||
log.T.F("GetSerialsByIdsWithFilter: input ids count=%d", ids.Len())
|
||||
|
||||
// Initialize the result map
|
||||
serials = make(map[string]*types.Uint40)
|
||||
// Initialize the result map with estimated capacity to reduce reallocations
|
||||
serials = make(map[string]*types.Uint40, ids.Len())
|
||||
|
||||
// Return early if no IDs are provided
|
||||
if ids.Len() == 0 {
|
||||
|
||||
Reference in New Issue
Block a user