CSS optimizations in khtml

It’s been a while since my last blog post and a lot has happened. So let me summarize some nice things. After my GSOC with SVG for khtml I felt like I need to do something more real-life, so I chose CSS to play with.
It’s appeared that recently web pages became slower and bigger, with heavy style sheets, so it was time for us to change something.

here is the bunch of optimizations was made for khtml before kde 4.2 release:
1. use AtomicString for CSS values, this way we reduce memory usage (with shared strings between different selectors) and improve item comparison
2. pre-parse class attribute selectors and store it as AtomicStrings (faster class look up)
3. better selectors collecting (linear algorithm instead of O(M*N) complexity)
4. finally, smart selectors choosing for potential match based on element’s class attribute, id attribute, local name id, so we don’t have to go over all selectors for every single element

Anyway, what’s in that? probably, not everyone is interested in code itself, so here is the impact:
– improvement on synthetic benchmark based on css taken from facebook from ~1s originally to 20ms with current trunk
– up-to 4x less memory usage for selectors with AtomicString on some heavy sites, like youtube
– much smoother site loading (youtube, facebook, etc)
– even acid3 got faster

Advertisements

8 Responses to “CSS optimizations in khtml”

  1. sebt3 Says:

    One word : Thanks 🙂

  2. Soap Says:

    Awesome work! I love using konqueror, but lately I’ve had to use other browsers for facebook, etc. mainly because of this.

    I’m looking forward to the day that I use only one webbrowser again.

  3. Coque Says:

    Thank you very much.

    I’m still using 4.1.3 from Debian experimental packages. I hope to see your optimizations running as soon as possible.

    Regards.

  4. Andreas Says:

    First off, great improvements, congratulations.
    The “real life” part was funny: it’s still a HTML rendering engine 😛

  5. Sebastian Sauer Says:

    Very impressing. Thanks too!

  6. Yngve Says:

    Looking forward to check this out. Keep up all the good work! 🙂

  7. Yves Says:

    Thank you for you good work. Konq is a serious browser which does not miss a lot to be able to replace firefox.

    Can you do something about the fact that heavy activity in one tab seems to freeze/slowdown the other tabs and even the complete konq gui.

    E.g. load a heavy page, in the same time open a new tab and type in the urlbar, this is often not smooth. Could single tabs be threads, or even processes?

    Thanks for your good work!

  8. fred Says:

    Thanks for your work! I love Konqueror + KHTML, now even in my workplace I’m using it under windows 😀

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: