-
Notifications
You must be signed in to change notification settings - Fork 321
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
Improvement to the Natural Order Sort #3276
Conversation
de53c0f
to
f06f40f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance improvements are fantastic!
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but I have a few comments.
The main function is quite complex - it is expected to some extent because the performed operation is not trivial. But I'm thinking if we could simplify it a bit - one idea would be to separate the lazy splitting of text into texts/numbers into a separate construct (either with a stateful iterator or ideally, in a bit more Enso-way, with a lazy list) - but the only reasonable way to do this that I see would not be efficient on pairs like 10...0
(a very long number) vs a
(just a letter) - because it would still parse the very long number unnecessarily.
So I think your approach is indeed best, in terms of performance (because it looks at the minimum number of characters to resolve the comparison).
I think it may be worth to add comments with a few words of explanation of the intent behind the helper functions (get_number
and order
). Explaining in more detail what the arguments represent and what the functions return could make it easier to understand what is going on here.
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso
Outdated
Show resolved
Hide resolved
Data generator for benchmarking
Benchmark script
Restore missing ToDo
fc9696d
to
9e9d70b
Compare
Pull Request Description
Moving away from RegEx based comparing of 2 texts to using break iterators to progress piecemeal.
Important Notes
Significant performance gains.
Test results for 10,000 values being sorted in an vector.
Average over 10 runs
Running on an r5a.xlarge EC2
Checklist
Please include the following checklist in your PR: