satellite: use more optimal monkit call for loop observers methods
Recently we applied this optimization to metrics observer and time used by its method dropped from 12m to 3m for us1 (220m segments). It looks that it make sense to apply the same code to all observers. Change-Id: I05898aaacbd9bcdf21babc7be9955da1db57bdf2
This commit is contained in:
parent
c5edf77237
commit
7a2d2a36ca
@ -115,6 +115,8 @@ func (service *Service) Tally(ctx context.Context) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var remoteSegmentFunc = mon.Func()
|
||||
|
||||
var _ segmentloop.Observer = (*Observer)(nil)
|
||||
|
||||
// Observer observes metainfo and adds up tallies for nodes and buckets.
|
||||
@ -141,8 +143,8 @@ func (observer *Observer) LoopStarted(context.Context, segmentloop.LoopInfo) (er
|
||||
}
|
||||
|
||||
// RemoteSegment is called for each remote segment.
|
||||
func (observer *Observer) RemoteSegment(ctx context.Context, segment *segmentloop.Segment) (err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
func (observer *Observer) RemoteSegment(ctx context.Context, segment *segmentloop.Segment) error {
|
||||
defer remoteSegmentFunc.Task(&ctx)(nil) // method always returns nil
|
||||
|
||||
if segment.Expired(observer.now) {
|
||||
return nil
|
||||
|
@ -16,6 +16,8 @@ import (
|
||||
"storj.io/storj/satellite/metabase/segmentloop"
|
||||
)
|
||||
|
||||
var remoteSegmentFunc = mon.Func()
|
||||
|
||||
var _ segmentloop.Observer = (*PieceTracker)(nil)
|
||||
|
||||
// PieceTracker implements the metainfo loop observer interface for garbage collection.
|
||||
@ -52,8 +54,8 @@ func (pieceTracker *PieceTracker) LoopStarted(ctx context.Context, info segmentl
|
||||
}
|
||||
|
||||
// RemoteSegment takes a remote segment found in metabase and adds pieces to bloom filters.
|
||||
func (pieceTracker *PieceTracker) RemoteSegment(ctx context.Context, segment *segmentloop.Segment) (err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
func (pieceTracker *PieceTracker) RemoteSegment(ctx context.Context, segment *segmentloop.Segment) error {
|
||||
defer remoteSegmentFunc.Task(&ctx)(nil) // method always returns nil
|
||||
|
||||
deriver := segment.RootPieceID.Deriver()
|
||||
for _, piece := range segment.Pieces {
|
||||
|
@ -15,6 +15,8 @@ import (
|
||||
"storj.io/uplink/private/eestream"
|
||||
)
|
||||
|
||||
var remoteSegmentFunc = mon.Func()
|
||||
|
||||
var _ segmentloop.Observer = (*PathCollector)(nil)
|
||||
|
||||
// PathCollector uses the metainfo loop to add paths to node reservoirs.
|
||||
@ -62,7 +64,7 @@ func (collector *PathCollector) Flush(ctx context.Context) (err error) {
|
||||
|
||||
// RemoteSegment takes a remote segment found in metainfo and creates a graceful exit transfer queue item if it doesn't exist already.
|
||||
func (collector *PathCollector) RemoteSegment(ctx context.Context, segment *segmentloop.Segment) (err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
defer remoteSegmentFunc.Task(&ctx)(&err)
|
||||
|
||||
if len(collector.nodeIDStorage) == 0 {
|
||||
return nil
|
||||
|
@ -168,6 +168,8 @@ func (checker *Checker) IdentifyInjuredSegments(ctx context.Context) (err error)
|
||||
return nil
|
||||
}
|
||||
|
||||
var remoteSegmentFunc = mon.Func()
|
||||
|
||||
var _ segmentloop.Observer = (*checkerObserver)(nil)
|
||||
|
||||
// checkerObserver implements the metainfo loop Observer interface.
|
||||
@ -216,7 +218,7 @@ func (obs *checkerObserver) LoopStarted(context.Context, segmentloop.LoopInfo) (
|
||||
}
|
||||
|
||||
func (obs *checkerObserver) RemoteSegment(ctx context.Context, segment *segmentloop.Segment) (err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
defer remoteSegmentFunc.Task(&ctx)(&err)
|
||||
|
||||
// ignore segment if expired
|
||||
if segment.Expired(time.Now()) {
|
||||
|
Loading…
Reference in New Issue
Block a user