Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heimdall instrumentation #4510

Merged
merged 10 commits into from
Sep 30, 2016
Merged

Conversation

runspired
Copy link
Contributor

This is a WIP branch that allows us to easily measure where our performance costs are in different record loading scenarios.

Example:

screen shot 2016-08-23 at 9 45 30 pm

@runspired
Copy link
Contributor Author

The .json files generated by the instrumentation runner should be added to git-ignore, that's the bulk of the line changes. Will prune those out in a moment

@stefanpenner
Copy link
Member

Awesome. I suspect we may (once this matures) shake out pieces into their own repo's and modules, but keeping it together during experimentation seems legit.

@fivetanley
Copy link
Member

beat me to it. nice!

@fivetanley
Copy link
Member

it would be great to allow instrumentation from the outside. on example would be to add some instrumentation for "how many models/requests were loaded during this route transition", but that's probably a separate thing i could implement

(sorry thinking aloud in github comments :P)

@runspired
Copy link
Contributor Author

I made some progress on reducing the cost of the instrumentation itself, so we may be able to leave some of it in for people if they want and use babel transforms to strip the rest of it out for production builds.

@runspired
Copy link
Contributor Author

Results of a recent round of measurements are below, I'm currently working on enabling ED to strip out heimdall instrumentation for production builds.

screen shot 2016-08-26 at 8 08 29 pm

@hjdivad
Copy link
Member

hjdivad commented Aug 29, 2016

@fivetanley

it would be great to allow instrumentation from the outside. on example would be to add some instrumentation for "how many models/requests were loaded during this route transition", but that's probably a separate thing i could implement

This is an excellent suggestion and, unless I've misunderstood you, also something heimdalljs explicitly supports. This is how we use it to track fs usage within ember-cli for instance.

see:

Copy link
Member

@stefanpenner stefanpenner left a comment

Choose a reason for hiding this comment

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

yay cleanup

@runspired
Copy link
Contributor Author

Getting happier, I've squashed and rebased. Got more instrumentation tweaks to make, need to push out an alpha release for heimdall-query and the heimdal babel transform, and figure out what is breaking tests.

@runspired
Copy link
Contributor Author

@igorT not sure why this test is failing, could use some help tracking it down.

@@ -18,6 +18,7 @@ function babelOptions(libraryName, _options) {
'es6.constants',
'es6.modules'
],
externalHelpers: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is from implementing a plugin to strip classCallCheck while investigating alternative adapters, it should be removed.

@@ -47,6 +48,7 @@
"devDependencies": {
"bower": "^1.6.5",
"broccoli-asset-rev": "^2.1.2",
"broccoli-babel-transpiler": "^5.6.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this creeping in here was accidental, will be removed.

"loader.js": "^4.0.0",
"lodash": "^4.15.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure lodash is directly needed anymore, I'll do a quick review to make sure. I believe this was only here for what is now heimdall-query.

@@ -0,0 +1,51 @@
/* global heimdall */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

despite setting this globally many places ESLint was yelling at me if I didn't set it at the top of files :/ This should be worked out.

heimdall.stop(token);
// console.log('ember-data-end', stats.endTime);
// console.profileEnd(label);
// console.info('findAll#item -> fetched ' + get(records, 'length') + ' records');
Copy link
Contributor Author

@runspired runspired Sep 15, 2016

Choose a reason for hiding this comment

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

all these console call comments should be removed.

Copy link
Contributor Author

@runspired runspired left a comment

Choose a reason for hiding this comment

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

Almost ready for PR to be reviewed for merging.

@@ -44,6 +44,24 @@ function retrieveFromCurrentState(key) {
}

var guid = 0;

const [
__a, __b, __c, __d, __e, __f, __g, __h, __i,
Copy link
Member

Choose a reason for hiding this comment

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

we should use more descriptive names?

@fivetanley
Copy link
Member

i think a small facade layer between heimdall and ember data would be nice. this allows us to document it as part of the Ember Data API and also change the implementation more easily if we needed to in the future.

@runspired
Copy link
Contributor Author

@fivetanley Describe what you are thinking. I had no intentions of the instrumentation being public beyond a user being able to leave it in their build and provide their own heimdall instance if desired.

@stefanpenner
Copy link
Member

stefanpenner commented Sep 15, 2016

@fivetanley I believe the public API you seek is heimdall itself. As it aims to provide cross cutting instrumentation (Ember/loader/ember-data/custom app code) etc.

@rwjblue
Copy link
Member

rwjblue commented Sep 15, 2016

I believe the public API you seek is heimdall itself.

Does it have a public API? I didn't think it was stable yet (don't see a 1.x or anything)...

@runspired
Copy link
Contributor Author

@rwjblue we're narrowing in on it, 0.3.x is close to stable

@runspired
Copy link
Contributor Author

@rwjblue and fwiw, the public API in heimdall 0.3.x-alpha3 is at this point highly unlikely to change (the last thing likely to change was the switch over from returning an array to returning an object when calling registerMonitor which I just made this morning), we're mostly playing around with internals at this point.

@fivetanley
Copy link
Member

Is this PR for benchmarking, or is it desired to also be useful to end users?

@stefanpenner
Copy link
Member

stefanpenner commented Sep 15, 2016

Is this PR for benchmarking, or is it desired to also be useful to end users?

first benchmarking, later developers caring about performance (maybe the extension and tests etc.)

@runspired
Copy link
Contributor Author

@fivetanley this PR is part of a concerted effort to have consistent instrumentation across ember-cli, ember, glimmer2, and ember-data to help us more quickly identify performance problems and regressions.

Benchmarking is secondary, but nice. One of the awesome things about this approach is that our instrumentation cost is low enough that it can be left in for end users when they desire, but easily stripped out for the primary case. Soon an end user wanting in depth measurements can select to not strip heimdall and provide their own heimdall instance for use.

'send',
'transitionTo',
'_triggerDeferredTriggers'
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stefanpenner style preference here? Expanded like this or moved onto fewer lines?

@chadhietala
Copy link
Contributor

@runspired I'm going to kill some CI jobs that you have running that are clogging up the concurrency.

@runspired
Copy link
Contributor Author

@igorT code review cleanup is now complete.

@bmac
Copy link
Member

bmac commented Sep 19, 2016

Overall this pr looks good to me @runspired. 👍

Copy link
Member

@fivetanley fivetanley left a comment

Choose a reason for hiding this comment

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

Looks good but a few things need addressing. Also instructions for using/running heimdall need to be in the README before merging.


if (environment === 'development') {
// uncomment when running baseline development benchmarks
// plugins.push(stripHeimdall);
Copy link
Member

Choose a reason for hiding this comment

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

would prefer an environment variable here. inevitably this comment to not commit it will be skipped or forgotten or not seen in a code review.

}),
// comment out when running non-baseline production benchmarks
// WARNING do not ever commit the commented out version!
stripHeimdall
Copy link
Member

Choose a reason for hiding this comment

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

would prefer an environment variable here. inevitably this comment to not commit it will be skipped or not seen in a code review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fivetanley I've found it very hard to replicate a production build without using the production env, if you have suggestions I'm open. Was going to look into a process flag to use as a toggle to keep us safe.

Copy link
Member

Choose a reason for hiding this comment

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

production builds are issued on CI requests and tags auto publish to bower. I wouldn't want heimdall to get in there accidentally; historically build related changes have been difficult to track down and reproduce. something like process.env.ENABLE_HEIMDALL would prevent this change from accidentally being checked into source control.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was going to look into a process flag to use as a toggle to keep us safe.

Agreed ;)

@runspired
Copy link
Contributor Author

This should be good now, Travis tests will pass I think appveryor was just a fluke.

cc @fivetanley I added a bit of documentation to CONTRIBUTING.md, and --instrument as a flag must be used to turn instrumentation on, it's always off and stripped otherwise.

cc @HeroicEric the counters are now alphabetized :)

@fivetanley
Copy link
Member

we'll need to double check with @tricknotes and other globals-mode users to ensure this works in gems/bower. it looks great from a build perspective but just trying to be careful since we tend to have build-related regressions whenever we change this stuff.

@runspired
Copy link
Contributor Author

@igor passing :)

@bmac
Copy link
Member

bmac commented Sep 30, 2016

@runspired do you mind rebasing this pr?

@runspired
Copy link
Contributor Author

@bmac I don't but did you know you can rebase and squash from the merge button now? 💃

@runspired
Copy link
Contributor Author

@bmac rebased :)

@fivetanley
Copy link
Member

@tricknotes do you have some cycles so we can make sure this still works in the globals version of ember data?

@bmac
Copy link
Member

bmac commented Sep 30, 2016

@fivetanley I'd like to merge this pr into the master branch. I can cut an alpha gem release to make testing easer and we will have plenty of time to fix any regressions because these changes will have to go through a full beta cycle. Does that sound good to you?

@fivetanley fivetanley merged commit 2340426 into emberjs:master Sep 30, 2016
@fivetanley
Copy link
Member

Sounds good to me. I'll open a tracking issue.

@tricknotes
Copy link
Member

@fivetanley Sorry to my late :<
Now I confirmed global builds, and it seems to work fine for me 🚀

@wecc wecc removed concept-review Tracks PRs that introduce new concepts that need reviewed for discussion team-review labels Oct 20, 2016
@runspired runspired deleted the heimdall-instrumentation branch October 21, 2016 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants