Skip to content

Commit

Permalink
Merge pull request #1225 from lightninglabs/universe-sync-limit
Browse files Browse the repository at this point in the history
multi: roll back change in request page size
  • Loading branch information
Roasbeef authored Dec 2, 2024
2 parents 4205556 + 0726ecb commit f7c8789
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/tapcli/universe.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func universeKeys(ctx *cli.Context) error {
ctxc, &unirpc.AssetLeafKeysRequest{
Id: universeID,
Offset: int32(offset),
Limit: universe.MaxPageSize,
Limit: universe.RequestPageSize,
},
)

Expand All @@ -336,7 +336,7 @@ func universeKeys(ctx *cli.Context) error {
assetKeys.AssetKeys = append(
assetKeys.AssetKeys, tempKeys.AssetKeys...,
)
offset += universe.MaxPageSize
offset += universe.RequestPageSize
}

printRespJSON(assetKeys)
Expand Down
4 changes: 2 additions & 2 deletions itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1598,10 +1598,10 @@ func AssertUniverseRootsEqual(a, b *unirpc.AssetRootResponse) bool {
func AssertUniverseStateEqual(t *testing.T, a, b unirpc.UniverseClient) bool {
ctxb := context.Background()

rootsA, err := assetRoots(ctxb, a, universe.MaxPageSize/100)
rootsA, err := assetRoots(ctxb, a, universe.RequestPageSize/100)
require.NoError(t, err)

rootsB, err := assetRoots(ctxb, b, universe.MaxPageSize/100)
rootsB, err := assetRoots(ctxb, b, universe.RequestPageSize/100)
require.NoError(t, err)

return AssertUniverseRootsEqual(rootsA, rootsB)
Expand Down
4 changes: 2 additions & 2 deletions sample-tapd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@
; universe.multiverse-caches.syncer-cache-pre-alloc-size=100000

; The size of the root node page cache for all requests that aren't served by
; the syncer cache. (default: 327680)
; universe.multiverse-caches.root-node-page-cache-size=327680
; the syncer cache. (default: 10240)
; universe.multiverse-caches.root-node-page-cache-size=10240


[address]
Expand Down
8 changes: 4 additions & 4 deletions tapdb/multiverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (b *MultiverseStore) RootNodes(ctx context.Context,
NumOffset: q.Offset,
NumLimit: func() int32 {
if q.Limit == 0 {
return universe.MaxPageSize
return universe.RequestPageSize
}

return q.Limit
Expand Down Expand Up @@ -573,7 +573,7 @@ func (b *MultiverseStore) fillSyncerCache(ctx context.Context) error {
params := sqlc.UniverseRootsParams{
SortDirection: sqlInt16(universe.SortAscending),
NumOffset: 0,
NumLimit: universe.MaxPageSize,
NumLimit: universe.RequestPageSize,
}

allRoots := make(
Expand All @@ -586,9 +586,9 @@ func (b *MultiverseStore) fillSyncerCache(ctx context.Context) error {
}

allRoots = append(allRoots, newRoots...)
params.NumOffset += universe.MaxPageSize
params.NumOffset += universe.RequestPageSize

if len(newRoots) < universe.MaxPageSize {
if len(newRoots) < universe.RequestPageSize {
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion tapdb/multiverse_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func DefaultMultiverseCacheConfig() MultiverseCacheConfig {
LeavesPerUniverse: 50,
SyncerCacheEnabled: false,
SyncerCachePreAllocSize: 100_000,
RootNodePageCacheSize: 20 * universe.MaxPageSize,
RootNodePageCacheSize: 20 * universe.RequestPageSize,
}
}

Expand Down
2 changes: 1 addition & 1 deletion tapdb/universe.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ func mintingKeys(ctx context.Context, dbTx BaseUniverseStore,
NumOffset: q.Offset,
NumLimit: func() int32 {
if q.Limit == 0 {
return universe.MaxPageSize
return universe.RequestPageSize
}

return q.Limit
Expand Down
7 changes: 7 additions & 0 deletions universe/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ const (
// MaxPageSize is the maximum page size that can be used when querying
// for asset roots and leaves.
MaxPageSize = 16384

// RequestPageSize is the default page size that should be used when
// querying for asset roots and leaves.
//
// TODO(guggero): Bump this to the value of MaxPageSize once the
// universe servers have been updated to v0.5.0-rc1 or later.
RequestPageSize = 512
)

// IdentifierKey is the compact representation of a universe identifier that can
Expand Down
2 changes: 1 addition & 1 deletion universe/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

const (
defaultPageSize = int32(MaxPageSize)
defaultPageSize = int32(RequestPageSize)
)

var (
Expand Down

0 comments on commit f7c8789

Please sign in to comment.