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

add better implementations for generic findprev findnext for AbstractString #35742

Merged
merged 2 commits into from
May 7, 2020

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented May 5, 2020

Ref #35727 (comment)

using DelimitedFiles
A = randn(Complex{Float64},300,50)
writedlm("A.csv",A,',')
@time readdlm("A.csv",',',Complex{Float64},'\n')

Before:

  9.316321 seconds (293.64 k allocations: 3.262 GiB, 3.35% gc time)

After

 0.013526 seconds (30.09 k allocations: 1.882 MiB)

Fixes #35721.

@KristofferC KristofferC added performance Must go faster strings "Strings!" labels May 5, 2020
@KristofferC KristofferC requested a review from stevengj May 5, 2020 09:50
@timholy
Copy link
Member

timholy commented May 5, 2020

An almost 1000x improvement, not too shabby.

base/strings/search.jl Outdated Show resolved Hide resolved
@stevengj
Copy link
Member

stevengj commented May 5, 2020

Out of curiosity, how does the speed of findnext compare to the old version?

Update: On my machine with Julia 1.5 master, this findnext is about 20% faster at finding the last character of a 1000-character string or a 37% improvement for an 11-character string. So, the old iterator-based implementation is not bad (and has no allocation), but the new implementation is slightly faster (and arguably simpler).

(Of course, the biggest improvement is eliminating the allocation in findprev.)

@stevengj
Copy link
Member

stevengj commented May 7, 2020

Note: Fixes #35721.

@KristofferC KristofferC force-pushed the kc/perf_abstract_string_find branch from 506cae1 to 30b8419 Compare May 7, 2020 08:52
@KristofferC
Copy link
Member Author

FreeBSD failure looks unrelated.

@KristofferC KristofferC merged commit a47cf00 into master May 7, 2020
@KristofferC KristofferC deleted the kc/perf_abstract_string_find branch May 7, 2020 11:54
Roger-luo added a commit to Roger-luo/julia that referenced this pull request May 11, 2020
Roger-luo added a commit to Roger-luo/julia that referenced this pull request May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DelimitedFiles readdlm is externally slow for Complex{Float64}
5 participants