Firefox and User Timing API in workers

Hi all,

I have recently worked on the porting of user timing API in workers in
Firefox. The reason why this is needed is because it will allow the user to
do some useful benchmark when content is loaded and managed from/by
ServiceWorkers. But it's also useful for performance analysis of worker
codes.

This code is not landed yet because I thought that was important to inform
you first. As the user timing API, from the spec point of view, should not
exposed to workers.

As probably you know, Firefox already has performance.now() in workers
(Workers, Shared Workers, Service Workers). And now we expose all the User
Timing interfaces:

PerformanceMark, PerformanceMeasure, PerformanceEntry and the partial
Performance interface as described by the point 4.2:
http://www.w3.org/TR/user-timing/#extensions-performance-interface

Our implementation is here:
https://bugzilla.mozilla.org/show_bug.cgi?id=1155761

Important points in our code are:

1. all the PerformanceEntry buffers/queue are per thread: marks are not
shared between worker and main-thread or workers and other workers. They
are owned by the performance object exposed in the Worker global scope.
This also means that performance.clearMarks() removes the existing marks
only in the current performance object.

2. PerformanceTiming is not exposed to workers. The only attribute that can
be used as marker name is 'navigationStart'.

3. navigationStart is taken from the window PerformanceTiming object when
the worker is created.
For window-less workers (SharedWorkers, ServiceWorkers) navigationStart is
the creation time of the worker itself.

4. performance.now() uses the navigationStart as described by point 3.

We would like to have a feedback from your working group before shipping
the code I just described.

Thank you in advance.

Best Regards,
Andrea

Received on Friday, 22 May 2015 11:19:07 UTC