提交 34c1f859 编写于 作者: J Johannes Rieken

remove gc-signals, heapservice, and mainThreadHeapService, #74846

上级 238a8521
......@@ -67,14 +67,6 @@ windows-process-tree/build/**
windows-process-tree/src/**
!windows-process-tree/**/*.node
gc-signals/binding.gyp
gc-signals/build/**
gc-signals/src/**
gc-signals/deps/**
!gc-signals/build/Release/*.node
!gc-signals/src/index.js
keytar/binding.gyp
keytar/build/**
keytar/src/**
......@@ -112,4 +104,4 @@ vscode-windows-ca-certs/**/*
!vscode-windows-ca-certs/package.json
!vscode-windows-ca-certs/**/*.node
node-addon-api/**/*
\ No newline at end of file
node-addon-api/**/*
......@@ -31,7 +31,6 @@
},
"dependencies": {
"applicationinsights": "1.0.8",
"gc-signals": "^0.0.2",
"getmac": "1.4.1",
"graceful-fs": "4.1.11",
"http-proxy-agent": "^2.1.0",
......
declare module 'gc-signals' {
export interface GCSignal {
}
/**
* Create a new GC signal. When being garbage collected the passed
* value is stored for later consumption.
*/
export const GCSignal: {
new(id: number): GCSignal;
};
/**
* Consume ids of garbage collected signals.
*/
export function consumeSignals(): number[];
export function onDidGarbageCollectSignals(callback: (ids: number[]) => any): {
dispose(): void;
};
export function trackGarbageCollection(obj: any, id: number): number;
}
\ No newline at end of file
......@@ -32,7 +32,6 @@ import './mainThreadErrors';
import './mainThreadExtensionService';
import './mainThreadFileSystem';
import './mainThreadFileSystemEventService';
import './mainThreadHeapService';
import './mainThreadKeytar';
import './mainThreadLanguageFeatures';
import './mainThreadLanguages';
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtHostContext, IExtHostContext } from '../common/extHost.protocol';
import { Disposable } from 'vs/base/common/lifecycle';
import { extHostCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { IHeapService } from 'vs/workbench/services/heap/common/heap';
@extHostCustomer
export class MainThreadHeapService extends Disposable {
constructor(
extHostContext: IExtHostContext,
@IHeapService heapService: IHeapService,
) {
super();
const proxy = extHostContext.getProxy(ExtHostContext.ExtHostHeapService);
this._register(heapService.onGarbageCollection((ids) => {
// send to ext host
proxy.$onGarbageCollection(ids);
}));
}
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export const IHeapService = createDecorator<IHeapService>('heapService');
export interface ObjectIdentifier {
$ident?: number;
}
export interface IHeapService {
_serviceBrand: any;
readonly onGarbageCollection: Event<number[]>;
/**
* Track gc-collection for the given object
*/
trackObject(obj: ObjectIdentifier | undefined): void;
}
export class NullHeapService implements IHeapService {
_serviceBrand: any;
onGarbageCollection = Event.None;
trackObject() { }
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { Event, Emitter } from 'vs/base/common/event';
import { GCSignal } from 'gc-signals';
import { IHeapService, ObjectIdentifier } from 'vs/workbench/services/heap/common/heap';
export class HeapService implements IHeapService {
_serviceBrand: any;
private readonly _onGarbageCollection: Emitter<number[]> = new Emitter<number[]>();
public readonly onGarbageCollection: Event<number[]> = this._onGarbageCollection.event;
private _activeSignals = new WeakMap<any, object>();
private _activeIds = new Set<number>();
private _consumeHandle: any;
private _ctor: { new(id: number): GCSignal };
private _ctorInit: Promise<void>;
constructor() {
//
}
dispose() {
clearInterval(this._consumeHandle);
}
trackObject(obj: ObjectIdentifier | undefined | null): void {
if (!obj) {
return;
}
const ident = obj.$ident;
if (typeof ident !== 'number') {
return;
}
if (this._activeIds.has(ident)) {
return;
}
if (this._ctor) {
// track and leave
this._activeIds.add(ident);
this._activeSignals.set(obj, new this._ctor(ident));
} else {
// make sure to load gc-signals, then track and leave
if (!this._ctorInit) {
this._ctorInit = import('gc-signals').then(({ GCSignal, consumeSignals }) => {
this._ctor = GCSignal;
this._consumeHandle = setInterval(() => {
const ids = consumeSignals();
if (ids.length > 0) {
// local book-keeping
for (const id of ids) {
this._activeIds.delete(id);
}
// fire event
this._onGarbageCollection.fire(ids);
}
}, 15 * 1000);
});
}
this._ctorInit.then(() => {
this._activeIds.add(ident);
this._activeSignals.set(obj, new this._ctor(ident));
});
}
}
}
registerSingleton(IHeapService, HeapService, true);
......@@ -16,7 +16,6 @@ import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/c
import { IModelService } from 'vs/editor/common/services/modelService';
import { ExtHostLanguageFeatures } from 'vs/workbench/api/common/extHostLanguageFeatures';
import { MainThreadLanguageFeatures } from 'vs/workbench/api/browser/mainThreadLanguageFeatures';
import { IHeapService, NullHeapService } from 'vs/workbench/services/heap/common/heap';
import { ExtHostApiCommands } from 'vs/workbench/api/common/extHostApiCommands';
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
import { ExtHostHeapService } from 'vs/workbench/api/common/extHostHeapService';
......@@ -67,7 +66,6 @@ suite('ExtHostLanguageFeatureCommands', function () {
{
let instantiationService = new TestInstantiationService();
rpcProtocol = new TestRPCProtocol();
instantiationService.stub(IHeapService, NullHeapService);
instantiationService.stub(ICommandService, {
_serviceBrand: undefined,
executeCommand(id: string, args: any): any {
......
......@@ -18,7 +18,6 @@ import { ExtHostLanguageFeatures } from 'vs/workbench/api/common/extHostLanguage
import { MainThreadLanguageFeatures } from 'vs/workbench/api/browser/mainThreadLanguageFeatures';
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
import { IHeapService, NullHeapService } from 'vs/workbench/services/heap/common/heap';
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/quickOpen';
......@@ -81,7 +80,6 @@ suite('ExtHostLanguageFeatures', function () {
{
let instantiationService = new TestInstantiationService();
instantiationService.stub(IMarkerService, MarkerService);
instantiationService.stub(IHeapService, NullHeapService);
inst = instantiationService;
}
......
......@@ -89,7 +89,6 @@ import { ContextViewService } from 'vs/platform/contextview/browser/contextViewS
// import { RelayURLService } from 'vs/platform/url/electron-browser/urlService';
// import { ITunnelService } from 'vs/platform/remote/common/tunnel';
// import { TunnelService } from 'vs/workbench/services/remote/node/tunnelService';
import { IHeapService, NullHeapService } from 'vs/workbench/services/heap/common/heap';
import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/browser/configurationResolverService';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { ISearchService } from 'vs/workbench/services/search/common/search';
......@@ -164,7 +163,6 @@ registerSingleton(IContextViewService, ContextViewService, true);
// registerSingleton(IMenubarService, MenubarService);
// registerSingleton(IURLService, RelayURLService);
registerSingleton(ISearchService, RemoteSearchService, true);
registerSingleton(IHeapService, NullHeapService);
registerSingleton(IContextMenuService, ContextMenuService);
registerSingleton(IConfigurationResolverService, ConfigurationResolverService, true);
......
......@@ -3555,11 +3555,6 @@ gauge@~2.7.3:
strip-ansi "^3.0.1"
wide-align "^1.1.0"
gc-signals@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/gc-signals/-/gc-signals-0.0.2.tgz#1cfa8a00adecaeeb93ea0dda72dad9e9f333e62f"
integrity sha512-Ghj4Co6x5bd3dvbAFuiDc6gN+BVK8ic8CBn70dXjzrtbC5hq4a+s4S6acEvftMP7LcQuHKN5v+30PGXhkCLoCQ==
generate-function@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册