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

Do not use Stateful for cmp of AbstractString #47125

Merged
merged 2 commits into from
Oct 12, 2022

Conversation

jakobnissen
Copy link
Member

@jakobnissen jakobnissen commented Oct 11, 2022

PR #45924 fixed length of Stateful, but this change requires Stateful to call
length on its wrapped iterator on instantiation.
The current implementation of cmp(::AbstractString, ::AbstractString) wraps the
strings in Stateful to efficiently check if one string is longer than the other
without needing an O(N) call to length.
However, with #45924 this length call is done anyway, which led to a performance
regression.

In this PR, the cmp method is changed so it no longer relies on Stateful to do
the same thing.

Fix #46719

Note to reviewers: I agree that it's not ideal that Stateful now calls length on instantiation. But I can't think of a way to ensure correct behaviour of Stateful without doing that. Furthermore, since Stateful now (after #45924) caches the length call, Stateful is only slower in the case where length is slow to compute and it's not called, as is the case for this particular cmp method.

PR JuliaLang#45924 fixed length of Stateful, but this change requires Stateful to call
length on its wrapped iterator on instantiation.
The current implementation of cmp(::AbstractString, ::AbstractString) wraps the
strings in Stateful to efficiently check if one string is longer than the other
without needing an O(N) call to length.
However, with JuliaLang#45924 this length call is done anyway, which led to a performance
regression.

In this PR, the cmp method is changed so it no longer relies on Stateful to do
the same thing.

Fix JuliaLang#46719
@jakobnissen
Copy link
Member Author

As far as I can tell, these various errors are unrelated

@aviatesk
Copy link
Member

@nanosoldier runbenchmarks("string", vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

Copy link
Member

@aviatesk aviatesk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The benchmark results look good.

@vtjnash
Copy link
Member

vtjnash commented Oct 12, 2022

@nanosoldier runbenchmarks("string", vs="@24f53313eed272f6d783c2e241fcd72dc342a2df")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - no performance regressions were detected. A full report can be found here.

@vtjnash
Copy link
Member

vtjnash commented Oct 12, 2022

Doubling the old performance is also quite good

@aviatesk aviatesk added the merge me PR is reviewed. Merge when all tests are passing label Oct 12, 2022
@aviatesk aviatesk merged commit a7d446b into JuliaLang:master Oct 12, 2022
@jakobnissen jakobnissen deleted the statelesscmp branch October 12, 2022 07:37
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Oct 13, 2022
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.

new performance issue with ==
5 participants