Skip to content
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

[PORT] sorting code improvements+optimizations #4797

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Absolucy
Copy link
Member

@Absolucy Absolucy commented Jan 9, 2025

About The Pull Request

ports the following PRs from tg:

there are likely far more that could be done, but I am not knowledgeable on sorting algorithms

Changelog

no user-facing changes

@Absolucy Absolucy added fuck it we ball what could possibly go wrong? Performance / Optimization the number going down makes me happy :3 labels Jan 9, 2025
@Absolucy Absolucy force-pushed the i-can-be-trusted-near-decade-old-code branch from a1f6360 to 9177791 Compare January 9, 2025 01:14
@Absolucy Absolucy changed the title micro-optimizes sorting [PORT] micro-optimizes sorting Jan 9, 2025
@Absolucy Absolucy removed the fuck it we ball what could possibly go wrong? label Jan 9, 2025
LemonInTheDark and others added 2 commits January 10, 2025 00:12
## About The Pull Request

Datum var reads are expensive, and sorting code does a lot of them.
let's work on that together, as a group.
There's maybe 250ms of sorting cost sitting in mostly global variable
work. I'd like to start chopping at that.

My tracy profiles aren't the most helpful, estimating this to save about
14% of timSort over the course of init, tho that's slightly noisy and
not the most reliable

## Why It's Good For The Game
speed
1. Removes code duplication
2. Fully documents `sortTim()`
3. Makes a define with default sortTim behavior, straight and to the
point for 95% of cases
4. Migrates other sorts into the same file
5. Removes some redundancy where they're reassigning a variable using an
in place sorter

For the record, we only use timSort
More documentation, easier to read, uses `length` over `len`, etc
Should be no gameplay effect at all
@Absolucy Absolucy force-pushed the i-can-be-trusted-near-decade-old-code branch from d404893 to 6f26e1f Compare January 10, 2025 05:12
@Absolucy Absolucy changed the title [PORT] micro-optimizes sorting [PORT] sorting code improvements+optimizations Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance / Optimization the number going down makes me happy :3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants