Closed Bug 1392264 Opened 7 years ago Closed 7 years ago

Returning leftover http transactions after unsuccessful dispatch ruins natural ordering

Categories

(Core :: Networking: HTTP, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: mayhemer, Assigned: mayhemer)

References

Details

(Whiteboard: [necko-active])

Attachments

(1 file)

This is a major perf problem.  We can't prioritize images sooner than during the layout phase which is too late, preload already kicked in most cases.  Hence, leaving trans at least in the natural order is vital to load images from the top to the bottom as they are placed in the markup (for most modern webs it usually means the order of appearance on the screen).

Will have a patch momentarily.
Priority: -- → P1
Attached patch v1Splinter Review
Attachment #8899469 - Flags: review?(kechang)
Comment on attachment 8899469 [details] [diff] [review]
v1

Review of attachment 8899469 [details] [diff] [review]:
-----------------------------------------------------------------

::: netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ +1173,5 @@
>  
> +    // Put the leftovers into connection entry, in the same order as they
> +    // were before to keep the natural ordering.
> +    for (const auto& transactionInfo : Reversed(pendingQ)) {
> +        ent->InsertTransaction(transactionInfo, true);

I think only putting the leftovers back in reverse is not enough.

For example, there is a pendingQ [A0, B0, C0, D0], where A0, B0, C0, and D0 all have priority 0.

If we select A0 and B0 out and put them back in reverse, the pendingQ would be like:
[C0, D0, B0, A0].

I think it's difficult to keep pendingQ's order as before. What do you think?
(In reply to Kershaw Chang [:kershaw] from comment #2)
> Comment on attachment 8899469 [details] [diff] [review]
> v1
> 
> Review of attachment 8899469 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: netwerk/protocol/http/nsHttpConnectionMgr.cpp
> @@ +1173,5 @@
> >  
> > +    // Put the leftovers into connection entry, in the same order as they
> > +    // were before to keep the natural ordering.
> > +    for (const auto& transactionInfo : Reversed(pendingQ)) {
> > +        ent->InsertTransaction(transactionInfo, true);
> 
> I think only putting the leftovers back in reverse is not enough.
> 
> For example, there is a pendingQ [A0, B0, C0, D0], where A0, B0, C0, and D0
> all have priority 0.
> 
> If we select A0 and B0 out and put them back in reverse, the pendingQ would
> be like:
> [C0, D0, B0, A0].
> 
> I think it's difficult to keep pendingQ's order as before. What do you think?

No.  The code as I change it adds the transactions back correctly, note the second arg being true.  It adds each transaction (one by one in the reversed order) as the first before a trans with the same priority, hence you reconstruct the array the same way as it was before.  I locally tested this, it's correct.
> No.  The code as I change it adds the transactions back correctly, note the
> second arg being true.  It adds each transaction (one by one in the reversed
> order) as the first before a trans with the same priority, hence you
> reconstruct the array the same way as it was before.  I locally tested this,
> it's correct.

Yes, you are right. I missed the second argument.
Attachment #8899469 - Flags: review?(kechang) → review+
Thanks!
Keywords: checkin-needed
Whiteboard: [necko-active]
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/c092fcf5ef9a
Return undispatched HTTP transaction to the queue in the same order as they were before. r=kershaw
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/c092fcf5ef9a
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: