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

Make Entry and OpenEntry a struct? #84

Open
homonoidian opened this issue Jan 6, 2023 · 1 comment
Open

Make Entry and OpenEntry a struct? #84

homonoidian opened this issue Jan 6, 2023 · 1 comment
Assignees

Comments

@homonoidian
Copy link
Collaborator

I have no idea whether this would have any effect on performance at all, but it would definitely be entertaining to see. Technically, I think this is possible by storing a reference to the dictionary that holds the entry inside that entry. If I remember correctly, the only reason I created the Entry object at all is (a) for tagging opener/pusher & consequent polymorphic on_open etc., and (b) to save on lookups during submit without having to handwrite custom submit lookup method (in a very naive implementation, we'd have to have two lookups: one to find out whether the entry exists, and another to store).

A tiny benchmark would be nice, will put it here before everything.

@homonoidian homonoidian self-assigned this Jan 6, 2023
@homonoidian
Copy link
Collaborator Author

The thing is actually slower because Crystal's hash methods are clumsy for this particular use case. To make use of the struct entries, we have to first find that struct entry in the dictionary, and then to submit to it, we have to again find it (Hash(K, V)#update and Hash(K, V)#[]=) and only then write.

As with everything, this could be resolved by writing a custom hash table implementation. Maybe, maybe not. I'm not in the mood of doing this -- there are much more interesting Substrate and Tape optimizations coming (hopefully!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant