add debug log skeleton

This commit is contained in:
vyzo 2021-06-21 15:17:00 +03:00
parent 0390285c4e
commit fc247e4223
2 changed files with 72 additions and 0 deletions

View 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
}

View File

@ -136,6 +136,8 @@ type SplitStore struct {
ctx context.Context
cancel func()
debug *debugLog
}
var _ bstore.Blockstore = (*SplitStore)(nil)
@ -203,9 +205,12 @@ func (s *SplitStore) Get(cid cid.Cid) (blocks.Block, error) {
return blk, nil
case bstore.ErrNotFound:
s.debug.LogReadMiss(cid)
blk, err = s.cold.Get(cid)
if err == nil {
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
}
return blk, err
@ -222,6 +227,8 @@ func (s *SplitStore) GetSize(cid cid.Cid) (int, error) {
return size, nil
case bstore.ErrNotFound:
s.debug.LogReadMiss(cid)
size, err = s.cold.GetSize(cid)
if err == nil {
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)
}
curTs := s.curTs
epoch := s.writeEpoch
s.mx.Unlock()
@ -249,6 +257,8 @@ func (s *SplitStore) Put(blk blocks.Block) error {
return s.cold.Put(blk)
}
s.debug.LogWrite(curTs, blk, epoch)
return s.hot.Put(blk)
}
@ -259,6 +269,7 @@ func (s *SplitStore) PutMany(blks []blocks.Block) error {
return s.cold.PutMany(blks)
}
curTs := s.curTs
epoch := s.writeEpoch
s.mx.Unlock()
@ -273,6 +284,8 @@ func (s *SplitStore) PutMany(blks []blocks.Block) error {
return s.cold.PutMany(blks)
}
s.debug.LogWriteMany(curTs, blks, epoch)
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)
switch err {
case bstore.ErrNotFound:
s.debug.LogReadMiss(cid)
err = s.cold.View(cid, cb)
if err == nil {
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
@ -411,6 +426,7 @@ func (s *SplitStore) Close() error {
}
s.cancel()
s.debug.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
cold = append(cold, cid)
coldCnt++
s.debug.LogMove(curTs, cid, writeEpoch)
return nil
})