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

Benchmark studycase: split #188

Closed
fredrikekre opened this issue Mar 19, 2019 · 7 comments
Closed

Benchmark studycase: split #188

fredrikekre opened this issue Mar 19, 2019 · 7 comments

Comments

@fredrikekre
Copy link
Contributor

The interpreter is fast enough that stepping line for line can usually be done without any noticable lag. However, I have found that split seems very slow:

julia> using BenchmarkTools, JuliaInterpreter
       io = IOBuffer()
       for _ in 1:100
           println(io, "abc 123")
       end
       str = String(take!(io))
       f(str) = split(str, '\n')
       @btime f($str)
       @btime @interpret f($str);
  6.385 μs (182 allocations: 6.52 KiB)
  2.540 s (858969 allocations: 38.95 MiB)

The original case was similar to the code above, but also included a loop over all lines splitting into "abc" and "123". I am not sure what the expected slowdown is, but at least this is something that really stood out. I am just posting this since it seems like an interesting case.

@KristofferC
Copy link
Member

Looks like a lot of time is spend in evaluate_foreigncall

@KristofferC
Copy link
Member

julia> using BenchmarkTools

julia> const s = "foo";

julia> @btime pointer_from_objref(s)
  1.500 ns (0 allocations: 0 bytes)
Ptr{Nothing} @0x00007f6ac35d33f0

julia> @btime @interpret pointer_from_objref(s)
  1.170 ms (503 allocations: 30.91 KiB)
Ptr{Nothing} @0x00007f6ac35d33f0

@KristofferC
Copy link
Member

FWIW

julia> @btime @interpret f($str);
  77.870 ms (1007426 allocations: 73.24 MiB)

now

@KristofferC
Copy link
Member

julia> @btime @interpret f($str);
  62.169 ms (380271 allocations: 12.45 MiB)

at #237

@KristofferC
Copy link
Member

julia>        @btime @interpret f($str);
  40.062 ms (378290 allocations: 11.77 MiB)

at #245

@KristofferC
Copy link
Member

KristofferC commented Mar 30, 2019

julia>        @btime @interpret f($str);
  35.767 ms (378288 allocations: 11.77 MiB)

with #245 and JuliaLang/julia#31541

Commenting out the last_reference uses:

julia> @btime @interpret f($str);
  31.060 ms (375400 allocations: 11.66 MiB)

@KristofferC
Copy link
Member

KristofferC commented Mar 31, 2019

While this is a nice thing to keep seeing improvements here I don't think there is anything special about the performance of split now that warrants this issue to be kept open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants