Re: XMLHttpRequest Priority Proposal

2010-08-03 Thread Anne van Kesteren

On Thu, 03 Jun 2010 17:37:05 +0200, Mike Belshe mbel...@google.com wrote:

Here is an updated doc:
https://docs.google.com/a/google.com/document/pub?id=1TcKtHi-XUVKXj9erQkkBXdidnG78lhK04D-2lh4O51Y


Can you make this publicly available? Now it requires a google.com account.


Should this also throw an INVALID_STATE_ERR exception just like timeout  
and withCredentials do? See


http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-timeout-attribute

for details on those attributes.


What prompted me to look at this again was a bug in WebKit I was added to.  
I briefly looked through the patch there but the networking layer was  
doing nothing at all with the field. (Well, it was not changed by this  
patch.) Is this really something that is useful prior to the deployment of  
SPDY? And are we sure SPDY is going to use something like this and that it  
will be useful then?


I suppose we can always remove the property later, but it seems rather  
experimental at this stage, so I am not sure whether I should add it.



--
Anne van Kesteren
http://annevankesteren.nl/



Re: XMLHttpRequest Priority Proposal

2010-08-03 Thread Mike Belshe
On Tue, Aug 3, 2010 at 5:45 AM, Anne van Kesteren ann...@opera.com wrote:

 On Thu, 03 Jun 2010 17:37:05 +0200, Mike Belshe mbel...@google.com
 wrote:

 Here is an updated doc:

 https://docs.google.com/a/google.com/document/pub?id=1TcKtHi-XUVKXj9erQkkBXdidnG78lhK04D-2lh4O51Y


 Can you make this publicly available? Now it requires a google.comaccount.


Sorry about that.  I've given up on google docs.  I have no idea how to
effectively share documents from it.  I've moved the specification to here
instead:

http://www.belshe.com/test/xmlhttprequest.priorities.html

http://www.belshe.com/test/xmlhttprequest.priorities.html



 Should this also throw an INVALID_STATE_ERR exception just like timeout and
 withCredentials do? See

 http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-timeout-attribute

 for details on those attributes.


Ok.





 What prompted me to look at this again was a bug in WebKit I was added to.
 I briefly looked through the patch there but the networking layer was doing
 nothing at all with the field. (Well, it was not changed by this patch.) Is
 this really something that is useful prior to the deployment of SPDY? And
 are we sure SPDY is going to use something like this and that it will be
 useful then?


The Google Maps team has used this technique quite effectively, seeing some
pages reduce latency by ~70%.  They have to fully schedule all resources
manually, however, as they get no help from the browser today.



 I suppose we can always remove the property later, but it seems rather
 experimental at this stage, so I am not sure whether I should add it.


I think it gives developers a good way to manage complex applications, and
it is pretty simple.

Mike





 --
 Anne van Kesteren
 http://annevankesteren.nl/



Re: XMLHttpRequest Priority Proposal

2010-06-03 Thread timeless
On Wed, Jun 2, 2010 at 10:11 PM, Mike Belshe mbel...@google.com wrote:
 Changes:
    * changed the setPriority() method to be an attribute priority

 Applications may alter the priority by calling the setPriority() method on 
 the XMLHttpRequest object.
  The priority set on the object at the time the applicaiton calls the 
 XMLHttpRequest.send() method
 determines the priority the browser should use when fetching this resource.  
 Calling setPriority()

Presumably you intend to change these instances of 'setPriority()' to
reference setting the attribute?



Re: XMLHttpRequest Priority Proposal

2010-06-03 Thread Mike Belshe
Correct.  Sorry.

Here is an updated doc:
https://docs.google.com/a/google.com/document/pub?id=1TcKtHi-XUVKXj9erQkkBXdidnG78lhK04D-2lh4O51Y

Mike


On Thu, Jun 3, 2010 at 2:11 AM, timeless timel...@gmail.com wrote:

 On Wed, Jun 2, 2010 at 10:11 PM, Mike Belshe mbel...@google.com wrote:
  Changes:
 * changed the setPriority() method to be an attribute priority

  Applications may alter the priority by calling the setPriority() method
 on the XMLHttpRequest object.
   The priority set on the object at the time the applicaiton calls the
 XMLHttpRequest.send() method
  determines the priority the browser should use when fetching this
 resource.  Calling setPriority()

 Presumably you intend to change these instances of 'setPriority()' to
 reference setting the attribute?



Re: XMLHttpRequest Priority Proposal

2010-06-02 Thread Mike Belshe
Finally cycling back on this.

Based on feedback from Olli and Anne, I have revised the spec.

Changes:
   * changed the setPriority() method to be an attribute priority
   * made priority be a string rather than a number
   * inserted the NORMAL priority as the default XHR priority

Here is the updated doc.

Olli has implemented a patch (for the old spec) already:
https://bugzilla.mozilla.org/show_bug.cgi?id=559092
We'll be working on a Chromium/Webkit one shortly.

Mike


XMLHttpRequest Priority FetchingEvery performant web browser implementation
today implements various heuristics for resource loading prioritization
internally.  The notion is simple, that loading some resources, such as
images, are less performance critical than loading other resources, such as
external style sheets.  By implementing basic priorities, browsers achieve
substantially better performance loading web pages.  Today, however, web
applications have no way of giving hints to the browser about what may be
high or low priority.

Because complex applications heavily rely on resource loading by way of
XmlHttpRequest, we propose a simple, backward compatible, and optional
mechanism whereby application developers can hint to a browser how to load a
XmlHttpRequest.

Proposed API:
interface XMLHttpRequest {
 // Set the load priority for this request.
 // The priority must be set before calling send().
 // Valid priorities are:
 //   “CRITICAL”, “HIGH”, “NORMAL”, “LOW”, “LOWEST”
 attribute string priority;
}

Example Usage:
var client = new XMLHttprequest;
client.priority = “HIGH”;
client.open(’GET’, ‘demo.cgi’);
client.send();

Description:
When a new XMLHttpRequest object is created, it contains a notion of
priority.  Browsers which schedule resource fetches may optionally use this
priority to determine in which order resources are fetched.

5 priorities are provided.  By keeping the number of different priorities
small, we keep browser and XMLHttpRequest priority implementations simple.

By default, all XMLHttpRequest objects have a priority “NORMAL”.

Applications may alter the priority by calling the setPriority() method on
the XMLHttpRequest object.  The priority set on the object at the time the
applicaiton calls the XMLHttpRequest.send() method determines the priority
the browser should use when fetching this resource.  Calling setPriority()
after the send() method will have no effect on the priority of the resource
load.

Browsers are not required to support the priority requested by applications,
and may ignore it altogether.  However, browsers are encouraged to support
the requested priority order.  The following is a description of one
possible prioritization policy:
  CRITICAL resources are loaded first.  When CRITICAL resources are in
progress, requests for HIGH-LOWEST resources are deferred until all CRITICAL
resources have finished.
  HIGH-LOWEST resources are loaded in that order.  When no CRITICAL
resources are in progress, HIGH-LOWEST resources will be loaded with HIGH
priority first.  The browser does not need to wait until higher priority
resources have finished fetching before it starts a request for a lower
priority resource, although it may chose to do so.

Existing Implementations:Google is currently using resource prioritization
techniques in its Google Maps application, internally to the Google Chrome
browser, and also as a part of the SPDY protocol.










On Sun, Apr 18, 2010 at 10:37 PM, Anne van Kesteren ann...@opera.comwrote:

 On Fri, 16 Apr 2010 18:03:08 +0900, Mike Belshe mbel...@google.com
 wrote:

 On Fri, Apr 16, 2010 at 1:37 AM, Anne van Kesteren ann...@opera.com
 wrote:

 I didn't actually propose an error condition and I'll note that your
 setPriority() proposal didn't handle errors either. E.g. what happens
 when I pass 20 as argument?


 Fair enough. :-)

 What I wanted was an enum, but I don't believe there is a way to do enums,
 right?


 Not currently, no.



  I think easiest would be to just ignore the setting as e.g. lineCap and
 lineJoin on the canvas 2D API do. Then errors are gracefully handled and
 by
 checking what priority is after setting you can see whether the
 implementation supports the feature.


 I'd take whatever people like most.  Personally, I don't like using
 strings for enums, but I can live with it.

 So you're proposing something like:

   var my_priority = HGIH;
   xhr.priority = my_priority;
   if (xhr.priority != my_priority)  {
 // we detected an error
   }


 Yeah. Basically using strings makes it easier to extend the API going
 forward as numbers start clashing pretty soon.



 --
 Anne van Kesteren
 http://annevankesteren.nl/



Re: XMLHttpRequest Priority Proposal

2010-06-02 Thread João Eiras
On Fri, 16 Apr 2010 07:00:56 +0100, Anne van Kesteren ann...@opera.com  
wrote:


On Wed, 14 Apr 2010 01:13:46 +0900, Mike Belshe mbel...@google.com  
wrote:

 // Set the load priority for this request.
 void setPriority(unsigned short priority);


Any reason this is not an attribute named priority?

Other than that I wonder if we should maybe simply use string values to  
make it easier to extend this if we ever need to.




How is it easier to extend ?
Like, define an interval from, say, 1 to 10, 5 is normal, 10 is high then  
let the UA decide how to deal better with prioritization.
Handling strings for such a simple use case is messy, and very different  
from all the other dom bindings that use integers already (e.g. nodeType,  
readyState).





Re: XMLHttpRequest Priority Proposal

2010-04-14 Thread Olli Pettay

Hi Mike,

FYI,
I wrote a wip patch for Gecko.
https://bugzilla.mozilla.org/show_bug.cgi?id=559092
Test builds will be here:
https://build.mozilla.org/tryserver-builds/opet...@mozilla.com-xhr_priority/



-Olli

On 4/13/10 8:36 PM, Mike Belshe wrote:

On Tue, Apr 13, 2010 at 9:36 AM, Olli Pettay olli.pet...@helsinki.fi
mailto:olli.pet...@helsinki.fi wrote:

Hi,


Thanks for the comments.

this seems like a pretty useful, yet reasonable easily implementable
feature.


Good to hear.

I'd add 5th value NORMAL, which would be the default value.

   const unsigned short CRITICAL = 0;
   const unsigned short HIGH = 1;
   const unsigned short NORMAL = 2
   const unsigned short LOW = 3;
   const unsigned short LOWEST = 4;

Not sure if we need all the values, or would
HIGH, NORMAL, LOW be enough?



  I'm not fussy about what priorities are exposed or what we call them -
so long as they are relatively few in number to avoid unnecessary
complexity.  (e.g. 3-5 priority buckets seems fine)

Mike



-Olli



On 4/13/10 7:13 PM, Mike Belshe wrote:

Hi,

I'm a developer on the chrome team, and also working on SPDY.

Others here at Google have requested that we expose some of the
priority-based resource loading mechanics to applications so that
applications can hint to the browser more information about which
resources are critical and which are not.  Some of the Google
Apps teams
have already implemented their own, manual priority-based resource
fetchers, and our maps team saw a huge latency reduction as a
result of
doing so.  Internally to chromium and webkit, resource loading
is also
priority-aware today.  Finally, in SPDY, we've observed good
improvements by exposing priorities all the way across the
protocol.  We
believe exposing priority on the XHR object may benefit many
applications manage their resource loads.

Here is a quick writeup of one proposal which we think would work in
browsers.  We believe it is backward compatible with existing
XHR, and
can be optionally implemented.  It also leaves a fair amount of the
tuning at the discretion of the browser, so it does not create a
long-term liability in the browser.  We hope that these
considerations
make it an easy choice to approve.

I'm wondering if the XMLHttpRequest group would be interested in
taking
this on?

Thanks,
Mike


  XMLHttpRequest Priority Fetching

Every performant web browser implementation today implements various
heuristics for resource loading prioritization internally.  The
notion
is simple, that loading some resources, such as images, are less
performance critical than loading other resources, such as external
style sheets.  By implementing basic priorities, browsers achieve
substantially better performance loading web pages.  Today,
however, web
applications have no way of giving hints to the browser about
what may
be high or low priority.

Because complex applications heavily rely on resource loading by
way of
XmlHttpRequest, we propose a simple, backward compatible, and
optional
mechanism whereby application developers can hint to a browser
how to
load a XmlHttpRequest.

Proposed API:
interface XMLHttpRequest {
  // XMLHttpRequest Priorities.
  const unsigned short CRITICAL = 0;
  const unsigned short HIGH = 1;
  const unsigned short LOW = 2;
  const unsigned short LOWEST = 3;

  // Set the load priority for this request.
  void setPriority(unsigned short priority);
}



Example Usage:
var client = new XMLHttprequest;
client.setPriority(HIGH);
client.open(’GET’, ‘demo.cgi’);
client.send();



Description:
When a new XMLHttpRequest object is created, it contains a notion of
priority.  Browsers which schedule resource fetches may
optionally use
this priority to determine in which order resources are fetched.

4 priorities are provided.  By keeping the number of different
priorities small, we keep browser and XMLHttpRequest priority
implementations simple.

By default, all XMLHttpRequest objects have a priority ‘LOW’.

Applications may alter the priority by calling the setPriority()
method
on the XMLHttpRequest object.  The priority set on the object at the
time the applicaiton calls the XMLHttpRequest.send() method
determines
the priority the browser should use when fetching this resource.
  Calling setPriority() after the send() method will have no

XMLHttpRequest Priority Proposal

2010-04-13 Thread Mike Belshe
Hi,

I'm a developer on the chrome team, and also working on SPDY.

Others here at Google have requested that we expose some of the
priority-based resource loading mechanics to applications so that
applications can hint to the browser more information about which resources
are critical and which are not.  Some of the Google Apps teams have already
implemented their own, manual priority-based resource fetchers, and our maps
team saw a huge latency reduction as a result of doing so.  Internally to
chromium and webkit, resource loading is also priority-aware today.
 Finally, in SPDY, we've observed good improvements by exposing priorities
all the way across the protocol.  We believe exposing priority on the XHR
object may benefit many applications manage their resource loads.

Here is a quick writeup of one proposal which we think would work in
browsers.  We believe it is backward compatible with existing XHR, and can
be optionally implemented.  It also leaves a fair amount of the tuning at
the discretion of the browser, so it does not create a long-term liability
in the browser.  We hope that these considerations make it an easy choice to
approve.

I'm wondering if the XMLHttpRequest group would be interested in taking this
on?

Thanks,
Mike


XMLHttpRequest Priority FetchingEvery performant web browser implementation
today implements various heuristics for resource loading prioritization
internally.  The notion is simple, that loading some resources, such as
images, are less performance critical than loading other resources, such as
external style sheets.  By implementing basic priorities, browsers achieve
substantially better performance loading web pages.  Today, however, web
applications have no way of giving hints to the browser about what may be
high or low priority.

Because complex applications heavily rely on resource loading by way of
XmlHttpRequest, we propose a simple, backward compatible, and optional
mechanism whereby application developers can hint to a browser how to load a
XmlHttpRequest.

Proposed API:
interface XMLHttpRequest {
 // XMLHttpRequest Priorities.
 const unsigned short CRITICAL = 0;
 const unsigned short HIGH = 1;
 const unsigned short LOW = 2;
 const unsigned short LOWEST = 3;

 // Set the load priority for this request.
 void setPriority(unsigned short priority);
}

Example Usage:
var client = new XMLHttprequest;
client.setPriority(HIGH);
client.open(’GET’, ‘demo.cgi’);
client.send();

Description:
When a new XMLHttpRequest object is created, it contains a notion of
priority.  Browsers which schedule resource fetches may optionally use this
priority to determine in which order resources are fetched.

4 priorities are provided.  By keeping the number of different priorities
small, we keep browser and XMLHttpRequest priority implementations simple.

By default, all XMLHttpRequest objects have a priority ‘LOW’.

Applications may alter the priority by calling the setPriority() method on
the XMLHttpRequest object.  The priority set on the object at the time the
applicaiton calls the XMLHttpRequest.send() method determines the priority
the browser should use when fetching this resource.  Calling setPriority()
after the send() method will have no effect on the priority of the resource
load.

Browsers are not required to support the priority requested by applications,
and may ignore it altogether.  However, browsers are encouraged to support
the requested priority order.  The following is a description of one
possible prioritization policy:
  CRITICAL resources are loaded first.  When CRITICAL resources are in
progress, requests for HIGH/MEDIUM/LOW resources are deferred until all
CRITICAL resources have finished.
  HIGH/MEDIUM/LOW resources are loaded in that order.  When no CRITICAL
resources are in progress, HIGH/MEDIUM/LOW resources will be loaded with
HIGH priority first.  The browser does not need to wait until higher
priority resources have finished fetching before it starts a request for a
lower priority resource, although it may chose to do so.

Existing Implementations:
Google is currently using resource prioritization techniques in its Google
Maps application, internally to the Google Chrome browser, and also as a
part of the SPDY protocol.


Re: XMLHttpRequest Priority Proposal

2010-04-13 Thread Mike Belshe
On Tue, Apr 13, 2010 at 9:36 AM, Olli Pettay olli.pet...@helsinki.fiwrote:

 Hi,


Thanks for the comments.



 this seems like a pretty useful, yet reasonable easily implementable
 feature.


Good to hear.


 I'd add 5th value NORMAL, which would be the default value.

   const unsigned short CRITICAL = 0;
   const unsigned short HIGH = 1;
   const unsigned short NORMAL = 2
   const unsigned short LOW = 3;
   const unsigned short LOWEST = 4;

 Not sure if we need all the values, or would
 HIGH, NORMAL, LOW be enough?



 I'm not fussy about what priorities are exposed or what we call them - so
long as they are relatively few in number to avoid unnecessary complexity.
 (e.g. 3-5 priority buckets seems fine)

Mike




 -Olli



 On 4/13/10 7:13 PM, Mike Belshe wrote:

 Hi,

 I'm a developer on the chrome team, and also working on SPDY.

 Others here at Google have requested that we expose some of the
 priority-based resource loading mechanics to applications so that
 applications can hint to the browser more information about which
 resources are critical and which are not.  Some of the Google Apps teams
 have already implemented their own, manual priority-based resource
 fetchers, and our maps team saw a huge latency reduction as a result of
 doing so.  Internally to chromium and webkit, resource loading is also
 priority-aware today.  Finally, in SPDY, we've observed good
 improvements by exposing priorities all the way across the protocol.  We
 believe exposing priority on the XHR object may benefit many
 applications manage their resource loads.

 Here is a quick writeup of one proposal which we think would work in
 browsers.  We believe it is backward compatible with existing XHR, and
 can be optionally implemented.  It also leaves a fair amount of the
 tuning at the discretion of the browser, so it does not create a
 long-term liability in the browser.  We hope that these considerations
 make it an easy choice to approve.

 I'm wondering if the XMLHttpRequest group would be interested in taking
 this on?

 Thanks,
 Mike


  XMLHttpRequest Priority Fetching

 Every performant web browser implementation today implements various
 heuristics for resource loading prioritization internally.  The notion
 is simple, that loading some resources, such as images, are less
 performance critical than loading other resources, such as external
 style sheets.  By implementing basic priorities, browsers achieve
 substantially better performance loading web pages.  Today, however, web
 applications have no way of giving hints to the browser about what may
 be high or low priority.

 Because complex applications heavily rely on resource loading by way of
 XmlHttpRequest, we propose a simple, backward compatible, and optional
 mechanism whereby application developers can hint to a browser how to
 load a XmlHttpRequest.

 Proposed API:
 interface XMLHttpRequest {
  // XMLHttpRequest Priorities.
  const unsigned short CRITICAL = 0;
  const unsigned short HIGH = 1;
  const unsigned short LOW = 2;
  const unsigned short LOWEST = 3;

  // Set the load priority for this request.
  void setPriority(unsigned short priority);
 }



 Example Usage:
 var client = new XMLHttprequest;
 client.setPriority(HIGH);
 client.open(’GET’, ‘demo.cgi’);
 client.send();



 Description:
 When a new XMLHttpRequest object is created, it contains a notion of
 priority.  Browsers which schedule resource fetches may optionally use
 this priority to determine in which order resources are fetched.

 4 priorities are provided.  By keeping the number of different
 priorities small, we keep browser and XMLHttpRequest priority
 implementations simple.

 By default, all XMLHttpRequest objects have a priority ‘LOW’.

 Applications may alter the priority by calling the setPriority() method
 on the XMLHttpRequest object.  The priority set on the object at the
 time the applicaiton calls the XMLHttpRequest.send() method determines
 the priority the browser should use when fetching this resource.
  Calling setPriority() after the send() method will have no effect on
 the priority of the resource load.

 Browsers are not required to support the priority requested by
 applications, and may ignore it altogether.  However, browsers are
 encouraged to support the requested priority order.  The following is a
 description of one possible prioritization policy:
   CRITICAL resources are loaded first.  When CRITICAL resources are in
 progress, requests for HIGH/MEDIUM/LOW resources are deferred until all
 CRITICAL resources have finished.
   HIGH/MEDIUM/LOW resources are loaded in that order.  When no CRITICAL
 resources are in progress, HIGH/MEDIUM/LOW resources will be loaded with
 HIGH priority first.  The browser does not need to wait until higher
 priority resources have finished fetching before it starts a request for
 a lower priority resource, although it may chose to do so.

 Existing Implementations:
  Google is currently using resource prioritization