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

Optimize unspecialized OrderedSet.init and OrderedSet.firstIndex(of:) #433

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dnadoba
Copy link
Member

@dnadoba dnadoba commented Nov 16, 2024

I have noticed that OrderedSet performance is slower than Dictionary if the Element isn't known at compile time and therefore the compiler can't specialize the implementations.

This PR replaces some of the generic functions that are generic with manual partial specialized variations that are only generic over the Element type.

Checklist

  • I've read the Contribution Guidelines
  • My contributions are licensed under the Swift license.
  • I've followed the coding style of the rest of the project.
  • I've added tests covering all new code paths my change adds to the project (if appropriate).
  • I've added benchmarks covering new functionality (if appropriate).
  • I've verified that my change does not break any existing tests or introduce unexplained benchmark regressions.
  • I've updated the documentation if necessary.

@dnadoba dnadoba force-pushed the dn-optimize-unspecialized-performance branch from 6da4419 to 9d3c30e Compare November 16, 2024 04:04
@dnadoba
Copy link
Member Author

dnadoba commented Nov 16, 2024

This is a benchmark of the unspecialized version of OrderedSet.init and OrderedSet.firstIndex(of:) before and after this change
chart-pr

@dnadoba dnadoba force-pushed the dn-optimize-unspecialized-performance branch from 9d3c30e to 4b1c4c0 Compare November 16, 2024 05:14
@dnadoba
Copy link
Member Author

dnadoba commented Nov 16, 2024

This is OrderedSet.init alone before and after
chart-ordered-set-init

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.

1 participant