[Thunar-dev] Tree_Model and Bugs 2502, 2902, 3602 and 4051

Ward ward.romp at gmail.com
Tue Jun 24 15:37:30 CEST 2008


Hi,

Working with Xfce/Thunar I soon noticed bug 2502 (freezes when hiding 
switched on). This bug seems to be related to bug 4051, 3602, and 2902. 
Since I'm pretty new to Thunar and have only limited experience in C, I 
would like to know whether my understanding of these bugs is correct. As 
far as I can see browsing through the source code and enabling all debug 
logs the following goes wrong.

All misery starts in 'thunar/thunar_tree_model.c'. It's the model of the 
model-view combination for the GTK_Tree_View widget that shows the 
directory tree. When the user activates a node in the tree, the node 
opens and shows all subnodes within the node. However, each subnode 
wants to know whether it has at least one subnode itself, because of the 
nice little triangle it then needs to show. The TreeView widget asks 
thunar_tree_model whether a node has a subnode. At this moment 
thunar_tree_model queries the node and creates an iterator for every 
subnode it finds. However, every iterator contains a file/directory 
object that wants to be notified of any changes - not only _of_ the 
directory, but also _in_ the directory. This does cause some problems 
for a directory like /proc and /dev.

Problems worsen because of caching within thunar_tree_model. I'm not 
sure about this (bit complicated due to the filter on top of the model 
and the ref_node mechanism that allows caching), but it seems that the 
file/directory objects are kept alive as long as the thunar_tree_model 
exists. This also implies that the directory/file objects want to be 
informed of all changes within each directory (if /proc is shown, a 
directory object exists for every subdir in /proc and every subdir wants 
to be informed about every change _within_ that subdir. This add up!!)

Unfortunately, we're not there yet. Thunar uses FAM/GAMIN for monitoring 
the filesystem. FAM/GAMIN uses efficient kernel monitoring to monitor 
changes to normal mounts (ext2/ext3/reiserfs etc). However, FAM/Gamin 
falls back to polling on special mount points like /proc, /dev (and SD 
cards, Fuse mounts etc...) So now Thunar wants be informed about changes 
to /proc and subdirs and FAM/Gamin polls everything. This is pretty time 
consuming (many, many files, and even more notifications since many 
files in /proc change every millisecond). This causes the crashes 
mentioned in the bug reports.

This explains the problems in bug 2502/3602 (crashes/freezes 
hiding/unhiding) because hiding/unhiding simply involves requerying all 
nodes. Especially hiding is tricky because all nodes are polled (is it 
suddenly a hidden file/dir??) It also explains bug 2902 (Thunar slows 
down browsing larger subdirs). As mentioned there by Jan Rathmann, this 
behaviour is specific for newer versions of GTK (maybe the new TreeView 
is more aggressive in obtaining information)?

A solution would consists of two steps:
1) Prevent caching too many nodes within thunar_tree_model, preferably 
prevent creation of these nodes.
2) If possible, prevent poll notifications. This does imply that 
information might be outdated, but there is a speed/accuracy trade-off.

Regards,



More information about the Thunar-dev mailing list