Bug 307632 - dot files scrolling is very slow when bird's eye is enabled
Summary: dot files scrolling is very slow when bird's eye is enabled
Status: RESOLVED WORKSFORME
Alias: None
Product: kgraphviewer
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: FreeBSD Ports FreeBSD
: NOR normal
Target Milestone: ---
Assignee: Gaël de Chalendar (aka Kleag)
URL:
Keywords: investigated, triaged
Depends on:
Blocks:
 
Reported: 2012-09-30 18:38 UTC by Yuri
Modified: 2018-09-19 14:31 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
dot file demonstrating the problem (48.62 KB, application/octet-stream)
2012-09-30 18:39 UTC, Yuri
Details
screenshot from kcachegrind showing problematic calls (137.17 KB, image/jpeg)
2012-10-02 03:36 UTC, Yuri
Details
callgrind profile (2.42 MB, text/plain)
2014-08-19 01:46 UTC, Yuri
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri 2012-09-30 18:38:31 UTC
I have a dot file of a reasonable size, ~140 nodes. When kgraphviewer shows it, scrolling takes a long time and makes it very annoying. dotty (from graphviz) scrolls through the graph very fast.

Please see an attached testcase.

kgraphviewer-2.0.2, kde-4.8.4

Reproducible: Always
Comment 1 Yuri 2012-09-30 18:39:51 UTC
Created attachment 74254 [details]
dot file demonstrating the problem
Comment 2 Yuri 2012-09-30 18:45:29 UTC
Only happens when bird's eye is enabled.
Comment 3 Gaël de Chalendar (aka Kleag) 2012-10-01 19:52:13 UTC
With kgraphviewer 2.1.1 under Mageia 2, it scrolls normaly, even with bird eye view.

Do you have the possibility to check with this version ?
Comment 4 Yuri 2012-10-01 23:30:36 UTC
I tried to build the latest git version of kgraphviewer while my installed kde4 is the older version 4.8.4 and am getting the error:
Linking CXX shared library ../../lib/libkgraphviewer.so
/usr/bin/ld: cannot find -lgvc
Comment 5 Yuri 2012-10-02 02:24:27 UTC
I made version 2.1.1 compile and run.
Same problem: it is still very slow when bird's eye is enabled.
All involved kde libs are from version 4.8.4
Comment 6 Yuri 2012-10-02 03:36:08 UTC
I profiled this situation with kcachegrind-cachegrind and found that for some reason 82% of time is spent in libz.so in functions inflate_fast, inflate_table, inflate.
Each of them were called ~1 million times.

see attached image of call graph.
Comment 7 Yuri 2012-10-02 03:36:53 UTC
Created attachment 74274 [details]
screenshot from kcachegrind showing problematic calls
Comment 8 Yuri 2012-10-02 06:25:10 UTC
So it looks like it loads font from file over and over once per text drawing operation, not reusing it.
Comment 9 Gaël de Chalendar (aka Kleag) 2012-10-02 21:09:54 UTC
(In reply to comment #8)
> So it looks like it loads font from file over and over once per text drawing
> operation, not reusing it.
It also seems to be located in the Qt library FreeType fonts handling. Maybe it is limited to FreeBSD ? I think I'll have to ask their advice to Qt specialists. I'll do that as soon as possible.

Thanks for your help in identifying clearly the problem.
Comment 10 Reimar Döffinger 2014-03-03 19:45:39 UTC
Is this issue still reproducible? It sounds like a font caching problem, either in Qt or libfreetype.
Comment 11 Yuri 2014-03-04 00:05:33 UTC
This port has been dropped from the FreeBSD on 2014-02-27 due to the broken for over 6 months build. I also assume it didn't have enough interest.

I will probably try to see if this port can be made to build, it will take some time.

How widely is this package used in general? Any statistics? In other words, is its functionality really needed and not covered by some other packages?
Comment 12 Yuri 2014-03-04 00:10:23 UTC
Also, while I am here, the first error immediately breaking the build is this:
usr/local/include/graphviz/cgraph.h: In member function 'void KGraphEditor::openUrlLibrary(const KUrl&, KParts::ReadOnlyPart*)':
/usr/local/include/graphviz/cgraph.h:263: error: too few arguments to function 'Agraph_t* agread(void*, Agdisc_t*)'
/usr/ports/graphics/kgraphviewer/work/kgraphviewer-2.0.2-kde4.4.0/src/kgrapheditor.cpp:245: error: at this point in file
*** [src/CMakeFiles/kgrapheditor.dir/kgrapheditor.o] Error code 1

Additionally, the port mentioned this:
# Several problems at once here:
# - The port does not include graphviz's include directory, assuming it is
#   always in the compiler's default path (ie. /usr/include).
# - The port includes <graphviz/foo.h>, while code is expected to include
#   <foo.h> instead, and pass -I${LOCALBASE}/graphviz instead of just
#   -I${LOCALBASE} to the compiler.
# - The code in the development repository does a better job at fixing the
#   problems above, but it still relies on the deprecated libgraph library that
#   graphics/graphviz in ports does not install anymore.
Comment 13 Reimar Döffinger 2014-03-04 09:10:22 UTC
Sorry, I probably should have given you more details. I've sent patches for the cgraph issue to the list just recently, but I have a suspicion that the only way to get them in is by taking over as a maintainer. As I have rather enoughto do I'm going through the bug tracker to estimate effort, interest and what kind of help I might get.
I'm surprised about the include path issue though, it seems to me it uses pkg-config...
Comment 14 Yuri 2014-03-04 09:50:29 UTC
So it looks like the upstream isn't maintained much too. This type of functionality isn't 
used much by the average linux user I guess.

Maybe we just need to leave it as it is. Keep this bug open, because I can't even run it easily now.
Comment 15 Reimar Döffinger 2014-03-26 21:36:29 UTC
I now pushed the compile fixes. Testing both of these and re-testing of this issue would be welcome.
Comment 16 Milian Wolff 2014-06-19 11:55:29 UTC
Git commit 246130d975ae06c9d43f71495613c25879a757f0 by Milian Wolff.
Committed on 19/06/2014 at 11:17.
Pushed by mwolff into branch 'master'.

Optimize: Disable semi-expensive debug output generation.

This debug message was never used, but still constructed on every
paint event. Getting rid of it makes this a bit faster.

M  +22   -11   src/part/canvaselement.cpp

http://commits.kde.org/kgraphviewer/246130d975ae06c9d43f71495613c25879a757f0
Comment 17 Milian Wolff 2014-06-19 11:55:29 UTC
Git commit 191609882d386616d1a4a83dfd06fd186e287b1f by Milian Wolff.
Committed on 19/06/2014 at 11:49.
Pushed by mwolff into branch 'master'.

Optimize: Cache string keys used for attribute lookup.

The string literal will otherwise be transformed into a QString,
which requires two allocations (QString's data and the actual
QChar* array in there). Saving this gives a noticeable boost, esp.
considering how often these methods are being called during painting.

M  +2    -2    src/part/graphedge.cpp
M  +19   -6    src/part/graphelement.cpp
M  +37   -23   src/part/graphelement.h

http://commits.kde.org/kgraphviewer/191609882d386616d1a4a83dfd06fd186e287b1f
Comment 18 Milian Wolff 2014-06-19 11:58:22 UTC
If current master is still slow, please give us some data. Record it using linux perf e.g.:

perf record --call-graph dwarf kgraphviewer sample.dot
# now scroll around, do whather that shows its slow
# then close down kgraphviewer, a perf.data file is generated
perf report | bzip2 > perf.log.bz2 # this will take some time

Then upload the perf.log.bz2 and make it accessible to us.
Comment 19 Christoph Feck 2014-07-21 19:20:23 UTC
Yuri, can you confirm the commit solves the performance issue?
Comment 20 Christoph Feck 2014-08-18 13:13:55 UTC
If you can provide the information requested in comment #18, please add it.
Comment 21 Yuri 2014-08-18 18:14:17 UTC
The current kgraphversion version (kgraphviewer-2.0.2-kde4.4.0.tar.bz2) doesn't build with the current version of graphviz-2.38.0 due to this error:
/usr/ports/graphics/kgraphviewer/work/kgraphviewer-2.0.2-kde4.4.0/src/kgraphviewer.cpp:195:16: error: too few arguments to function 'Agraph_t* agread(void*, Agdisc_t*)'
   g = agread(fp);
                ^

kgraphviewer's page http://extragear.kde.org/apps/kgraphviewer/ link that points to "its KDE git repository" is broken: Internal Error

So I can't locate kgraphviewer trunk.
Comment 22 Gaël de Chalendar (aka Kleag) 2014-08-18 20:34:22 UTC
Hello,

Yes, the  last  changes to kgv were in part to use the last versions of graphviz.
 
Concerning the access to the  repository, I have opened a sysadmin ticket:
https://sysadmin.kde.org/tickets/index.php?page=tickets&act=view&id=XDD-7476

The kgraphviewer master url is git@git.kde.org:kgraphviewer (will this work as anonymous ?).

Regards,

Gaël

----- Mail original -----
> De: "Yuri" <yuri@tsoft.com>
> À: kleag@free.fr
> Envoyé: Lundi 18 Août 2014 20:14:17
> Objet: [kgraphviewer] [Bug 307632] dot files scrolling is very slow when bird's eye is enabled
> 
> https://bugs.kde.org/show_bug.cgi?id=307632
> 
> --- Comment #21 from Yuri <yuri@tsoft.com> ---
> The current kgraphversion version
> (kgraphviewer-2.0.2-kde4.4.0.tar.bz2) doesn't
> build with the current version of graphviz-2.38.0 due to this error:
> /usr/ports/graphics/kgraphviewer/work/kgraphviewer-2.0.2-kde4.4.0/src/kgraphviewer.cpp:195:16:
> error: too few arguments to function 'Agraph_t* agread(void*,
> Agdisc_t*)'
>    g = agread(fp);
>                 ^
> 
> kgraphviewer's page http://extragear.kde.org/apps/kgraphviewer/ link
> that
> points to "its KDE git repository" is broken: Internal Error
> 
> So I can't locate kgraphviewer trunk.
> 
> --
> You are receiving this mail because:
> You are the assignee for the bug.
>
Comment 23 Gaël de Chalendar (aka Kleag) 2014-08-18 20:37:56 UTC
Wow! Sysadmins are really good! The ticket I opened is already closed with the problem fixed...

Gaël

----- Mail original -----
> De: "Gaël de Chalendar" <kleag@free.fr>
> À: kleag@free.fr
> Envoyé: Lundi 18 Août 2014 22:34:22
> Objet: [kgraphviewer] [Bug 307632] dot files scrolling is very slow when bird's eye is enabled
> 
> https://bugs.kde.org/show_bug.cgi?id=307632
> 
> --- Comment #22 from Gaël de Chalendar (aka Kleag) <kleag@free.fr>
> ---
> Hello,
> 
> Yes, the  last  changes to kgv were in part to use the last versions
> of
> graphviz.
> 
> Concerning the access to the  repository, I have opened a sysadmin
> ticket:
> https://sysadmin.kde.org/tickets/index.php?page=tickets&act=view&id=XDD-7476
> 
> The kgraphviewer master url is git@git.kde.org:kgraphviewer (will
> this work as
> anonymous ?).
> 
> Regards,
> 
> Gaël
> 
> ----- Mail original -----
> > De: "Yuri" <yuri@tsoft.com>
> > À: kleag@free.fr
> > Envoyé: Lundi 18 Août 2014 20:14:17
> > Objet: [kgraphviewer] [Bug 307632] dot files scrolling is very slow
> > when bird's eye is enabled
> > 
> > https://bugs.kde.org/show_bug.cgi?id=307632
> > 
> > --- Comment #21 from Yuri <yuri@tsoft.com> ---
> > The current kgraphversion version
> > (kgraphviewer-2.0.2-kde4.4.0.tar.bz2) doesn't
> > build with the current version of graphviz-2.38.0 due to this
> > error:
> > /usr/ports/graphics/kgraphviewer/work/kgraphviewer-2.0.2-kde4.4.0/src/kgraphviewer.cpp:195:16:
> > error: too few arguments to function 'Agraph_t* agread(void*,
> > Agdisc_t*)'
> >    g = agread(fp);
> >                 ^
> > 
> > kgraphviewer's page http://extragear.kde.org/apps/kgraphviewer/
> > link
> > that
> > points to "its KDE git repository" is broken: Internal Error
> > 
> > So I can't locate kgraphviewer trunk.
> > 
> > --
> > You are receiving this mail because:
> > You are the assignee for the bug.
> >
> 
> --
> You are receiving this mail because:
> You are the assignee for the bug.
Comment 24 Yuri 2014-08-18 21:56:00 UTC
Now I compiled kgraphviewer trunk, and command 'kgraphviewer sample.dot' hangs with this stack:
(gdb) bt
#0  0x0000000804f2f35a in select () from /lib/libc.so.7
#1  0x0000000804bd4ae2 in select () from /lib/libthr.so.3
#2  0x00000008034eef20 in KLockFile::lock(QFlags<KLockFile::LockFlag>) () from /usr/local/lib/libkdecore.so.5
#3  0x0000000803339190 in KConfigIniBackend::lock(KComponentData const&) () from /usr/local/lib/libkdecore.so.5
#4  0x00000008033220b2 in KConfig::sync() () from /usr/local/lib/libkdecore.so.5
#5  0x00000008033a2552 in KDebugPrivate::writeGroupForNamedArea(QByteArray const&, bool) () from /usr/local/lib/libkdecore.so.5
#6  0x00000008033a1efe in KDebugPrivate::areaData(QtMsgType, unsigned int, bool) () from /usr/local/lib/libkdecore.so.5
#7  0x00000008033a188f in KDebugPrivate::stream(QtMsgType, unsigned int, char const*, int, char const*) () from /usr/local/lib/libkdecore.so.5
#8  0x00000008033a05a1 in kDebugStream(QtMsgType, int, char const*, int, char const*) () from /usr/local/lib/libkdecore.so.5
#9  0x0000000801ef196b in KXMLGUIClient::setXMLFile(QString const&, bool, bool) () from /usr/local/lib/libkdeui.so.5
#10 0x000000000040da74 in KGraphViewerWindow::KGraphViewerWindow (this=0x80b5b1900)
    at /usr/ports/graphics/kgraphviewer/yuri-kgraphviewer-git/src/kgraphviewer.cpp:62
#11 0x000000000040bfd3 in main (argc=<optimized out>, argv=<optimized out>)
    at /usr/ports/graphics/kgraphviewer/yuri-kgraphviewer-git/src/main.cpp:119


kdelibs-4.12.5_3
Comment 25 Yuri 2014-08-18 22:21:13 UTC
It (strangely) hanged this way first several times, and now it works.

The original scrolling problem is gone.

You should make a release, and then I can also suggest FreeBSD to restore the corresponding port (it was deleted in spring due to it being broken).
Comment 26 Yuri 2014-08-18 23:04:36 UTC
Oops, forgot the bird's eye part.
With bird's eye view it is is still extremely slow.
Comment 27 Yuri 2014-08-19 01:46:51 UTC
Created attachment 88314 [details]
callgrind profile

I don't have 'perf' command on FreeBSD box where I see the problem. Instead attaching valgrind/callgrind profile.

Please view it with kcachegrind profile.

inflate_fast/inflate_table/inflate from libz.so take most of the time.
Comment 28 Yuri 2014-08-19 01:47:53 UTC
Required information provided.
Comment 29 Gaël de Chalendar (aka Kleag) 2017-08-02 12:27:57 UTC
With current version 2.1.90 on KDE Neon and also with the current master, the provided samble scrolls very efficiently with or without the bird's eye view.

Do you still encounter the problem ?
Comment 30 Andrew Crouthamel 2018-09-19 14:31:33 UTC
This bug has had its resolution changed, but accidentally has been left in NEEDSINFO status. I am thus closing this bug and setting the status as RESOLVED to reflect the resolution change.