Skip to content

Commit

Permalink
fix lock again, allow super speed (#83)
Browse files Browse the repository at this point in the history
* fix lock again, allow super speed (combine async and threads)
  • Loading branch information
Moelf authored Sep 6, 2021
1 parent 0bb8a48 commit 42ddc0b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UnROOT"
uuid = "3cd96dde-e98d-4713-81e9-a4a1b0235ce9"
authors = ["Tamas Gal", "Jerry Ling", "Johannes Schumann", "Nick Amin"]
version = "0.4.1"
version = "0.4.2"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
49 changes: 25 additions & 24 deletions src/root.jl
Original file line number Diff line number Diff line change
Expand Up @@ -419,40 +419,41 @@ function readbasketseek(
f::ROOTFile, branch::Union{TBranch, TBranchElement}, seek_pos::Int
)::Tuple{Vector{UInt8},Vector{Int32}} # just being extra careful
lock(f)
local basketkey, compressedbytes
try
seek(f.fobj, seek_pos)
basketkey = unpack(f.fobj, TBasketKey)
compressedbytes = compressed_datastream(f.fobj, basketkey)
catch
finally
unlock(f)
end

basketrawbytes = decompress_datastreambytes(compressedbytes, basketkey)
basketrawbytes = decompress_datastreambytes(compressedbytes, basketkey)

@debug begin
ibasket = findfirst(==(seek_pos), branch.fBasketSeek)
mbcompressed = length(compressedbytes)/1024^2
mbuncompressed = length(basketrawbytes)/1024^2
"Read branch $(branch.fName), basket $(ibasket), $(mbcompressed) MB compressed, $(mbuncompressed) MB uncompressed"
end
@debug begin
ibasket = findfirst(==(seek_pos), branch.fBasketSeek)
mbcompressed = length(compressedbytes)/1024^2
mbuncompressed = length(basketrawbytes)/1024^2
"Read branch $(branch.fName), basket $(ibasket), $(mbcompressed) MB compressed, $(mbuncompressed) MB uncompressed"
end

Keylen = basketkey.fKeylen
contentsize = Int32(basketkey.fLast - Keylen)
Keylen = basketkey.fKeylen
contentsize = Int32(basketkey.fLast - Keylen)

offsetbytesize = basketkey.fObjlen - contentsize - 8
offsetbytesize = basketkey.fObjlen - contentsize - 8

data = @view basketrawbytes[1:contentsize]
if offsetbytesize > 0
data = @view basketrawbytes[1:contentsize]
if offsetbytesize > 0

#indexing is inclusive on both ends
offbytes = @view basketrawbytes[(contentsize + 4 + 1):(end - 4)]
#indexing is inclusive on both ends
offbytes = @view basketrawbytes[(contentsize + 4 + 1):(end - 4)]

# offsets starts at -fKeylen, same as the `local_offset` we pass in in the loop
offset = ntoh.(reinterpret(Int32, offbytes)) .- Keylen
push!(offset, contentsize)
return data, offset
else
return data, Int32[]
end
catch
finally
unlock(f)
# offsets starts at -fKeylen, same as the `local_offset` we pass in in the loop
offset = ntoh.(reinterpret(Int32, offbytes)) .- Keylen
push!(offset, contentsize)
return data, offset
else
return data, Int32[]
end
end

2 comments on commit 42ddc0b

@Moelf
Copy link
Member Author

@Moelf Moelf commented on 42ddc0b Sep 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/44265

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.2 -m "<description of version>" 42ddc0b13067c5c96bb2d7bf9853920c73a1bbec
git push origin v0.4.2

Please sign in to comment.