Skip to content

optimization: schema: use slices.Sort instead of sort.Slice - #564

Merged
zeroshade merged 2 commits into
apache:mainfrom
pixelherodev:slice-sort-faster
Nov 8, 2025
Merged

optimization: schema: use slices.Sort instead of sort.Slice#564
zeroshade merged 2 commits into
apache:mainfrom
pixelherodev:slice-sort-faster

Conversation

@pixelherodev

Copy link
Copy Markdown
Contributor

Shaves off nearly half of the time of Metadata.Equal for me; sort.Slice takes in any as the type of the slice, which requires converting the slice to an interface - which itself requires allocating and converting the pointer to the slice header to use as the interface value.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

Shaves off ~1/3rd of the time of Metadata.Equal for me; sort.Slice takes
in `any` as the type of the slice, which requires converting the slice to
an interface - which itself requires allocating and converting the
pointer to the slice header to use as the interface value.
@pixelherodev

Copy link
Copy Markdown
Contributor Author

sort.Strings is just a wrapper for slices.Sort now; as such, drop the other usage of the sort module in schema.go and drop the dependency too

@zeroshade
zeroshade merged commit 9a643a2 into apache:main Nov 8, 2025
35 of 38 checks passed
@pixelherodev

Copy link
Copy Markdown
Contributor Author

I figure I should probably include this as the motivation:

image
@pixelherodev
pixelherodev deleted the slice-sort-faster branch November 11, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants