You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds (tagged) blob deduplication support. The main issue it
solves is that all external calls to a motoko canister go through candid
deserialization and blobs passed as arguments end up as fresh blobs on
the motoko heap. Calling multiple times with the same blob as argument
creates multiple copies of the same blob.
To achieve deduplication, this PR does the following:
* in `internals.mo`, it creates a fixed-size hash-table which solves
collisions via chaining.
* sets up a thin RTS interface to set/get the hash-table allocated in
`internals.mo` to be tracked by the RTS layer such that the table is not
garbage collected and it survives upgrades.
* to achieve deduplication, the hash table stores weak references
pointing to the actual objects; once objects are garbage collected, the
weak references will point to null.
* a thin client interface (in `prim.mo`) to walk the hash table and
check which deduplicated blobs are alive/dead and prune the dead ones if
neeed.
0 commit comments