Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Revamp polydev around the devtools timeline APIs - #35

Merged
rictic merged 8 commits into
masterfrom
hacking
Nov 17, 2016
Merged

rictic merged 8 commits into
masterfrom
hacking

Conversation

@rictic

@rictic rictic commented Sep 8, 2016

Copy link
Copy Markdown
Contributor

Adds:

  • easy visualization of performance impact of custom elements
    inline with other performance information in browser timeline
    devtools
  • support for Custom Elements v0
  • tests

Removes:

  • 'Polymer' panel in devtools.
    • The data model changed significantly so that code will need
      to be rewritten significantly.
    • ... and I kind don't believe in the feature that much.
      Being able to visualize the impact in the timeline seems
      superior to aggregate statistics.
  • Async tracking with zones.
    • I'd like to add this back. The zones API has changed completely,
      and it uses a decent amount of idiosyncratic terminology without
      defining any of it. Yay. Just needs some sweat, and this is useful
      as is.

super();
} finally {
window.performance.mark(endMark);
window.performance.measure(measure, startMark, endMark);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's straightforward, it'd be a touch better to do the measure() outside of the critical path. Eg done in rIC

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no clear way to ensure that it gets called before the timeline is closed when doing that asynchronously

@paulirish

Copy link
Copy Markdown
Contributor

Just FWIW, I benchmarked the cost of performance.mark() yesterday to understand what sort of overheard it has: https://gist.github.com/paulirish/2fad3834e2617fb199bc12e17058dde4 TL;DR: we're good.

@rictic

rictic commented Sep 8, 2016 •

Copy link
Copy Markdown
Contributor Author

Do you have any info on the cost of calling measure()?

The nondeterminism of rIC makes me nervous. AIUI it's entirely possible that the user will end timeline recording before a single idle callback fires. I guess we could give it a timeout of not too long.

@rictic
rictic force-pushed the hacking branch 5 times, most recently from 046e427 to 881fdb2 Compare September 8, 2016 19:03
@paulirish

Copy link
Copy Markdown
Contributor

Do you have any info on the cost of calling measure()?

I tried it out and it's fine. measure() is like 30% more expensive than mark(), but we're still talking sub-microsecond for each.

Comment thread .gitignore
/bower_components/
/node_modules/
/build/
/src/document-context/*.js* No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we move to a src/lib split?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're currently compiling a single file, seems like overkill at this point IMO

Comment thread manifest.json Outdated
{
"name": "Polymer DevTools Extension",
"version": "0.0.5",
"version": "0.0.6",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like I already 0.0.6 on the chrome store

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumped to 0.0.7

Comment thread src/background.js

var pagePorts = new Map();
var polymerPanelPorts = new Map();
const pagePorts = new Map();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add 'use strict';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/background.js Outdated
} else if (
messageType === 'get-element-stats' ||
messageType === 'clear-element-stats') {
console.log('messageType', messageType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, here and elsewhere

Comment thread src/background.js Outdated
});

} else if (port.name =='element-zones') {
} else if (port.name == 'element-zones') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if not needed, or rename, since element-zones isn't used anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, done

let elementCounter = 0;
const originalCreate = proto.createdCallback || (() => undefined);

function wrap(name: string, fullName: string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

longer name please :) maybe wrapCallback?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. wrapCustomElementCallback is clear and doesn't cause any line wraps.

const result = makeMeasurement(
'created', tagName, counter, () => originalCreate.apply(this));

const originalPropertySetter = this._propertySetter;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you patch this at the prototype level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like yes! I guess this was an artifact of back when we were doing more patching of the Polymer() call?

constructor: CustomElementV1Constructor): CustomElementV1Constructor {
let wrappedConstructor: CustomElementV1Constructor =
class extends constructor {
constructor() {

@justinfagnani justinfagnani Sep 16, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to do constructor(...args) and super(...args) just in case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, done

const startMark = `${prefix}start created ${tagName} ${counter}`;
const endMark = `${prefix}end created ${tagName} ${counter}`;
const measure = `${prefix}created ${tagName} ${counter}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're not wrapping _propertySetter here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread package.json Outdated
@@ -7,14 +7,12 @@
"dev": "gulp dev"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test command?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@paulirish

Copy link
Copy Markdown
Contributor

Do yall want us to show this at polymer summit? +@samccone

@rictic rictic left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments addressed, PTAL!

new (): V1CustomElement;
}

interface V1CustomElement extends HTMLElement {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think they do. e.g.

document.body.connectedCallback // => undefined

Comment thread src/background.js

var pagePorts = new Map();
var polymerPanelPorts = new Map();
const pagePorts = new Map();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/background.js Outdated
} else if (
messageType === 'get-element-stats' ||
messageType === 'clear-element-stats') {
console.log('messageType', messageType);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, here and elsewhere

Comment thread src/background.js Outdated
});

} else if (port.name =='element-zones') {
} else if (port.name == 'element-zones') {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, done

}

interface CustomElementsRegistry {
define(tagName: string, constructor: CustomElementV1Constructor):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the spec has it as any which is how I'm contributing it up for now:

microsoft/TypeScript-DOM-lib-generator#150

Gonna leave this as is until the next typescript release when we can delete it.

constructor: CustomElementV1Constructor): CustomElementV1Constructor {
let wrappedConstructor: CustomElementV1Constructor =
class extends constructor {
constructor() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, done

const startMark = `${prefix}start created ${tagName} ${counter}`;
const endMark = `${prefix}end created ${tagName} ${counter}`;
const measure = `${prefix}created ${tagName} ${counter}`;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const result = makeMeasurement(
'created', tagName, counter, () => originalCreate.apply(this));

const originalPropertySetter = this._propertySetter;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like yes! I guess this was an artifact of back when we were doing more patching of the Polymer() call?

Comment thread package.json Outdated
@@ -7,14 +7,12 @@
"dev": "gulp dev"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread manifest.json Outdated
{
"name": "Polymer DevTools Extension",
"version": "0.0.5",
"version": "0.0.6",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumped to 0.0.7

@rictic

rictic commented Nov 15, 2016

Copy link
Copy Markdown
Contributor Author

screen shot 2016-11-15 at 6 45 46 am

@paulirish Here's a screenshot!

Adds:
  * easy visualization of performance impact of custom elements
    inline with other performance information in browser timeline
    devtools

  * support for Custom Elements v0

Removes:
  * 'Polymer' panel in devtools.
    * The data model changed significantly so that code will need
      to be rewritten significantly.
    * ... and I kind don't believe in the feature that much.
      Being able to visualize the impact in the timeline seems
      superior to aggregate statistics.
  * Async tracking with zones.
    * I'd like to add this back. The zones API has changed completely,
      and it uses a decent amount of idiosyncratic terminology without
      defining any of it. Yay. Just needs some sweat, and this is useful
      as is.
@rictic

rictic commented Nov 16, 2016

Copy link
Copy Markdown
Contributor Author

Ok, got tests passing. Sorry about that. PTAL

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants