-
Notifications
You must be signed in to change notification settings - Fork 28
Improve performance of fqcnt_jl1_klib.jl #7
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
Conversation
|
Brilliant. Thanks! |
|
Yes, it is a significant improvement on uncompressed fastq. Do you know why julia is not that fast on compressed fastq? Also, which libz.so is the script calling? Is it the system zlib (which is 1.2.7 on CentOS7)? I have updated the timing in README.md. I will update fqcnt/README.md and blog post tomorrow. The more interesting benchmark is bedcov. It is simpler than the first. I don't understand why Julia can't get good performance. Thanks. |
|
Recent Julia distributions are shipped with zlib.so and it is used if you write This is an example patch on my machine: diff --git a/lib/Klib.jl b/lib/Klib.jl
index 1b7fc39..a8f8d21 100644
--- a/lib/Klib.jl
+++ b/lib/Klib.jl
@@ -120,6 +120,9 @@ end
tostring(b::ByteBuffer, n::Int) = unsafe_string(b.a, n)
+const libz = "/usr/lib/x86_64-linux-gnu/libz.so"
+#const libz = "libz"
+
#
# GzFile
#
@@ -127,17 +130,17 @@ mutable struct GzFile <: IO
fp::Ptr{Cvoid}
function GzFile(fn::String, mode = "r")
- x = ccall((:gzopen, "libz"), Ptr{Cvoid}, (Cstring, Cstring), fn, mode)
+ x = ccall((:gzopen, libz), Ptr{Cvoid}, (Cstring, Cstring), fn, mode)
y = x == C_NULL ? nothing : new(x)
if y != nothing finalizer(Base.close, y) end
return y
end
end
-Base.readbytes!(fp::GzFile, buf::Vector{UInt8}) = ccall((:gzread, "libz"), Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cuint), fp.fp, buf, length(buf))
+Base.readbytes!(fp::GzFile, buf::Vector{UInt8}) = ccall((:gzread, libz), Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cuint), fp.fp, buf, length(buf))
function Base.close(fp::GzFile)
- ret = fp.fp != C_NULL ? ccall((:gzclose, "libz"), Cint, (Ptr{Cvoid},), fp.fp) : -1
+ ret = fp.fp != C_NULL ? ccall((:gzclose, libz), Cint, (Ptr{Cvoid},), fp.fp) : -1
fp.fp = C_NULL
return ret
endAnd this is a comparison before the patch: and after the patch: I will check bedcov, too. But maybe I have not enough time to improve it immediately. |
Do you know if the upcoming 1.5 has the improved version? I would guess no, since the fix to Yggdrasil was merged so recently. We should definitely try get that in, in my opinion. |
|
I didn't know, but I expected ;) Considering @lh3 will update his blog post very soon and using the nightly build is not recommended in general, I think the quickest fix we can take for benchmarking is to hardcode the zlib path as I've shown above. Of course, Zlib_jll.jl may be used instead, but it adds a new dependency in the benchmark. |
|
I have updated README and blog post using the system zlib. Julia is on par with faster languages now. Note that Klib.jl in this repo still uses "libz". When timing, I was using the system zlib on CentOS7. |
Hi, I've slightly improved the performance of fqcnt_jl1_klib.jl.
Here are the step-by-step improvements from 759cd6a to 15d9864 on my machine: