Skip to content

fix: optimize new set implementation and update docs#917

Merged
austinabell merged 3 commits into
masterfrom
austin/set_opt
Sep 23, 2022
Merged

fix: optimize new set implementation and update docs#917
austinabell merged 3 commits into
masterfrom
austin/set_opt

Conversation

@austinabell
Copy link
Copy Markdown
Contributor

There is no benefit to the cache in the set's case, as no APIs depend on it, and since no data loaded, the cache adds more overhead than benefit. This change also removes the Ord and Clone requirements on the set's keys.

Benchmarking these changes are ~15% decrease in gas for a small number of elements, and ~25% for larger amounts of modifications

Copy link
Copy Markdown
Contributor

@itegulov itegulov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarking these changes are ~15% decrease in gas for a small number of elements, and ~25% for larger amounts of modifications

Interesting, would you mind sharing the benchmark source code?

In any case, LGTM and sounds likely that the caching overhead outweighs the benefits from what I remember from the benchmarks I did back in January.

Comment thread near-sdk/src/store/lookup_set/mod.rs Outdated
@austinabell
Copy link
Copy Markdown
Contributor Author

Interesting, would you mind sharing the benchmark source code?

Yeah, was hacked together quickly, and didn't update all the values or point to a git dep, but here it is: austinabell/storage_collections_bench@b3864e3

Co-authored-by: Daniyar Itegulov <ditegulov@gmail.com>
@austinabell austinabell merged commit aa1c1e0 into master Sep 23, 2022
@austinabell austinabell deleted the austin/set_opt branch September 23, 2022 06:59
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

Successfully merging this pull request may close these issues.

2 participants