Skip to content

Commit 3d98e82

Browse files
authored
Optimize test_vm get_actor (#585)
* Optimize test_vm get_actor Improves extend_sector_with_deals by 40% Signed-off-by: Jakub Sztandera <[email protected]> * Keep the cache across invocations Gives another 32% Signed-off-by: Jakub Sztandera <[email protected]> Signed-off-by: Jakub Sztandera <[email protected]>
1 parent 9a13081 commit 3d98e82

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test_vm/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,11 @@ impl<'bs> VM<'bs> {
328328
self.store,
329329
)
330330
.unwrap();
331-
actors.get(&addr.to_bytes()).unwrap().cloned()
331+
let actor = actors.get(&addr.to_bytes()).unwrap().cloned();
332+
actor.iter().for_each(|a| {
333+
self.actors_cache.borrow_mut().insert(addr, a.clone());
334+
});
335+
actor
332336
}
333337

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

351-
// roll "back" to latest head, flushing cache
352-
self.rollback(actors.flush().unwrap());
355+
self.state_root.replace(actors.flush().unwrap());
356+
self.actors_dirty.replace(false);
353357
*self.state_root.borrow()
354358
}
355359

0 commit comments

Comments
 (0)