-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
I have an array of relatively large JSON messages. They take a while to process in a single threaded loop. However trying to run the loop in multithreaded mode crashes julia. Wonder if this is JSON or julia bug (or my bug).
using JSON
@assert Threads.nthreads() > 1 "please start julia in multithreaded mode \"julia --threads 8\" "
str = "{\"queryCount\":11218,\"resultsCount\":11218,\"adjusted\":true,\"results\":[" *
repeat("{\"T\":\"EWT\",\"v\":5.183782e+06,\"vw\":58.9362,\"o\":59.44,\"c\":58.73,\"h\":59.45,\"l\":58.72,\"t\":1649966400000,\"n\":28854},", 11218)
str = str[1:end-1] * "]}" #this is large JSON
parse_total = 1000
strings = repeat([str], parse_total) #now we have many large messages
results_tmp = Vector{Any}(nothing, parse_total)
println("parsing 1 thread")
for i in 1:parse_total
results_tmp[i] = JSON.parse(strings[i])
i % 100 == 0 && println(i)
end
println("parsing using $(Threads.nthreads()) threads")
results_tmp = Vector{Any}(nothing, parse_total)
Threads.@threads for i in 1:parse_total
results_tmp[i] = JSON.parse(strings[i])
end
println("done parsing using $(Threads.nthreads()) threads")
calling this file like this I 100% crash in the multithreaded loop (single thread runs fine all the time). I don't get any message julia just exits
julia --threads 16 debug_json.jl
I tried smaller json message and it looks like runnig fine. it is really once it gets big (both message itself and number of messages to parse) I seem to be able to repeat the crash
I run Win10
, julia 1.7.2
and JSON v0.21.3
At this point I would be happy with a workaround if one exists.
Metadata
Metadata
Assignees
Labels
No labels