add debug log skeleton
This commit is contained in:
parent
0390285c4e
commit
fc247e4223
53
blockstore/splitstore/debug.go
Normal file
53
blockstore/splitstore/debug.go
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package splitstore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
|
blocks "github.com/ipfs/go-block-format"
|
||||||
|
cid "github.com/ipfs/go-cid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type debugLog struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *debugLog) LogReadMiss(cid cid.Cid) {
|
||||||
|
if d == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *debugLog) LogWrite(curTs *types.TipSet, blk blocks.Block, writeEpoch abi.ChainEpoch) {
|
||||||
|
if d == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *debugLog) LogWriteMany(curTs *types.TipSet, blks []blocks.Block, writeEpoch abi.ChainEpoch) {
|
||||||
|
if d == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *debugLog) LogMove(curTs *types.TipSet, cid cid.Cid, writeEpoch abi.ChainEpoch) {
|
||||||
|
if d == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *debugLog) Close() error {
|
||||||
|
if d == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
}
|
@ -136,6 +136,8 @@ type SplitStore struct {
|
|||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancel func()
|
cancel func()
|
||||||
|
|
||||||
|
debug *debugLog
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ bstore.Blockstore = (*SplitStore)(nil)
|
var _ bstore.Blockstore = (*SplitStore)(nil)
|
||||||
@ -203,9 +205,12 @@ func (s *SplitStore) Get(cid cid.Cid) (blocks.Block, error) {
|
|||||||
return blk, nil
|
return blk, nil
|
||||||
|
|
||||||
case bstore.ErrNotFound:
|
case bstore.ErrNotFound:
|
||||||
|
s.debug.LogReadMiss(cid)
|
||||||
|
|
||||||
blk, err = s.cold.Get(cid)
|
blk, err = s.cold.Get(cid)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
|
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
|
||||||
|
|
||||||
}
|
}
|
||||||
return blk, err
|
return blk, err
|
||||||
|
|
||||||
@ -222,6 +227,8 @@ func (s *SplitStore) GetSize(cid cid.Cid) (int, error) {
|
|||||||
return size, nil
|
return size, nil
|
||||||
|
|
||||||
case bstore.ErrNotFound:
|
case bstore.ErrNotFound:
|
||||||
|
s.debug.LogReadMiss(cid)
|
||||||
|
|
||||||
size, err = s.cold.GetSize(cid)
|
size, err = s.cold.GetSize(cid)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
|
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
|
||||||
@ -240,6 +247,7 @@ func (s *SplitStore) Put(blk blocks.Block) error {
|
|||||||
return s.cold.Put(blk)
|
return s.cold.Put(blk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curTs := s.curTs
|
||||||
epoch := s.writeEpoch
|
epoch := s.writeEpoch
|
||||||
s.mx.Unlock()
|
s.mx.Unlock()
|
||||||
|
|
||||||
@ -249,6 +257,8 @@ func (s *SplitStore) Put(blk blocks.Block) error {
|
|||||||
return s.cold.Put(blk)
|
return s.cold.Put(blk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.debug.LogWrite(curTs, blk, epoch)
|
||||||
|
|
||||||
return s.hot.Put(blk)
|
return s.hot.Put(blk)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,6 +269,7 @@ func (s *SplitStore) PutMany(blks []blocks.Block) error {
|
|||||||
return s.cold.PutMany(blks)
|
return s.cold.PutMany(blks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curTs := s.curTs
|
||||||
epoch := s.writeEpoch
|
epoch := s.writeEpoch
|
||||||
s.mx.Unlock()
|
s.mx.Unlock()
|
||||||
|
|
||||||
@ -273,6 +284,8 @@ func (s *SplitStore) PutMany(blks []blocks.Block) error {
|
|||||||
return s.cold.PutMany(blks)
|
return s.cold.PutMany(blks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.debug.LogWriteMany(curTs, blks, epoch)
|
||||||
|
|
||||||
return s.hot.PutMany(blks)
|
return s.hot.PutMany(blks)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,6 +332,8 @@ func (s *SplitStore) View(cid cid.Cid, cb func([]byte) error) error {
|
|||||||
err := s.hot.View(cid, cb)
|
err := s.hot.View(cid, cb)
|
||||||
switch err {
|
switch err {
|
||||||
case bstore.ErrNotFound:
|
case bstore.ErrNotFound:
|
||||||
|
s.debug.LogReadMiss(cid)
|
||||||
|
|
||||||
err = s.cold.View(cid, cb)
|
err = s.cold.View(cid, cb)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
|
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
|
||||||
@ -411,6 +426,7 @@ func (s *SplitStore) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.cancel()
|
s.cancel()
|
||||||
|
s.debug.Close()
|
||||||
return multierr.Combine(s.tracker.Close(), s.env.Close())
|
return multierr.Combine(s.tracker.Close(), s.env.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,6 +800,9 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
|
|||||||
// it's cold, mark it for move
|
// it's cold, mark it for move
|
||||||
cold = append(cold, cid)
|
cold = append(cold, cid)
|
||||||
coldCnt++
|
coldCnt++
|
||||||
|
|
||||||
|
s.debug.LogMove(curTs, cid, writeEpoch)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user