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

Improve number parsing in streams: use a PushVector to work around slow push! in Base #264

Merged
merged 2 commits into from
Nov 10, 2018

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Nov 4, 2018

Edit: Rebased on top of #265 which perhaps made this PR less urgent.

This improves the performance of parsing numbers by avoiding the use of push! which is slow (JuliaLang/julia#24909) . Using the benchmark

using JSON
using BenchmarkTools

a = string("[", join([rand(Int) for i in 1:10^3], ","), "]");
@btime JSON.parse($a)

we have before:

julia> @btime JSON.parse(IOBuffer($a))
  318.252 μs (1018 allocations: 32.45 KiB)

and after:

julia> @btime JSON.parse(IOBuffer($a))
  242.448 μs (1015 allocations: 32.38 KiB)

@KristofferC KristofferC changed the title Improve number parsing: use a PushVector to work around slow push! in Base Improve number parsing in streams: use a PushVector to work around slow push! in Base Nov 4, 2018
@TotalVerb
Copy link
Collaborator

Does this still give improvement after #265?

@KristofferC
Copy link
Member Author

Yes, but only for the StreamingParser case (since after #265, the MemoryParser doesn't use this at all).

@TotalVerb TotalVerb merged commit 741cbd5 into JuliaIO:master Nov 10, 2018
@KristofferC KristofferC mentioned this pull request Sep 7, 2020
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