-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
drastic slow down of zoomable light table after GMIC integration in master #4114
Comments
It is a big deal if your plan is to remove the zoomable light table. I am absolutely against. |
I thought the gmic library was broken on opensuze. see #4067.
I'm not a user of zoomable lighttable (I could become :-)), but I've tested your use case (with an 8Gb memory machine) and I don't find any speed difference with a collection of 150 images, once images are in cache. |
FWIW attached you find the output of Any issues that could come from the mix of C++ code (garbage collection etc.) into the C world of darktable? |
In lighttable libgmic is not activated if you have not made use of lut3d with compressed luts. It could be an issue like that if you were on darkroom on lut3d using gmz file ...
I don't see any issue with lut3d in your file. I've seen 2 images with that module, but no warning nor error message. Nothing about libgmic either (and not the issue #4067) I see some difference between images:
If you want a quick workaround you can uninstall libgmic and rebuild dt (after deleting build folder content). You would be free of this library. |
C++ doesn't have garbage collection and usually projects doesn't automagically get slower just by introducing C++ code. |
After deleting libgmic-devel, |
Here is the output of |
I've tried to compare the 2 log files. The only difference I've found so far is about the [lighttable] image expose time (0,0005 sec -> more than 0,0250, but not always). How much memory has your machine ? Do (did) you see significant swap running dt ? |
@upegelow : Sorry, I sent a message on the dev mailing list (to get feedback) pointing to the discussion about removing broken storages and the zoomanble lt which is very very difficult to maintain. Everybody who responded said that they were not using the zoomable lt so yes it was decided to go ahead and removing it as part of the big rewrite drived by @AlicVB. So it seems that we need to reconsider this decision and see how we can manage keeping you and the maintainers of this code happy :) |
16GB and no swapping. |
plenty of space then. |
libgmic library has one (but I don't know the detail). |
Some further insights: there is no general slowdown of darktable. Exporting an image on CPU takes the same time regardless if gmic is loaded or not. Some other thought. On my system the libgmic-devel install includes a file
|
@upegelow : I've tried to reproduce with no luck atm.
everywhere in So it will be easier to find the problematic part. I personally suspect it's somewhere after Line 1250 in 1befa7d
(and yes, there's certainly better ways for debugging ;)) |
This list is really the list of dependencies of gmic. This side seems ok. |
I think I need to do a session with gperftools in order to get closer to the issue. I hope to find time on Friday. |
All time is lost in the following section: Lines 1291 to 1312 in e56b0e7
This is regardless of color management yes or no. However, it's closely linked to using OPENMP here: if I skip OPENMP in that part all runs normal. For comparison:
This is for thumbnails of about 160 x 110 pixels. Now anybody can explain what role gmic plays here and if this could happen in other code places as well? |
@upegelow : As this indeed makes no sense let's explore one possibility. Do you have a Linux kernel 5.3 ? It has been reported to be buggy and could produce large slowdown. Maybe the key in this story ? |
|
If you have some time, can you by any chance do timing tests with an iop where openmp is used (with and without gmic). With opencl deactivated of course ;) So we can see if gmic break somehow all OPENMP uses or just this one... |
Here is a test in the tonecurve module: OPENMP on:
OPENMP off:
As it should be. |
That's probably one of the strangest issue I have seen :( Sorry no more idea at this point. One more thing I would check is the shared libraries used in both cases. Maybe libgmic compiled in your distrib is using a different OpenMP library? Mixing would cause this slow down ? Or maybe it is compiled with another version of GCC ? |
BTW, this is exactly what we are doing for rawspeed for example. |
distro maintainers won't be happy. So we will end up where we started - they will rip out gmic git submodule and link to the system library (with the same dependencies) instead. |
@parafin : as we've done with the OpenCL headers. It will be optional. |
When I started to work on this, I added gmic.h in dt code. I don't remember I needed any other library to compile and use it.
Why I don't see this at build time ? |
Because DT is built without -Wl,--no-undefined flag. iop plugin is a shared library, by default it is assumed, that it's OK to have unresolved symbols in it. |
And how will this idea help then, if most users use packages from distributions which will use system library and therefore this bug will be present for them? |
I don't now and we don't know as we don't have a single idea about the issue at the moment. It is happening for a single user at the moment. At least we will be able to provide a version with a very minimal version of GMIC built and so with less dependencies for all people building from sources. And I hope this will solve @upegelow issue and maybe it will give us an idea about what is going on. I have nothing better to propose at the moment. |
Just removed them. But yet no warning / error at build time (and still crash :-)). Something is missing ... About dependencies, looking at the Makefile (if I understand correctly) only zlib library is mandatory. |
Not sure what have you removed, but that flag is missing, so you should have added it, not removed. You probably changed if(WIN32) part. |
If the idea is to have a minimal build of gmic, then you don't need to include it in dt sources, just do a minimal build of gmic and install it instead of system version;) |
My bad! So I have to find out where to put it ... |
But in that case if the user needs to use gmic as an application we get back the compatibility issue. My idea currently is to add the code (normally with no or very few dependencies) to dt. So it should run whatever the context. |
Which problem are we trying to fix here? If it's the bug with lighttable slowdown - then we should debug it first, not make some decisions already. @upegelow is unwilling to help right now, so I would suggest to wait for someone to reproduce the issue who is able to run the tests I proposed. Custom build of gmic was suggested as a test, not as a solution. At best it's a workaround. If we are talking about the amount of dependencies gmic pulls and we want to reduce them, then I guess it's a question for packagers of libgmic. In Gentoo it is solved by USE-flags, and in binary distributions it's a foundational limitation. Copying code doesn't sound like a good idea, and will be actively opposed by various distributions due to their policy on bundled libraries. |
From my standpoint, to find a way to use the desired features without bringing bug, build or distributions issue... About the right to include or not piece of codes, I don't know, but that's the gmic team itself which suggested to do that way (that was also on their site). |
And I'm saying that copying code will introduce distribution (or rather packaging) problems. It's not about a right to do it (if licenses are compatible, it's not a problem), but the fact that code duplication is considered bad. |
With some significant trouble I managed to compile gmic and libs myself with the following settings:
A few observations:
|
Could you produce the same library comparison pdf like you did before? |
Only libmvec comes as an additional dependency specific to gmic. |
Could you try also to remove "-Ofast" flag from gmic's CMakeLists.txt and rebuild it? It should get rid of libmvec too, I think. But honestly I don't know what to make of it, especially since we now have 3 different behaviours (rendering speeds)... |
That's it probably. Without -Ofast / libmvec export image takes about 0.0005 secs, the same as when compiled without gmic. |
Still, I'm not sure what it means... So at least 2 gmic dependencies affect darktable performance - one from the original long list of libraries dropped render speed from 0.02 to 0.004, then libmvec (it seems) dropped 0.004 to original 0.0005. libmvec seems to replace some mathematical functions with optimized implementation, which doesn't explain the slowdown, especially since the code that is slow does just plain old memcpy. |
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz with active hyperthreading A bit of clarification on the numbers. So far I have four cases:
The difference between 2 and 3: the original library is likely compiled with gcc/g++ version 7 (standard on Leap 15.1). That compiler version would generate an internal g++ error here on one of the gmic source files so I needed to move to version 8. Additionally I was not able to compile with opencv, so I needed to discard the zart part of gmic. |
fwiw: I do not build but use darix's openSUSE Tumbleweed builds and I experienced very noticeable delays switching images during the time gmic was in the Tumbleweed builds. Not seeing it now. hope this may help |
I have now narrowed down the issue and could revise some of my previous findings. The problem seems to arise from opencv3 which is linked in the standard gmic package on my system. By moving to opencv4 I could generate a gmic package that would not slow down darktable. I needed to skip building of zart as I have not been able to make the build process accepting opencv4, but that's fine for me. The imminent cause of the slowdown has been that our code in view.c only sees one CPU core: Lines 1291 to 1312 in e56b0e7
As a consequence we get a massive accumulation of OPENMP overhead (processing many images with low resolution) without any advantage. IMHO we should revise the code above a bit. There could be one codepath with OPENMP and one without. Based on image dimensions and number of cores the path could be chosen dynamically. This would require a bit investigations to find the break even point. |
To clarify:
Regarding OpenCV affecting OpenMP, I've found only one thing to try - set OPENCV_FOR_OPENMP_DYNAMIC_DISABLE environment variable to 1. Are both OpenCV3 and OpenCV4 built with OpenMP support on your system? |
Yes, Yes.
I don't know. Both do not link against libgomp. |
Then probably no? Is opencv the only different library from ldd output when you change from opencv3 to opencv4? I'm sadly not very familiar with OpenMP and how it uses threads, so I'm afraid this is all the help I can provide with this bug... |
Just for the records: I can no longer reproduce the slow down on my system. After a recent upgrade of several system libraries (incl. gmic) the problem is gone. I am closing this issue. |
Describe the bug
The zoomable light table (one of the view options in lighttable mode) has experienced a drastic slow down recently after integration of GMIC.
Panning and zooming to navigate within the lighttable used to be very fast, even with larger collections. Now it can be so slow that darktable practically freezes. Work is not possible any longer.
I bisected the issue and found to my surprise:
To Reproduce
Already tested: no influence from my existing
library.db
. I get the same behavior with a fresh setup.Expected behavior
The lighttable should be as fast as in 3.0. If GMIC stands in the way and this cannot be sorted out quickly GMIC integration should be made optional at compile time.
Platform (please complete the following information):
The text was updated successfully, but these errors were encountered: