shawnsmithdev / zermelo

A radix sorting library for Go (golang)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use sort.Slice instead of sort.Interface?

ashi009 opened this issue · comments

I've done some benchmark on both. It seems that sort.Slice has 20% performance improvement comparing to sort.Interface.

However it means stop supporting go 1.7 and earlier versions.

Good point. Closing this.

With vgo coming, I'm starting to tag releases. The existing code has been cleaned up some and tagged as "v0.1". I'm reopening this as a feature request for "v0.2", as doing this will not break any working code unless its built with an old Go. This is a change that, while somewhat risky, isn't the same as breaking API compatibility and doesn't warrant a full new major point release.

Go moves pretty fast, and I encourage all shops to strive to keep up with Go releases, but let's use Ubuntu LTS support as a sort of relative benchmark for how long we want to support builds on old Go versions.

Ubuntu 16.04 LTS is good until April 2021, and it came with Go 1.6, which includes support for the vendor folder (>=1.5). So a solution for these users, and any on versions >= 1.5 but <= 1.7 is to vendor a clone at the v0.1 tag until they can upgrade to 18.04 LTS / Go 1.10.

This will break builds on 14.04 Trusty, which is good until April 2019 and came with Go 1.2, which is currently the low bar for test builds in travis. This makes me uncomfortable with releasing this change until closer to that time. But we should be ready to switch to sort.Slice() when the last semi-reasonable excuse to still be running Go 1.2 expires.

Go 1.6 is no longer maintained, and will not receive any security upgrade: https://github.com/golang/go/wiki/Go-Release-Cycle#release-maintenance

I don't think LTS means "use all the ancient dev tools to get stability".

That's why I said "semi-reasonable". It is a pretty weak excuse. It would be more than reasonable for me to release this change "early".

Merged!

FYI, the increased speed is primarily due to Go skipping array-bounds checks in its swapper. An optimization that is not available to third-party packages, where those checks are always generated by the compiler.