-
Notifications
You must be signed in to change notification settings - Fork 127
[tstate] change map[key] from string to fixed size byte array #170
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
1bedeab
884d441
3caa306
a5a957a
e6c8653
1d7c146
c688a54
25e5f28
d8abb92
e6d1a05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ type fetchData struct { | |
|
||
type txData struct { | ||
tx *Transaction | ||
storage map[string][]byte | ||
storage map[[tstate.MapKeyLength]byte][]byte | ||
} | ||
|
||
type Processor struct { | ||
|
@@ -49,11 +49,11 @@ func (p *Processor) Prefetch(ctx context.Context, db Database) { | |
defer span.End() | ||
|
||
// Store required keys for each set | ||
alreadyFetched := make(map[string]*fetchData, len(p.blk.GetTxs())) | ||
alreadyFetched := make(map[[tstate.MapKeyLength]byte]*fetchData, len(p.blk.GetTxs())) | ||
for _, tx := range p.blk.GetTxs() { | ||
storage := map[string][]byte{} | ||
storage := map[[65]byte][]byte{} | ||
for _, k := range tx.StateKeys(sm) { | ||
sk := string(k) | ||
sk := tstate.ToStateKeyArray(k) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if the best middle-ground is just to use the approach in https://pthevenet.com/posts/programming/go/bytesliceindexedmaps/ We then get most of the benefit while retaining flexibility 🤷 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah the flexibility loss isn't worth the gain, working on benchmark a few alternatives including yours, hope to have that soon. |
||
if v, ok := alreadyFetched[sk]; ok { | ||
if v.exists { | ||
storage[sk] = v.v | ||
|
Uh oh!
There was an error while loading. Please reload this page.