On Monday, January 12, 2015 at 8:40:17 PM UTC+1, Josh Matthews wrote:
> 1) Poll-based
Don't.
> 2.3) Shared response buffers
I like this one.
> The network request task updates the shared memory in a safe manner (due
I like the "shared memory" feature very much here. We do a lot of memory
copying during now and I would love to avoid it.
> This is the extent of the possibilities that I've come up with, and I
> don't have a clear sense of the optimal one here. I know that Gecko has
> had trouble with networking-related runnables flooding the event loop in
> the past, which could suggest that a scheme that minimizes runnables
> would be worth investing in. I'd appreciate your thoughts!
The main-thread flooding is an inheritance from old times. The problem is that
to just start a network load you need to go 3 or 4 times through the main
thread. To get OnDataAvail and OnStopRequest (important too!) is the same
case. When there is a content JS or GC running, DOM/text rendering happening,
you are delayed **a lot**. But I feel servo is going to avoid nicely from its
nature.
I assume now you do not limit connections per host/IP at all and don't reuse
connections as well, right?
Think of few requirements:
- you should limit number of connections per IP (I emphasize here *IP*, not
host) since IP usually represents a physical (virtual instance) server
- you should limit the total number of connections (100?) to avoid getting
kicked by home routers with NAT limits
- you have to support reuse of keep-alive (persistent) connections
- you should be able to preconnect ; actually have an async API you ask for a
connection object that will be given back to you fully prepared, including DNS,
TCP h.s., TLS h.s. (session reuse, cert verification/exception) and proxy
negotiation already done ; Gecko heads these days to do preconnections as much
as possible, you should too and do it better than necko..
- this is for HTTP/1: I've never made a research here but experiment with
something like the following resource scheduling model may be good:
- have one (best reused or preconnected) connection for top level document
HTML
- have (preconnected) two (more) connections reserved for *each*:
- head CSS
- fonts
- head sync JS
(total of 6 or more conns, suggesting two for each kind of content at least
since statistically two conns will serve more than twice better)
- anything else may reuse the existing connections when all render/reflow
blocking resources are in our possesion or open new if needed ; note that new
connection will be slower because of small rwins (that grow/stabilize with
number of carried bytes) so should be used for images with known sizes/low prio
stuff etc.
- think that you will be using HTTP/2 that is using a single only connection
(coalesced even per IP) muxing all for you ; I still think some connection
parallelism would be good to have here, but depends...
- think of loading resources concurrently (do a race) from the disk http cache,
meaning to query disk and network at the same time and see what wins
I also have never truly researched epoll or (in contrary) polling each open
network socket alone on its own thread. Anyway, having more threads to poll
(like NxS - N threads where each polls S sockets ; thread per load group, or
so..) may be wise. Most open sockets are in an idle state anyway and just
flood the poll list (that has limits, btw) and must be reshaked on and on on
every read/write op.
-hb-
>
> Cheers,
> Josh
_______________________________________________
dev-servo mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-servo