-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Make use of v8 cached data #16366
Merged
Merged
Make use of v8 cached data #16366
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1d995a7
use loader with support for cached data
jrieken 1f41ae8
ugily likes the past
jrieken 9791f64
update loader
jrieken 335b422
update loader to eeafe10
jrieken 83b929e
use cachedData only when built
jrieken 22e5e9f
add nodeCachedDataManager for telemetry and cleanup
jrieken 70a9363
increase cleanup timeout
jrieken File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/vs/workbench/electron-browser/nodeCachedDataManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; | ||
import { onUnexpectedError } from 'vs/base/common/errors'; | ||
import { TPromise } from 'vs/base/common/winjs.base'; | ||
import { dirname, join } from 'vs/base/common/paths'; | ||
import { readdir, rimraf } from 'vs/base/node/pfs'; | ||
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; | ||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; | ||
|
||
|
||
export class NodeCachedDataManager { | ||
|
||
private _telemetryService: ITelemetryService; | ||
private _environmentService: IEnvironmentService; | ||
private _disposables: IDisposable[] = []; | ||
|
||
constructor( | ||
@ITelemetryService telemetryService: ITelemetryService, | ||
@IEnvironmentService environmentService: IEnvironmentService | ||
) { | ||
this._telemetryService = telemetryService; | ||
this._environmentService = environmentService; | ||
|
||
this._handleCachedDataErrors(); | ||
this._manageCachedDataSoon(); | ||
} | ||
|
||
dispose(): void { | ||
this._disposables = dispose(this._disposables); | ||
} | ||
|
||
private _handleCachedDataErrors(): void { | ||
const onNodeCachedDataError = (err) => { | ||
this._telemetryService.publicLog('nodeCachedData', { errorCode: err.errorCode, path: err.path }); | ||
}; | ||
|
||
// handle future and past errors | ||
(<any>self).require.config({ onNodeCachedDataError }, true); | ||
(<any[]>(<any>window).MonacoEnvironment.nodeCachedDataErrors).forEach(onNodeCachedDataError); | ||
delete (<any>window).MonacoEnvironment.nodeCachedDataErrors; | ||
|
||
// stop when being disposed | ||
this._disposables.push({ | ||
dispose() { | ||
(<any>self).require.config({ onNodeCachedDataError: undefined }, true); | ||
} | ||
}); | ||
} | ||
|
||
private _manageCachedDataSoon(): void { | ||
// Cached data is stored as user data in directories like `CachedData/1.8.0`. | ||
// This function makes sure to delete cached data from previous versions, | ||
// like`CachedData/1.7.2`. | ||
|
||
const {nodeCachedDataDir} = this._environmentService; | ||
if (!nodeCachedDataDir) { | ||
return; | ||
} | ||
|
||
let handle = setTimeout(() => { | ||
handle = undefined; | ||
|
||
const nodeCachedDataBase = dirname(nodeCachedDataDir); | ||
|
||
readdir(nodeCachedDataBase).then(entries => { | ||
|
||
const deletes = entries.map(entry => { | ||
const path = join(nodeCachedDataBase, entry); | ||
if (path !== nodeCachedDataDir) { | ||
return rimraf(path); | ||
} | ||
}); | ||
|
||
return TPromise.join(deletes); | ||
|
||
}).done(undefined, onUnexpectedError); | ||
|
||
}, 30 * 1000); | ||
|
||
this._disposables.push({ | ||
dispose() { clearTimeout(handle); } | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@jrieken should we not use the commit ID of the built as a way to identify the backup? if we use the version, wouldn't we use old cached data each time we update insiders build?
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.
We update the cached data then
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.
@jrieken ok but that basically means each insider user now has the performance penalty to pay to get the cached data and write to disk instead of also having the performance gain on insiders?
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.
Well, nevermind, since we update insiders nightly, the cache needs to be invalidated anyways.
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.
Yes - we could consider not enabling this for insiders at all. However, to get started and to collect feedback I'll keep it enabled.