Skip to content

Optimize instance Ord of SourcePos #172

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

Closed

Conversation

ulidtko
Copy link

@ulidtko ulidtko commented Sep 8, 2023

Followup to issue #171.

This is partial remedy, aiding somewhat with "creative" users who pass the entire input into the parse function — both as the input, and as its SourceName / filename. This makes SourceName arbitrarily large — hence, comparing first by the strict-Int fields makes a lot of sense, and does help somewhat (not terribly well) according to measurements.

@parsonsmatt I've credited you in Co-Authored-By — for you've made the observation about the stock-derived Ord instance in the issue thread. Feel free to raise objection if you'd not like that, I'll promptly remove.

See issue haskell#171.

Co-Authored-By: Matt Parsons <[email protected]>
@ulidtko
Copy link
Author

ulidtko commented Sep 8, 2023

As a further idea: using something like hashable to guarantee constant-time comparison of SourcePos'es, regardless of how much MiB's of junk data the user has put into the SourceName.

But before implementing that, I'd like to hear from @phadej first. If such an idea sounds any good.

@phadej
Copy link
Collaborator

phadej commented Sep 11, 2023

This is breaking change and doesn't fix #171.

@phadej phadej closed this Sep 11, 2023
@ulidtko ulidtko deleted the optimize-sourcepos-comparisons branch September 11, 2023 14:41
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