This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Why is converting the ipfilter block list so slow?

Tags: None
(comma "," separated)
thetrivialstuff
Registered Member
Posts
4
Karma
0
Hi,

First, apologies if this is answered in a FAQ somewhere (tried finding it, etc.).

I'm wondering what the technical reasons are for the (lack of) speed in this conversion -- I found it alluded to somewhere that the reason for doing it at all is to save memory at runtime, and I applaud that decision... However, being a compsci student with a minor in mathematics, I can't help but wonder if it can be optimized a little :)

I glanced at the source code a bit, but I've never worked with C++ * (though I do know enough C to get by) -- the bits in ./plugins/ipfilter aren't commented very much.

Anyway, if someone could describe to me a bit of what's going on when the list gets converted, I'd love to have a go at making it go faster.

~Felix.

*: University of Victoria is teaching us bloody Java instead, which annoys me a bit.
imported4-Ivan
Registered Member
Posts
819
Karma
0

Fri Feb 16, 2007 11:25 am
Converting is done in ipfilter ConvertDialog::convert().

We convert plain text IP ranges to a binary file format (ipblock struct) and KT loads so called 'antip2p header' from this file containing about 100 of these blocks, then we binary search header when checking for an ip after which we binary search the file itself. It's much better than keeping 5MB+ file in RAM and searching and it's pretty fast too.

I've noticed it gets slow and my guess is that Qt is making some weirdness there. You probably noticed how things go pretty fast at the beginning and at the end it gets really slow.

It can probably be optimized so if you care to help, please do so.
swolchok
Registered Member
Posts
9
Karma
0

Mon Feb 26, 2007 8:47 pm
I have emailed a patch correcting this issue to Joris after confirming that it was not fixed in SVN. The problem was that the slow part iterated over a QStringList using QStringList::operator[]() (i.e., subscripting), which takes linear time in Qt 3. I fixed it by using QStringList::iterator instead.
George
Moderator
Posts
5421
Karma
1

Wed Feb 28, 2007 5:50 pm
We are gonna include that patch in 2.1.1, thanks for the patch.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]