-
Notifications
You must be signed in to change notification settings - Fork 14
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
Loading multiple files spends time in GC #117
Comments
Why not use Maybe something like
|
It's a little difficult to diagnose this remotely, I could help a lot better if you shared a minimal working example that I could run on my end.
This wasn't clear from your code that it was a 3-channel image. Either way, have you tried some of the suggestions for using
Yeah, this is happening because it's likely combining all three channels before doing the reinterpret or something similar.
That's interesting. Could you give me the output of julia> ifds(TiffImages.load(filename, mmap = true) for one of your images? I need to know what kind of TIFF you are trying to load. |
Yes, I understand, I'll generate one that doesn't involve sending large amounts of data.
I'm sorry, that is my bad. The images are originally monochrome but I post-processed them in Python (fiducial marker detection, couldn't do it in Julia), and apparently the output got converted into a three channel image. I thought it was just a quirk of the library, that it always imported in three channels, should've checked my data first. Rechecking with the original images, it's very fast. But it's also a different computer (I'm at home now and don't have access to the post-processed images to cross-compare). So I need to do some investigating first to determine whether it's the result of the post-processing or something else. Sorry for the complications. I will come back here and write update once it's a bit clearer. |
So, I checked and on my work computer (8GB of RAM, enough free RAM to not go to swap), the problem exists whatever files I use, be they post-processed or not. I generated an example file filled with just random The IFDs are the following:
So it's something wrong on my work PC, it doesn't happen on my home PC (which is admittedly much more powerful) |
Huh. Not sure. Based on the IFD information, your TIFF looks pretty standard and should load just fine without any GC. Are both of your machines running the same OS? EDIT: Could you be hitting this issue? https://discourse.julialang.org/t/very-slow-loading-speed-of-tiff-images/99826/15 |
I am indeed on Windows on the work machine (where there is this problem) and on Linux at home (where there is no problem). And yeah, it's slower than MATLAB which I'm trying to replace. In any case, disabling the GC around the call to |
Does it help or does it resolve the GC issue? Not sure why we forcibly run the GC on Windows in our load function, which was introduced in #79 https://github.com/tlnagy/TiffImages.jl/blame/0594e42d94929a0b4bcb712985e75559eaab96ec/src/utils.jl#L198 Maybe @timholy or @johnnychen94 remember why we are doing this? Seems like this is definitely not the solution as it makes |
Sorry, rewrote the comment a couple of times and didn't re-read it. It completely eliminates the issue. For some reason it just doesn't work if I do it inside my function.
This, doesn't work (GC is still used in But I think this has got nothing to do with the package and is just something about Julia GC I'm not getting. So unless you think otherwise, I'm content with the workaround. |
Hi,
I have to load hundreds of TIFF files into memory. Unfortunately, if I try to simply do something like
The garbage collection runs for more than 90% of the time (according to ProfileView). And to collect 230 files (800x800, 8 bit-depth, monochrome), takes a lot of time (30 seconds). The computer I ran it on doesn't have much in the way of RAM but it shouldn't have been using swap.
So I'm looking for a way to make loading images in-place. That is, directly dumping the contents into an array. Is there a way to do so?
Pardon the poor quality of the code, been more than a year that I haven't used Julia and bad habits set in fast.
Best,
Semptum
The text was updated successfully, but these errors were encountered: