rs-soroban-env
rs-soroban-env copied to clipboard
Cache contract id (and other frequent objects) in host
We fetch contract IDs as hashes fairly often, which means we're either copying around 32-byte hashes in the host or converting them to 8-byte Object
s that hold handles pointing to bytes in the host object array. That latter approach is ok as far as it goes, but we don't unique those bytes, and we do a fair number of conversions, so it's possible that we're winding up with quite a lot of copies of a given contract ID in the host object array.
We've talked about doing ubiquitous "interning" (forcing host objects to be unique when added to the table) and this is still a bit of a design decision to work through, but it should at least be possible to optionally ask for an object to be added uniquely, to cut down on cases like this.
Decision: we're not going to do ubiquitous interning for now. It penalizes the common case (allocating actually-new objects) in favor of a rarer case (allocating duplicate objects). For objects we know we need to cache a widely-reused value of, we can cache that value.
(we should still cache the contract ID, probably)
Should probably also cache a variety of continuously-reused symbols and event-topic-vectors-containing-just-those-symbols.
Discussed with @graydon and this can move to post V1 launch
if we run out of time to get this done for v1.