This commit is contained in:
zenground0
2023-07-13 08:41:34 -06:00
parent 6eadc0ee57
commit 38b21a713a
2 changed files with 15 additions and 8 deletions
+3 -3
View File
@@ -47,13 +47,13 @@ func (t *AMTRoot) MarshalCBOR(w io.Writer) error {
// t.BitWidth (uint64) (uint64)
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.BitWidth)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, t.BitWidth); err != nil {
return err
}
// t.Height (uint64) (uint64)
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Height)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, t.Height); err != nil {
return err
}
@@ -132,7 +132,7 @@ func (t *AMTRoot) UnmarshalCBOR(r io.Reader) (err error) {
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Count = uint64(extra)
t.Count = extra
}
// t.AMTNode (internal.AMTNode) (struct)
+12 -5
View File
@@ -180,11 +180,11 @@ func (asc *amtStatCollector) record(ctx context.Context, nd format.Node) error {
if link {
asc.totalAMTLinks += len(node.Links)
asc.totalAMTLinkNodes += 1
asc.totalAMTLinkNodes++
asc.totalAMTLinkNodeSize += int(size)
} else if value {
asc.totalAMTValues += len(node.Values)
asc.totalAMTValueNodes += 1
asc.totalAMTValueNodes++
asc.totalAMTValueNodeSize += int(size)
} else {
return xerrors.Errorf("unexpected AMT node %x: neither link nor value", nd.RawData())
@@ -230,6 +230,11 @@ var amtBenchCmd = &cli.Command{
Usage: "AMT idx interval for churning values",
Value: 2880,
},
&cli.IntFlag{
Name: "bitwidth",
Usage: "AMT bitwidth",
Value: 6,
},
},
Action: func(c *cli.Context) error {
bs := blockstore.NewMemory()
@@ -237,7 +242,7 @@ var amtBenchCmd = &cli.Command{
store := adt.WrapStore(ctx, cbor.NewCborStore(bs))
// Setup in memory blockstore
const bitwidth = 6
bitwidth := c.Int("bitwidth")
array, err := adt.MakeEmptyArray(store, bitwidth)
if err != nil {
return err
@@ -247,12 +252,14 @@ var amtBenchCmd = &cli.Command{
// Create 40,000,000 states for realistic workload
fmt.Printf("Populating AMT\n")
for i := 0; i < 40000000; i++ {
array.Set(uint64(i), &market.DealState{
if err := array.Set(uint64(i), &market.DealState{
SectorStartEpoch: abi.ChainEpoch(2000000 + i),
LastUpdatedEpoch: abi.ChainEpoch(-1),
SlashEpoch: -1,
VerifiedClaim: verifreg.AllocationId(i),
})
}); err != nil {
return err
}
}
r, err := array.Root()