-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
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
As far as I can tell, these various errors are unrelated |
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
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 benchmark results look good.
@nanosoldier |
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
Doubling the old performance is also quite good |
PR #45924 fixed length of
Stateful
, but this change requiresStateful
to calllength
on its wrapped iterator on instantiation.The current implementation of
cmp(::AbstractString, ::AbstractString)
wraps thestrings in
Stateful
to efficiently check if one string is longer than the otherwithout 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 onStateful
to dothe same thing.
Fix #46719
Note to reviewers: I agree that it's not ideal that
Stateful
now callsl
ength on instantiation. But I can't think of a way to ensure correct behaviour ofStateful
without doing that. Furthermore, sinceStateful
now (after #45924) caches thelength
call,Stateful
is only slower in the case wherelength
is slow to compute and it's not called, as is the case for this particularcmp
method.