-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
core(predictive-perf): refactor simulation logic #3489
Conversation
There was a problem hiding this 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
* @return {{timeElapsed: number, roundTrips: number, bytesDownloaded: number, congestionWindow: number}} | ||
*/ | ||
simulateDownloadUntil(bytesToDownload, timeAlreadyElapsed = 0, maximumTimeToElapse = Infinity) { | ||
simulateDownloadUntil(bytesToDownload, options) { | ||
options = Object.assign({ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totes
@brendankenny did you want a whack at this too, or you good? |
There was a problem hiding this 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
@@ -123,13 +126,13 @@ class PredictivePerf extends Audit { | |||
let sum = 0; | |||
const values = {}; | |||
Object.keys(graphs).forEach(key => { | |||
const estimate = PageDependencyGraph.estimateGraph(graphs[key]); | |||
const lastLongTaskEnd = PredictivePerf.getLastLongTaskEndTime(estimate.nodeTiming); | |||
const results = new Simulator(graphs[key]).simulate(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -7,8 +7,9 @@ | |||
|
|||
const Audit = require('./audit'); | |||
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'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 = {}; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -320,8 +328,10 @@ class Estimator { | |||
const connection = this._connections.get(node.record.connectionId); | |||
const calculation = connection.simulateDownloadUntil( | |||
node.record.transferSize - timingData.bytesDownloaded, | |||
timingData.timeElapsed, | |||
timePeriodLength - timingData.timeElapsedOvershoot | |||
{ |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
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
fdd4f64
to
1895a8d
Compare
Addresses the remaining non-accuracy impacting items from code review.
TODO from #3162 (comment) (Separately with analysis of impact to accuracy)
isValidDepGraph