-
Notifications
You must be signed in to change notification settings - Fork 17
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 lazy Chain/Vcat for Tree #131
Conversation
Codecov Report
@@ Coverage Diff @@
## master #131 +/- ##
==========================================
- Coverage 92.38% 92.13% -0.25%
==========================================
Files 11 11
Lines 1418 1450 +32
==========================================
+ Hits 1310 1336 +26
- Misses 108 114 +6
Continue to review full report at Codecov.
|
julia> @time let nmu=0
for evt in r
nmu += evt.nMuon
end
nmu
end
0.705541 seconds (11.37 k allocations: 544.327 MiB, 1.61% gc time)
149322456
julia> @time let nmu=0
for evt in two_r
nmu += evt.nMuon
end
nmu
end
1.532861 seconds (22.73 k allocations: 1.063 GiB, 1.81% gc time)
298644912 and jagged julia> @time let nmu=0
for evt in r
nmu += length(evt.Muon_phi)
end
nmu
end
4.039776 seconds (18.39 k allocations: 2.967 GiB, 1.76% gc time)
149322456
julia> @time let nmu=0
for evt in two_r
nmu += length(evt.Muon_phi)
end
nmu
end
7.949935 seconds (36.78 k allocations: 5.934 GiB, 1.21% gc time)
298644912 |
#avoid false sharing
julia> @time let nmu=zeros(Int, Threads.nthreads()*10)
@batch for evt in two_r
nmu[Threads.threadid()*10] += length(evt.Muon_phi)
end
sum(nmu)
end
2.356330 seconds (229.16 k allocations: 6.024 GiB, 1.22% gc time, 4.17% compilation time)
298644912 |
looks good to me in my limited testing. It's interesting to see how much functionality you can add with only 10-15 lines :) |
for posterity, here's an attempt using julia> function myvcat(t1::LazyTree, t2::LazyTree)
c1 = columns(UnROOT.innertable(t1))
c2 = columns(UnROOT.innertable(t2))
LazyTree(
Table(NamedTuple(k=>ChainedVector([c1[k], c2[k]]) for k in keys(c1)))
)
end
julia> const _blah = myvcat(r,r);
julia> const two_r = vcat(r,r); # this PR
julia> @time sum(x->length(x.Muon_phi), _blah)
8.517592 seconds (96.67 k allocations: 5.937 GiB, 1.92% gc time, 0.77% compilation time)
298644912
julia> @time sum(x->length(x.Muon_phi), two_r) # this PR
7.866316 seconds (110.78 k allocations: 5.938 GiB, 1.98% gc time, 1.07% compilation time)
298644912 I also tried: LazyTree(
Table(TableOperations.joinpartitions(Tables.partitioner([c1, c2])))
) which is basically automatic |
Closes #72
In no hurry to merge, please give it a try ;)
TODO: