add perf comment/concern

This commit is contained in:
Brendan Hansknecht 2024-07-22 17:54:37 -07:00
parent 8b58161c73
commit 65ab733a63
No known key found for this signature in database
GPG key ID: 0EA784685083E75B

View file

@ -22,6 +22,12 @@ pub fn quadsort(
element_width: usize,
copy: CopyFn,
) void {
// Note, knowing constant versions of element_width and copy could have huge perf gains.
// Hopefully llvm will essentially always do it via constant argument propagation and inlining.
// If not, we may want to generate `n` different version of this function with comptime.
// Then have our builtin dispatch to the correct version.
// llvm garbage collection would remove all other variants.
// Also, for numeric types, inlining the compare function can be a 2x perf gain.
if (element_width <= MAX_ELEMENT_BUFFER_SIZE) {
quadsort_direct(source_ptr, len, cmp, cmp_data, data_is_owned, inc_n_data, element_width, copy);
} else {