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

perf(gather-runner): Clear cache selectively per-pass #2156

Merged
merged 6 commits into from
May 9, 2017

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented May 5, 2017

Instead of once at the beginning, we now clear on a pass-level, but in reality this is the same as it was the first pass that we need it for.

Additionally, don't leave "disable cache" on. Just clear it and start from empty when necessary.

Cache is cleared if we're on a "perf pass" as defined by recordTrace && useThrottling.

In the name of Operation Yaquina Bay #2146. fixes #2089


From a perf perspective the wins are not as noticeable except on high-end hardware. That's because disk cache isn't really significantly faster than the network. lol. Usually pass #4 drops ~10% in duration (for google news, it was from 900ms total to 800ms total)

@paulirish paulirish force-pushed the dontdisablecache branch 2 times, most recently from a6d3b34 to e61bb62 Compare May 5, 2017 17:40
@paulirish paulirish mentioned this pull request May 5, 2017
40 tasks
@paulirish paulirish added the OYB label May 5, 2017
@paulirish paulirish requested a review from patrickhulce May 5, 2017 21:49
const useThrottling = options.config.useThrottling;
return Promise.resolve()
// Clear disk & memory cache if it's a perf run
.then(_ => resetStorage && recordTrace && useThrottling && driver.cleanBrowserCaches())
Copy link
Member

Choose a reason for hiding this comment

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

this heuristic seems a little magical, but I can't think of a better one. At some point we'll want an escape hatch (for if you want a perf pass but not a trace...e.g. running your own gatherers or in-page metrics), but in theory finishing #1826 would mean you'd be able to set a disableStorageReset per-pass in the config

Copy link
Member Author

Choose a reason for hiding this comment

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

ya

}).then(finalUrl => {
options.url = finalUrl;
});
const resetStorage = !options.flags.disableStorageReset;
Copy link
Member

Choose a reason for hiding this comment

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

we usually let options.flags optionally exist, but I don't care much :)

@@ -242,10 +242,10 @@ describe('GatherRunner', function() {
});
});

it('clears the network cache and origin storage', () => {
it('clears origin storage', () => {
Copy link
Member

Choose a reason for hiding this comment

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

do you want to check that the cache gets turned off and back on again?

Copy link
Member Author

Choose a reason for hiding this comment

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

it doesnt go off and on, actually. in the ended didnt go with what the ticket explained. :)

just a one time "Clear everything" at the start of the pass.

added test for that.

Copy link
Member

Choose a reason for hiding this comment

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

it doesnt go off and on, actually

well I meant whatever this is doing here, then :P

// Toggle 'Disable Cache' to evict the memory cache
.then(_ => this.sendCommand('Network.setCacheDisabled', {cacheDisabled: true}))
.then(_ => this.sendCommand('Network.setCacheDisabled', {cacheDisabled: false}));

Copy link
Member Author

Choose a reason for hiding this comment

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

not really. :)

the only thing to really assert is that we want for the first sendCommand's promise to resolve before sending the second. (but technically that's not even necessary)

const resetStorage = !options.flags.disableStorageReset;
const recordTrace = options.config.recordTrace;
const useThrottling = options.config.useThrottling;
return Promise.resolve()
Copy link
Member

Choose a reason for hiding this comment

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

what do you think about moving this to pass? It seems more like setup for navigating (like driver.beginDevtoolsLog and driver.beginTracing) rather than just the act of navigating (putting it here also means going to about:blank also goes through these steps, FWIW)

Copy link
Member Author

Choose a reason for hiding this comment

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

yah seems good.

moved beginDevtoolsLog() to be in the promise chain too.

@paulirish
Copy link
Member Author

ptal

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

lgtm

it'd be nice if we could get more smoke-style tests when we do these protocol-only changes, but I can't think of an obvious, quick way that wouldn't be flaky. In this case and the request blocking case, the unit tests really don't give us much value compared to making sure the commands do what we think they do

@brendankenny
Copy link
Member

it'd be nice if we could get more smoke-style tests when we do these protocol-only changes, but I can't think of an obvious, quick way that wouldn't be flaky

Agreed. We've talked before about adding a smokehouse pass that uses completely custom gatherers doing things to verify gatherRunner/driver behavior...we could maybe write one that loads a site, then loads it again in a "perf pass", and checks the network records to make sure it didn't come from the cache...but that might still be flaky. Similar technique could be used to check #2168

Copy link
Member

@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.

LGTM with some last tiny things

const pass = Promise.resolve()
// Begin tracing only if requested by config.
// Clear disk & memory cache if it's a perf run
.then(_ => resetStorage && recordTrace && useThrottling && driver.cleanBrowserCaches())
Copy link
Member

Choose a reason for hiding this comment

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

make a perfRun var?

* i. cleanBrowserCaches() (if it's a perf run)
* ii. beginDevtoolsLog()
* iii. beginTrace (if requested)
* iiv. GatherRunner.loadPage()
Copy link
Member

Choose a reason for hiding this comment

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

iv (and v below)

@paulirish paulirish force-pushed the dontdisablecache branch from e7e3a19 to ed49797 Compare May 9, 2017 19:21
@paulirish paulirish merged commit 740c2e9 into master May 9, 2017
@paulirish paulirish deleted the dontdisablecache branch May 9, 2017 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disk cache is disabled for the whole run
3 participants