Skip to content

Commit

Permalink
[exp] Do not populat cross-block cache
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov committed Oct 14, 2024
1 parent 2c5019d commit ed51b55
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions aptos-move/block-executor/src/cross_block_caches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::sync::{
const MAX_STRUCT_NAME_INDEX_MAP_SIZE: usize = 100_000;

/// The maximum size of [CrossBlockModuleCache]. Checked at block boundaries.
#[allow(dead_code)]
const MAX_CROSS_BLOCK_MODULE_CACHE_SIZE: usize = 100_000;

/// A cached environment that can be persisted across blocks. Used by block executor only.
Expand Down Expand Up @@ -87,6 +88,7 @@ struct CrossBlockModuleCacheEntry {

impl CrossBlockModuleCacheEntry {
/// Returns a new valid cache entry. Panics if provided module entry is not verified.
#[allow(dead_code)]
fn new(entry: ModuleCacheEntry) -> Self {
assert!(entry.is_verified());
Self {
Expand Down Expand Up @@ -163,31 +165,31 @@ impl CrossBlockModuleCache {
/// Adds new verified entries from block-level cache to the cross-block cache. Flushes the
/// cache if its size is too large. Should only be called at block end.
pub(crate) fn populate_from_sync_code_cache_at_block_end(
code_cache: &SyncCodeCache<ModuleId, ModuleCacheEntry, ScriptCacheEntry>,
_code_cache: &SyncCodeCache<ModuleId, ModuleCacheEntry, ScriptCacheEntry>,
) {
let mut cache = CROSS_BLOCK_MODULE_CACHE.acquire();
if cache.len() > MAX_CROSS_BLOCK_MODULE_CACHE_SIZE {
cache.clear();
}

code_cache.module_cache().filter_into(
cache.dereference_mut(),
|e| e.is_verified(),
|e| CrossBlockModuleCacheEntry::new(e.clone()),
);
// let mut cache = CROSS_BLOCK_MODULE_CACHE.acquire();
// if cache.len() > MAX_CROSS_BLOCK_MODULE_CACHE_SIZE {
// cache.clear();
// }
//
// code_cache.module_cache().filter_into(
// cache.dereference_mut(),
// |e| e.is_verified(),
// |e| CrossBlockModuleCacheEntry::new(e.clone()),
// );
}

/// Same as [Self::populate_from_sync_code_cache_at_block_end], but only used by sequential
/// execution.
pub(crate) fn populate_from_unsync_code_cache_at_block_end(code_cache: &UnsyncCodeCache) {
let mut cache = CROSS_BLOCK_MODULE_CACHE.acquire();
if cache.len() > MAX_CROSS_BLOCK_MODULE_CACHE_SIZE {
cache.clear();
}

code_cache.collect_verified_entries_into(cache.dereference_mut(), |e| {
CrossBlockModuleCacheEntry::new(e.clone())
});
pub(crate) fn populate_from_unsync_code_cache_at_block_end(_code_cache: &UnsyncCodeCache) {
// let mut cache = CROSS_BLOCK_MODULE_CACHE.acquire();
// if cache.len() > MAX_CROSS_BLOCK_MODULE_CACHE_SIZE {
// cache.clear();
// }
//
// code_cache.collect_verified_entries_into(cache.dereference_mut(), |e| {
// CrossBlockModuleCacheEntry::new(e.clone())
// });
}

/// Returns true if the module is stored in cross-block cache and is valid.
Expand Down

0 comments on commit ed51b55

Please sign in to comment.