Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache contract id (and other frequent objects) in host #681

Open
graydon opened this issue Feb 9, 2023 · 4 comments
Open

Cache contract id (and other frequent objects) in host #681

graydon opened this issue Feb 9, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@graydon
Copy link
Contributor

graydon commented Feb 9, 2023

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 Objects 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.

@graydon
Copy link
Contributor Author

graydon commented Feb 16, 2023

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.

@graydon
Copy link
Contributor Author

graydon commented Feb 16, 2023

(we should still cache the contract ID, probably)

@graydon graydon changed the title Cache contract id as object -- possibly use ubiquitous interning Cache contract id as object Feb 16, 2023
@graydon
Copy link
Contributor Author

graydon commented Mar 9, 2023

Should probably also cache a variety of continuously-reused symbols and event-topic-vectors-containing-just-those-symbols.

@graydon graydon changed the title Cache contract id as object Cache contract id (and other frequent objects) in host Mar 9, 2023
@anupsdf
Copy link
Contributor

anupsdf commented Jun 22, 2023

Discussed with @graydon and this can move to post V1 launch if we run out of time to get this done for v1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@graydon @anupsdf and others