LWN.net Logo

Threading

Threading

Posted Jun 30, 2007 11:44 UTC (Sat) by oak (guest, #2786)
In reply to: Threading by mikov
Parent article: Test driving Firefox 3

> My absolutely biggest gripe is that it is impossible to kill a single
Firefox window.

I.e. all windows belong to same process. I think the reason why this is
done is because browser startup is slow and due to amount of code, engine
state/initialization etc, it would also take quite a bit of additional
memory at startup. Also, with each window being in a separate process,
you would notice the heap fragmentation caused by the dynamic (JS, Flash
etc) HTML page contents much sooner (each separate window taking after a
day 1/2GB of RAM instead of single Browser process using that much).

It would be nice if Firefox binary would have an option that when you
start it from the command line it would start a new process instead of
asking an already existing Firefox instance to open a new window though...

> The second is that everything, including all separate windows, is
running in the same thread.

One should use separate threads only for separate functionality.
Otherwise the needed locking will kill your performance. Actually I think
it could be better if Firefox would get rid of threading completely, I
think most of the work is done in the main thread anyway, but use of
threads (at all) means that all mallocs within C-library need to be done
with locking. :-)

(Linking against thread library automatically replaces some functions from
C-library with their thread-safe functions. This can in some rare cases
lead to funny problems with dlopen()ed libs if one does linking wrong.)


(Log in to post comments)

Threading

Posted Jun 30, 2007 22:50 UTC (Sat) by mikov (subscriber, #33179) [Link]

One should use separate threads only for separate functionality. Otherwise the needed locking will kill your performance. Actually I think it could be better if Firefox would get rid of threading completely, I think most of the work is done in the main thread anyway, but use of threads (at all) means that all mallocs within C-library need to be done with locking. :-)

I have to disagree. Speaking in general, there are no hard and fast rules in threading and you can't say that locking kills performance without a more specific context. What does "separate functionality" mean anyway ?

It is true that for some (many?) kinds of servers a single thread can achieve better throughput, but for GUI-s this is plain wrong. In a GUI you should be concerned with latency before all, and not with absolute performance. The UI should react immediately to every user action, even if it takes a bit longer to actually complete it.

I do agree that having an option to open new windows in a separate process would go a long way towards improving the situation.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds