On Sun, 5 Aug 2012 00:13:37 +0400
Andrey Matveyakin <
a.matv...@gmail.com> wrote:
> Hello!
>
> I'm working on improving directory size calculation in Krusader at
> this time. I want to share a draft with you. I would be glad to hear
> any feedbacks: which changes are good and which are are not? What
> else could be done about it?
>
> I'm not posting the patches to the review board because they are not
> ready for pushing, it's a draft, as I have already said. I even
> copypasted some files from KIO to make it easier to preview the
> changes: you wouldn't have to recompile kdelibs to see the result.
> But this is definitely a bad move for a release version :-)
> Another problem is, you might want to investigate separate changes,
> while the review board doesn't allow to send a chain of commits as
> far as I understand.
>
> To sum up, I've taught Krusader to use KIO::DirectorySizeJob for space
> calculation.
>
Hi Andrey,
I also thought about using KIO::DirectorySizeJob, though I haven't
further looked into it.
But is seems to be the right way to me.
> The main benefits are:
> 1. It's now possible calculate size of a remote directory (fixes bug
> 272735).
> 2. Size is calculated in background on space hit.
>
> The smaller benefits (some of them are not actually related to the
> principal changes):
> 3. "0" is shown instead of "<DIR>" when size is really zero.
> 4. "≥" is shown when size is calculated inaccurately (this requires
> modifing kdelibs and the patch is not finished).
> 5. "Calculate All Directories' Sizes" action added.
> 6. KrCalcSpaceDialog fixed: size in bytes is now written.
> 7. Code simplified: an analog of DirectorySizeJob removed from
> KrCalcSpaceDialog.
>
> Changes:
> 8. Computed size value has changed: it now includes directories' self
> sizes. So, an empty folder is reported to occupy 4096 bytes on my ext4
> volume.
> I can't say whether it is good or bad. A advantage is, the size
> reported is now consistent with other KDE apps, such as file
> properties dialog, and consistency is always welcomed, isn't it?
I'd say yes.
> My be, it worth adding a setting whether to include directory's sizes
> in total size or not. But I don't find it necessary.
>
No, not necessary.
> Sadly, a huge drawback comes too:
> 9. Size calculation significantly slowed down.
> Nearly two or three times. That's an inadmissible regression. So, it
> would be very nice to fix it. All the more, all KDE will benefit from
> it, not just Krusader.
>
> I'm not sure where the slowdown comes from: DirectorySizeJob is
> certainly more complicated that current Krusader's algorithm: it
> works over network, handles hard liks correclty, etc. But I think,
> the problem is different. DirectorySizeJob internally calls ListJob
> and simply sums up sizes of all item recieved from it. ListJob itself
> starts a Slave to list a directory. The Slave emits listEntries
> signal when it finds new entries. I find it strange that this signal
> is emitted so frequently: nearly once per millisecond according to my
> measuring, often passing 1--4 or even 0 entries. As far as I
> understand, it shouldn't happen so often. At least, there is a
> static const int minimum_updatetime = 100;
> line in
> void SlaveBase::listEntry( const UDSEntry& entry, bool _ready )
> function.
> It seems, it was planned not to send updates more often that every 100
> milliseconds, but the delay isn't working for some reason. Or may be,
> I didn't caught the idea of that code.
>
> Anyway, it seems to me, that the delay should be added. I'm going to
> investigate the problem closer in the nearest future.
>
> Andrey.
>
That (what SlaveBase::listEntry() is doing) doesn't sound right, would
be great if you can find out what's going wrong there.
Btw: I did some changes to KrCalcSpaceDialog (and many other parts too)
in a separate branch (to be merged after 2.4 release), so it would be
best if you worked on top of that when you do bigger changes.
I just need to figure out how to upload branches first ;-)
Jan