Skip to content

Commit

Permalink
Optimize test_vm get_actor (#585)
Browse files Browse the repository at this point in the history
* Optimize test_vm get_actor

Improves extend_sector_with_deals by 40%

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>

* Keep the cache across invocations

Gives another 32%

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
  • Loading branch information
Jakub Sztandera authored Aug 29, 2022
1 parent 9a13081 commit 3d98e82
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test_vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,11 @@ impl<'bs> VM<'bs> {
self.store,
)
.unwrap();
actors.get(&addr.to_bytes()).unwrap().cloned()
let actor = actors.get(&addr.to_bytes()).unwrap().cloned();
actor.iter().for_each(|a| {
self.actors_cache.borrow_mut().insert(addr, a.clone());
});
actor
}

// blindly overwrite the actor at this address whether it previously existed or not
Expand All @@ -348,8 +352,8 @@ impl<'bs> VM<'bs> {
actors.set(addr.to_bytes().into(), act.clone()).unwrap();
}

// roll "back" to latest head, flushing cache
self.rollback(actors.flush().unwrap());
self.state_root.replace(actors.flush().unwrap());
self.actors_dirty.replace(false);
*self.state_root.borrow()
}

Expand Down

0 comments on commit 3d98e82

Please sign in to comment.