#859 column modules invoked many times unnecessarily

1.3
open
nobody
libfm (281)
3
2014-08-13
2014-04-06
AL89
No

Hi,
I'm trying to write modules for PCManFM to read metadata from music files (ID3, vorbis comment etc.) and show them in columns. I found out that after loading a folder, such modules are invoked many times, not just once. On a folder containing about 200 mp3s, this creates a significant and sustained CPU usage.

Steps to reproduce:

1) compile attached module with make && sudo make install. You may want to edit MODULES_DIR in Makefile. TagLib C development files are needed (libtagc0-dev on Debian and derivatives);

2) close all active instances of PCManFM;

3) open PCManFM from a terminal to see debugging output, switch to column view and activate the new column named "Title";

4) navigate to a directory with many mp3s (the more, the better). Their titles should be shown in the new column. They are also printed on the terminal every time the module is invoked. At this point, if I do nothing, they're printed again about every second. If I move the pointer or scroll the list they're printed again even faster.

I experienced this on Debian Testing (version 1.2.0 installed from repository) and Lubuntu 13.10 (version 1.2.0 compiled from source). Is PCManFM supposed to do so, or am I doing something wrong?
Thanks anyway for your great work!

1 Attachments

Discussion

    • labels: --> libfm
    • Group: 1.2 --> 1.3
    • Priority: 5 --> 3
     
  • Thank you very much for reporting this. I think the calls noticed by you are some kind of widget updates that are generated by GTK, may be some file is changed every second so it tries to update the view. In most of cases such update is fast enough so would not consume noticeable amount of CPU because near all the values are already retrieved so will be accessed instantly. If that is not the case (it seems it's not in your case, you retrieve data each time) then some caching should be used. Unfortunately there is no caching APIs to store extra data in FmFileInfo structure for instant access to it at this moment. In fact, it would be very good if this issue was discovered within months passed since that column API was introduced so caching APIs to store extra data in FmFileInfo could be added to 1.2 as well but now it's too late to do anything for it. I mark this report as issue for 1.3 and for now you can do some caching inside of your module to avoid excess CPU usage. That is incorrect of course because there is no way to clear that cache data when it isn't used anymore (it will grow eventually), but there is no other way to get rid of your issue for now, I'm sorry.