-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: unreserve on-demand #2071
Conversation
bf8e10a
to
421ad0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 11 files at r1.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @acud)
pkg/localstore/gc.go, line 47 at r1 (raw file):
// not to overwhelm the cache with too many chunks which it will flush // anyway. reserveCollectionRatio = 0.5
this should be more like 10% max
pkg/localstore/gc_test.go, line 1017 at r1 (raw file):
}) db.SetUnreserveFunc(unres) fmt.Println(1)
debug code
pkg/postage/batchstore/reserve.go, line 52 at r1 (raw file):
var Capacity = exp2(22) const unreservePage = 50 // how many entries to ask for deletion
what is the purpose of this?
pkg/postage/batchstore/reserve.go, line 73 at r1 (raw file):
// dequeued by the localstore once the storage fills up. func (s *store) unreserve(b *postage.Batch, radius uint8) error { c, err := s.getQueueCardinality()
this need not be peristed in fact. just make sure its a value on s atomically incremented
pkg/postage/batchstore/reserve.go, line 88 at r1 (raw file):
} func (s *store) Unreserve() error {
not sure why this is not an actual iterator. Make it an iterator and you can
- eliminate the page constant,
- get rid of unreserveFunc and its settter
- take onset as a parameter, then you can move pruning to an async routine
pkg/postage/batchstore/reserve.go, line 106 at r1 (raw file):
entries[i] = string(key) i++ if i == unreservePage {
return i==unreserePage, nil
pkg/postage/batchstore/reserve.go, line 114 at r1 (raw file):
return err } for _, v := range entries {
this better be asynchronous and done on demand
pkg/postage/batchstore/reserve.go, line 366 at r1 (raw file):
} func (s *store) getQueueCardinality() (val uint64, err error) {
just needs to be initialised as the the topmost index
pkg/postage/batchstore/reserve.go, line 375 at r1 (raw file):
} func (s *store) putQueueCardinality(val uint64) error {
same
pkg/postage/batchstore/reserve_test.go, line 839 at r1 (raw file):
} func TestUnreserveItemSequence(t *testing.T) {
what is this testing. seems a bit complex
TODO:
|
2c835f9
to
d87d4a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 14 of 14 files at r2.
Reviewable status: all files reviewed, 12 unresolved discussions (waiting on @acud)
pkg/postage/interface.go, line 37 at r2 (raw file):
GetReserveState() *ReserveState SetRadiusSetter(RadiusSetter) Unreserve(UnreserveIteratorFn) error
this should be a nother interface
pkg/postage/batchstore/reserve.go, line 71 at r2 (raw file):
// dequeued by the localstore once the storage fills up. func (s *store) unreserve(b []byte, radius uint8) error { c, err := s.getQueueCardinality()
this can be optimised
pkg/postage/batchstore/mock/store.go, line 143 at r2 (raw file):
return rs } func (bs *BatchStore) Unreserve(_ postage.UnreserveIteratorFn) {
not needed if on a different interface
LGTM when tests pass |
4f71526
to
4c9443b
Compare
0850008
to
628f756
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 8 files at r3, 12 of 12 files at r4.
Reviewable status: all files reviewed, 17 unresolved discussions (waiting on @acud)
pkg/localstore/reserve_test.go, line 302 at r4 (raw file):
t.Fatal(err) } mtx.Lock()
this lock is not needed right?
pkg/localstore/reserve_test.go, line 389 at r4 (raw file):
unres := func(f postage.UnreserveIteratorFn) error { mtx.Lock()
why lock is needed
pkg/node/node.go, line 334 at r4 (raw file):
b.p2pHalter = p2ps var unreserveFn func([]byte, uint8) (uint64, error)
maybe comment here about this black magic going on to make reciprocal dependency painless
pkg/postage/batchstore/reserve.go, line 60 at r4 (raw file):
// would like to guarantee that all chunks are stored Radius uint8 `json:"radius"` StorageRadius uint8 `json:"storageRadius"`
add comment: the current actual radius of eviction/storage
pkg/postage/batchstore/reserve.go, line 110 at r4 (raw file):
v.Radius != swarm.MaxPO+1
this condition is no longer needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 17 unresolved discussions (waiting on @acud and @zelig)
pkg/localstore/gc.go, line 47 at r1 (raw file):
Previously, zelig (Viktor Trón) wrote…
this should be more like 10% max
Done.
pkg/localstore/gc_test.go, line 1017 at r1 (raw file):
Previously, zelig (Viktor Trón) wrote…
debug code
Done.
pkg/localstore/reserve_test.go, line 302 at r4 (raw file):
Previously, zelig (Viktor Trón) wrote…
this lock is not needed right?
race detector
pkg/localstore/reserve_test.go, line 389 at r4 (raw file):
Previously, zelig (Viktor Trón) wrote…
why lock is needed
race detector
pkg/postage/batchstore/reserve.go, line 106 at r1 (raw file):
Previously, zelig (Viktor Trón) wrote…
return i==unreserePage, nil
Done.
pkg/postage/batchstore/reserve.go, line 110 at r4 (raw file):
Previously, zelig (Viktor Trón) wrote…
v.Radius != swarm.MaxPO+1
this condition is no longer needed
Done.
pkg/postage/batchstore/reserve_test.go, line 839 at r1 (raw file):
Previously, zelig (Viktor Trón) wrote…
what is this testing. seems a bit complex
Done.
pkg/postage/batchstore/mock/store.go, line 143 at r2 (raw file):
Previously, zelig (Viktor Trón) wrote…
not needed if on a different interface
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r5.
Reviewable status: all files reviewed, 12 unresolved discussions (waiting on @acud and @zelig)
pkg/postage/batchstore/reserve.go, line 110 at r4 (raw file):
Previously, acud (acud) wrote…
Done.
not done
This reverts commit bbbf43c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 5 files at r8, 12 of 12 files at r9.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @acud and @zelig)
pkg/localstore/localstore.go, line 210 at r9 (raw file):
db = &DB{ stateStore: ss,
why
pkg/node/node.go, line 359 at r9 (raw file):
} fmt.Println("starting bee...")
?
#2040
This change is
TODO:
on batchstore reset we should delete all the fifo queue items(already implicitly done by theReset
method)retrieval protocol has to check postage stamp validity and force cache in case the stamp is invalid