Skip to content

Commit

Permalink
Fix tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
Drvi committed Jul 2, 2023
1 parent 772d104 commit a734a34
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
15 changes: 8 additions & 7 deletions src/ChunkedBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function ChunkingContext(buffersize::Integer, nworkers::Integer, limit::Integer,
(4 <= buffersize <= typemax(Int32)) || throw(ArgumentError("`buffersize` argument must be larger than 4 and smaller than 2_147_483_648 bytes."))
(0 < nworkers < 256) || throw(ArgumentError("`nworkers` argument must be larger than 0 and smaller than 256."))
(0 <= limit <= typemax(Int)) || throw(ArgumentError("`limit` argument must be positive and smaller than 9_223_372_036_854_775_808."))
# TRACING # clear_traces!(nworkers)
return ChunkingContext(
1,
TaskCounter(),
Expand Down Expand Up @@ -115,15 +116,15 @@ export parse_file_serial, parse_file_parallel, populate_result_buffer!
# TRACING # const T1 = UInt[]
# TRACING # const T2 = UInt[]
# TRACING # get_parser_task_trace(i) = PARSER_TASKS_TIMES[i]
# TRACING # function clear_traces!()
# TRACING # for _ in length(PARSER_TASKS_TIMES)+1:Threads.nthreads()
# TRACING # function clear_traces!(nworkers::Int=Threads.nthreads())
# TRACING # for _ in (length(PARSER_TASKS_TIMES)+1:nworkers)
# TRACING # push!(PARSER_TASKS_TIMES, UInt[])
# TRACING # end
# TRACING # empty!(ChunkedCSV.IO_TASK_TIMES)
# TRACING # empty!(ChunkedCSV.LEXER_TASK_TIMES)
# TRACING # empty!(ChunkedCSV.T1)
# TRACING # empty!(ChunkedCSV.T2)
# TRACING # foreach(empty!, ChunkedCSV.PARSER_TASKS_TIMES)
# TRACING # empty!(IO_TASK_TIMES)
# TRACING # empty!(LEXER_TASK_TIMES)
# TRACING # empty!(T1)
# TRACING # empty!(T2)
# TRACING # foreach(empty!, PARSER_TASKS_TIMES)
# TRACING # return nothing
# TRACING # end

Expand Down
4 changes: 2 additions & 2 deletions src/ConsumeContexts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ there to be `ntasks * (1 + length(parsing_ctx.schema))` units of work per chunk
See also [`consume!`](@ref), [`setup_tasks!`](@ref), [`task_done!`](@ref), [`cleanup`](@ref)
"""
function setup_tasks!(::AbstractConsumeContext, chunking_ctx::ChunkingContext, ntasks::Int)
# TRACING # parsing_ctx.id == 1 ? push!(ChunkedCSV.T1, time_ns()) : push!(ChunkedCSV.T2, time_ns())
# TRACING # chunking_ctx.id == 1 ? push!(ChunkedBase.T1, time_ns()) : push!(ChunkedBase.T2, time_ns())
set!(chunking_ctx.counter, ntasks)
return nothing
end
Expand Down Expand Up @@ -80,7 +80,7 @@ See also [`consume!`](@ref), [`setup_tasks!`](@ref), [`task_done!`](@ref), [`cle
"""
function sync_tasks(chunking_ctx::ChunkingContext)
wait(chunking_ctx.counter)
# TRACING # parsing_ctx.id == 1 ? push!(ChunkedCSV.T1, time_ns()) : push!(ChunkedCSV.T2, time_ns()) # TRACING
# TRACING # chunking_ctx.id == 1 ? push!(ChunkedBase.T1, time_ns()) : push!(ChunkedBase.T2, time_ns())
return nothing
end
"""
Expand Down
12 changes: 6 additions & 6 deletions src/_traces.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using GLMakie, ChunkedCSV
using GLMakie, ChunkedBase

function plot_traces()
t1 = copy(ChunkedCSV.T1)
t2 = copy(ChunkedCSV.T2)
io_task = copy(ChunkedCSV.IO_TASK_TIMES)
lexer_task = copy(ChunkedCSV.LEXER_TASK_TIMES)
parser_tasks = filter(x->length(x)>0, ChunkedCSV.PARSER_TASKS_TIMES)
t1 = copy(ChunkedBase.T1)
t2 = copy(ChunkedBase.T2)
io_task = copy(ChunkedBase.IO_TASK_TIMES)
lexer_task = copy(ChunkedBase.LEXER_TASK_TIMES)
parser_tasks = filter(x->length(x)>0, ChunkedBase.PARSER_TASKS_TIMES)

start = Int(mapreduce(first, min, parser_tasks, init=min(io_task[1], lexer_task[1])))

Expand Down

0 comments on commit a734a34

Please sign in to comment.