Skip to content

core(predictive-perf): refactor simulation logic#3489

Merged
patrickhulce merged 5 commits intomasterfrom
predictive_perf__refactor
Oct 11, 2017
Merged

core(predictive-perf): refactor simulation logic#3489
patrickhulce merged 5 commits intomasterfrom
predictive_perf__refactor

Conversation

@patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented Oct 5, 2017

Addresses the remaining non-accuracy impacting items from code review.

  • Moves to use WebInspector.resourceTypes
  • Moves the bulk of the logic into lib/
  • Renames estimator -> simulator
  • Eliminates estimateGraph method from PageDependencyGraph artifact class
  • Renames the node states in Simulator
  • Refactors signature of simulateDownloadUntil

TODO from #3162 (comment) (Separately with analysis of impact to accuracy)

  • Use all trace events that have a stack trace
  • Improve the network initiator logic
  • Remove safeguards in favor of isValidDepGraph

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

this works for me! only one small nit

*/
simulateDownloadUntil(bytesToDownload, timeAlreadyElapsed = 0, maximumTimeToElapse = Infinity) {
simulateDownloadUntil(bytesToDownload, options) {
options = Object.assign({
Copy link
Member

Choose a reason for hiding this comment

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

can we destructure AND do default values?

based on http://node.green/ i think we're good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

totes

@patrickhulce
Copy link
Collaborator Author

@brendankenny did you want a whack at this too, or you good?

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

just a few style nits but otherwise LGTM

Object.keys(graphs).forEach(key => {
const estimate = PageDependencyGraph.estimateGraph(graphs[key]);
const lastLongTaskEnd = PredictivePerf.getLastLongTaskEndTime(estimate.nodeTiming);
const results = new Simulator(graphs[key]).simulate();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd personally still prefer estimate for the local var here, as results is information-less :) or simulatedResults or something. results could be anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

const Util = require('../report/v2/renderer/util.js');
const PageDependencyGraph = require('../gather/computed/page-dependency-graph.js');
const Node = require('../gather/computed/dependency-graph/node.js');
const Simulator = require('../lib/dependency-graph/simulator/simulator.js');
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess simulator.js's context can be figured out from its path, but maybe LoadSimulator or something for the local handle to it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sg done

this._connectionsInUse = new Set();
this._numberInProgressByType = new Map();

this._nodes = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

should be an array now?

Copy link
Collaborator Author

@patrickhulce patrickhulce Oct 9, 2017

Choose a reason for hiding this comment

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

wait why? I thought the whole point was to key these by their state 😆

EDIT: oh just that the keys are numbers now so you'd prefer to have array?

Copy link
Contributor

Choose a reason for hiding this comment

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

EDIT: oh just that the keys are numbers now so you'd prefer to have array?

yah

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

node.record.transferSize - timingData.bytesDownloaded,
timingData.timeElapsed,
timePeriodLength - timingData.timeElapsedOvershoot
{
Copy link
Contributor

Choose a reason for hiding this comment

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

wait, why is this moving to an options object? There's only three and having them named doesn't seem better in this case...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel ya @brendankenny, but @paulirish was persistent

executive summary: it's easier for the caller to understand what the params are

@patrickhulce patrickhulce changed the title refactor(predictive-perf): remaining review items refactor(predictive-perf): address remaining review items Oct 9, 2017
@patrickhulce patrickhulce changed the title refactor(predictive-perf): address remaining review items core(predictive-perf): remaining review items Oct 9, 2017
@patrickhulce patrickhulce changed the title core(predictive-perf): remaining review items core(predictive-perf): refactor simulation logic Oct 9, 2017
@brendankenny
Copy link
Contributor

rebase to pick up test fixes?

* Moves gather/computed/dependency-graph to lib/dependency-graph
* Renames estimator -> simulator
* Eliminates estimateGraph method from PageDependencyGraph artifact class
* Renames the node states in Simulator
* Refactors signature of simulateDownloadUntil
@patrickhulce patrickhulce force-pushed the predictive_perf__refactor branch from fdd4f64 to 1895a8d Compare October 11, 2017 17:59
@patrickhulce patrickhulce merged commit fc88101 into master Oct 11, 2017
@patrickhulce patrickhulce deleted the predictive_perf__refactor branch October 11, 2017 21:55
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.

3 participants