diem / diem/move

[Feature Request] add eviction API's to VM's module and type caches

Open
#18 1 comment 0 reactions 4 assignees Claimed by @vgao1996 View on GitHub
enhancement
Dominant language
Rust
Stars
378
Forks
137
PR merge metrics
No merged PRs in 30d

Description

# Problem

The Move VM keeps a [cache](https://github.com/diem/move/blob/main/language/move-vm/runtime/src/loader.rs#L425) of the modules it has previously deserialized, verified, and linked (and similar for types and scripts). However, there are no API's for removing entries from these caches, nor is there any eviction policy. This means that an instance of the VM is kept alive and continues encountering new modules, these caches will grow without bound and eventually cause memory issues.

This was not an issue in Diem because the set of modules was fixed and VM instances were ephemeral (i.e., the system starts a new VM instance for each block). But other uses of Move may want to use the VM in a different way--e.g., we are considering a system where a server keeps an instance of the VM alive indefinitely, and we expect the server to encounter many different modules.

# Proposed solution

I think we should start with exposing API's that:
1. Return the size of all three caches in bytes
2. Clear all caches

This is rather crude, but these API's will at least allow adapters to prevent the caches from growing beyond `N` bytes.

In time, I can imagine VM config's that allow adapter's specifying various eviction policies (e.g., a LFU cache that drops the long tail of infrequently used modules seems like a sensible one), but I'd rather move forward with something simple for now and use experience/data to help us design something fancier.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.