On Mon, Oct 02, 2017 at 09:07:09PM -0400, Boris Zbarsky wrote:
On 10/2/17 5:35 PM, Kris Maglione wrote:
So far it doesn't look like there's any significant difference on any talos test from adding [NeedsCallerPrincipal] to setAttribute/setAttributeNS/Attr.value,

OK. That's a minimum bar, obviously, but I would still like us to measure what the (presumably nonzero) impact is, so we know what we're dealing with. In particular, setAttribute may simply not be a huge part of most talos tests.

What I'd like to see is how long setAttribute() with some meaningless name like "testing" takes with/without this change on an HTMLDivElement in both the "in document" and "out of document" cases. Just a silly microbenchmark is ok for this purpose; it at least gives us an idea of what happens in the L2-cache-hit case.

For the pretty simple micro-benchmark below, here are the in-document and out-of-document numbers for three runs without the subject principal:

1260ns 1820ns
1260ns 1870ns
1014ns 1332ns

and three runs with:

1002ns 1470ns
1280ns 1722ns
1207ns 1898ns

The difference between the two is within the noise.


Without inserting the div into the document, the numbers were closer to 500ns, with or without the subject principal, in- or out-of-document.

I haven't tested a sandbox with X-rays, but I'm willing to bet X-ray overhead completely overwhelms any other meaningful metric in that case.


<body>
 <iframe src="foo.html"></iframe>
 <script>
   "use strict";

   function run(doc) {
     let div = document.createElement("div");
     doc.body.appendChild(div);

     let iterations = 1024 * 1024;

     let start = performance.now();
     for (let i = 0; i < iterations; i++) {
       div.setAttribute("data-num", i);
     }
     let end = performance.now();
     let delta = (end - start) * 1000 * 1000;

     doc.body.appendChild(document.createTextNode(`Per-iteration: 
${Math.round(delta / iterations)}ns`));
   }

   let iframe = document.querySelector("iframe");
   iframe.addEventListener("load", () => {
     run(iframe.contentDocument);
   }, {once: true});

   window.addEventListener("load", () => {
     run(document);
   }, {once: true});
 </script>
</body>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to