Skip to content
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

Problem: don't support dependency pre-analysis #13

Merged
merged 8 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion mvmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,35 @@ type MVMemory struct {
func NewMVMemory(
block_size int, stores map[storetypes.StoreKey]int,
storage MultiStore, scheduler *Scheduler,
) *MVMemory {
return NewMVMemoryWithEstimates(block_size, stores, storage, scheduler, nil)
}

func NewMVMemoryWithEstimates(
block_size int, stores map[storetypes.StoreKey]int,
storage MultiStore, scheduler *Scheduler, estimates map[int]MultiLocations,
) *MVMemory {
data := make([]MVStore, len(stores))
for key, i := range stores {
data[i] = NewMVStore(key)
}
return &MVMemory{

mv := &MVMemory{
storage: storage,
scheduler: scheduler,
stores: stores,
data: data,
lastWrittenLocations: make([]atomic.Pointer[MultiLocations], block_size),
lastReadSet: make([]atomic.Pointer[MultiReadSet], block_size),
}

// init with pre-estimates
for txn, est := range estimates {
mv.rcuUpdateWrittenLocations(TxnIndex(txn), est)
mv.ConvertWritesToEstimates(TxnIndex(txn))
}

return mv
}

func (mv *MVMemory) Record(version TxnVersion, view *MultiMVMemoryView) bool {
Expand Down
17 changes: 16 additions & 1 deletion stm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ func ExecuteBlock(
storage MultiStore,
executors int,
txExecutor TxExecutor,
) error {
return ExecuteBlockWithEstimates(
ctx, blockSize, stores, storage, executors,
nil, txExecutor,
)
}

func ExecuteBlockWithEstimates(
ctx context.Context,
blockSize int,
stores map[storetypes.StoreKey]int,
storage MultiStore,
executors int,
estimates map[int]MultiLocations, // txn -> multi-locations
txExecutor TxExecutor,
) error {
if executors < 0 {
return fmt.Errorf("invalid number of executors: %d", executors)
Expand All @@ -27,7 +42,7 @@ func ExecuteBlock(

// Create a new scheduler
scheduler := NewScheduler(blockSize)
mvMemory := NewMVMemory(blockSize, stores, storage, scheduler)
mvMemory := NewMVMemoryWithEstimates(blockSize, stores, storage, scheduler, estimates)

var wg sync.WaitGroup
wg.Add(executors)
Expand Down
Loading