StableBTreeMap in Canisters

Well done!
I also recently tried to use StableBTreeMap in canister and it works very well.

Someone did a benchmark test of storing to stable memory and wasm heap, they are basically the same: GitHub - aewc/balance at bench

But when it comes to some complex requirements, it gets a little tricky.
My canister has several data structures, including some fixed-length data, dynamically growing Vectors and Maps. In this way, it is more troublesome to divide the stable memory in advance. For example, I divide 1GB for A, 2GB for B, 1GB for C, and finally D, etc.

This will cause a problem that even if the entire canister has no state at the beginning, it needs to occupy at least 4GB of stable memory. The most important thing is that after these fixed quotas are used up in the future, they need to be redistributed.

The reason for this is that StableBTreeMap is implemented based on Vec, and a StableBTreeMap must occupy the entire contiguous memory space. If StableBTreeMap can be implemented based on List, then in the same continuous memory space, A, B, C, D can be stored alternately.

Considering that the existing StableBTreeMap has been carefully designed and extensively tested, another option is to map contiguous Vecs to Lists.