Skip to content

Non-recursive shell sort#101

Closed
funny-falcon wants to merge 1 commit intoianlancetaylor:masterfrom
funny-falcon:shell-sort
Closed

Non-recursive shell sort#101
funny-falcon wants to merge 1 commit intoianlancetaylor:masterfrom
funny-falcon:shell-sort

Conversation

@funny-falcon
Copy link

Shell-sort is straight-forward non-recursive algorithm.
It is comparable in performance to naive qsort up to million items.

Shell-sort is straight-forward non-recursive algorithm.
It is comparable in performance to naive qsort up to million items.
@ianlancetaylor
Copy link
Owner

The libbacktrace sort time is a big percentage of its performance on large programs. I have not seen any complaints about running out of stack space during the sort. So this doesn't seem like a desirable change.

Have you run any benchmarks on large programs?

@funny-falcon
Copy link
Author

funny-falcon commented Jan 5, 2023

I've integrated libbacktrace into PostgreSQL, and by 'perf record' shell sort is just a bit slower (3-7%). (ie 12% vs 13% of total cpu usage).

To be honestly, looking on swap function it was hard to guess sorting is performance critical.

Given all array elements passed to backtrace_qsort are pointer-aligned, I've made PR #102. It makes sorting 2.5 times faster.

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