debt - remove unsupported max_old_space_size option (#180183)

This commit is contained in:
Benjamin Pasero 2023-04-18 07:32:23 +02:00 committed by GitHub
parent 4e45804466
commit 6d5b85427d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 31 additions and 305 deletions

View File

@ -502,10 +502,6 @@ pub struct EditorTroubleshooting {
#[clap(long)]
pub disable_gpu: bool,
/// Max memory size for a window (in Mbytes).
#[clap(long, value_name = "memory")]
pub max_memory: Option<usize>,
/// Shows all telemetry events which the editor collects.
#[clap(long)]
pub telemetry: bool,
@ -534,9 +530,6 @@ impl EditorTroubleshooting {
if self.disable_gpu {
target.push("--disable-gpu".to_string());
}
if let Some(memory) = &self.max_memory {
target.push(format!("--max-memory={}", memory));
}
if self.telemetry {
target.push("--telemetry".to_string());
}

View File

@ -31,7 +31,7 @@ _@@APPNAME@@()
COMPREPLY=( $( compgen -W 'critical error warn info debug trace off' ) )
return
;;
--folder-uri|--disable-extension|--max-memory)
--folder-uri|--disable-extension)
# argument required but no completions available
return 0
;;
@ -50,8 +50,7 @@ _@@APPNAME@@()
--uninstall-extension --enable-proposed-api --verbose --log -s
--status -p --performance --prof-startup --disable-extensions
--disable-extension --inspect-extensions
--inspect-brk-extensions --disable-gpu
--max-memory=' -- "$cur") )
--inspect-brk-extensions --disable-gpu' -- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
fi

View File

@ -32,7 +32,6 @@ arguments=(
'--inspect-extensions[allow debugging and profiling of extensions]'
'--inspect-brk-extensions[allow debugging and profiling of extensions with the extension host being paused after start]'
'--disable-gpu[disable GPU hardware acceleration]'
'--max-memory=[max memory size for a window (in Mbytes)]:size (Mbytes)'
'*:file or directory:_files'
)

View File

@ -439,11 +439,6 @@ function getJSFlags(cliArgs) {
jsFlags.push(cliArgs['js-flags']);
}
// Support max-memory flag
if (cliArgs['max-memory'] && !/max_old_space_size=(\d+)/g.exec(cliArgs['js-flags'] ?? '')) {
jsFlags.push(`--max_old_space_size=${cliArgs['max-memory']}`);
}
return jsFlags.length > 0 ? jsFlags.join(' ') : null;
}
@ -458,7 +453,6 @@ function parseCLIArgs() {
'user-data-dir',
'locale',
'js-flags',
'max-memory',
'crash-reporter-directory'
]
});

View File

@ -11,7 +11,6 @@ import { Event } from 'vs/base/common/event';
import { isAbsolute, resolve, join, dirname } from 'vs/base/common/path';
import { IProcessEnvironment, isMacintosh, isWindows } from 'vs/base/common/platform';
import { randomPort } from 'vs/base/common/ports';
import { isString } from 'vs/base/common/types';
import { whenDeleted, writeFileSync } from 'vs/base/node/pfs';
import { findFreePort } from 'vs/base/node/ports';
import { watchFileContents } from 'vs/platform/files/node/watcher/nodejs/nodejsWatcherLib';
@ -390,14 +389,6 @@ export async function main(argv: string[]): Promise<any> {
});
}
const jsFlags = args['js-flags'];
if (isString(jsFlags)) {
const match = /max_old_space_size=(\d+)/g.exec(jsFlags);
if (match && !args['max-memory']) {
addArg(argv, `--max-memory=${match[1]}`);
}
}
const options: SpawnOptions = {
detached: true,
env

View File

@ -93,7 +93,6 @@ export interface NativeParsedArgs {
'crash-reporter-directory'?: string;
'crash-reporter-id'?: string;
'skip-add-to-recently-opened'?: boolean;
'max-memory'?: string;
'file-write'?: boolean;
'file-chmod'?: boolean;
'enable-smoke-test-driver'?: boolean;

View File

@ -110,7 +110,6 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
'inspect-brk-extensions': { type: 'string', allowEmptyValue: true, deprecates: ['debugBrkPluginHost'], args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") },
'disable-gpu': { type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") },
'ms-enable-electron-run-as-node': { type: 'boolean', global: true },
'max-memory': { type: 'string', cat: 't', description: localize('maxMemory', "Max memory size for a window (in Mbytes)."), args: 'memory' },
'telemetry': { type: 'boolean', cat: 't', description: localize('telemetry', "Shows all telemetry events which VS code collects.") },
'remote': { type: 'string', allowEmptyValue: true },

View File

@ -9,8 +9,6 @@ import { localize } from 'vs/nls';
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
import { ErrorReporter, OPTIONS, parseArgs } from 'vs/platform/environment/node/argv';
const MIN_MAX_MEMORY_SIZE_MB = 2048;
function parseAndValidate(cmdLineArgs: string[], reportWarnings: boolean): NativeParsedArgs {
const onMultipleValues = (id: string, val: string) => {
console.warn(localize('multipleValues', "Option '{0}' is defined more than once. Using value '{1}'.", id, val));
@ -47,10 +45,6 @@ function parseAndValidate(cmdLineArgs: string[], reportWarnings: boolean): Nativ
args._.forEach(arg => assert(/^(\w:)?[^:]+(:\d*){0,2}$/.test(arg), localize('gotoValidation', "Arguments in `--goto` mode should be in the format of `FILE(:LINE(:CHARACTER))`.")));
}
if (args['max-memory']) {
assert(parseInt(args['max-memory']) >= MIN_MAX_MEMORY_SIZE_MB, `The max-memory argument cannot be specified lower than ${MIN_MAX_MEMORY_SIZE_MB} MB.`);
}
return args;
}

View File

@ -663,20 +663,8 @@ export class FileService extends Disposable implements IFileService {
}
private validateReadFileLimits(resource: URI, size: number, options?: IReadFileStreamOptions): void {
if (options?.limits) {
let tooLargeErrorResult: FileOperationResult | undefined = undefined;
if (typeof options.limits.memory === 'number' && size > options.limits.memory) {
tooLargeErrorResult = FileOperationResult.FILE_EXCEEDS_MEMORY_LIMIT;
}
if (typeof options.limits.size === 'number' && size > options.limits.size) {
tooLargeErrorResult = FileOperationResult.FILE_TOO_LARGE;
}
if (typeof tooLargeErrorResult === 'number') {
throw new TooLargeFileOperationError(localize('fileTooLargeError', "Unable to read file '{0}' that is too large to open", this.resourceForError(resource)), tooLargeErrorResult, size, options);
}
if (typeof options?.limits?.size === 'number' && size > options.limits.size) {
throw new TooLargeFileOperationError(localize('fileTooLargeError', "Unable to read file '{0}' that is too large to open", this.resourceForError(resource)), FileOperationResult.FILE_TOO_LARGE, size, options);
}
}

View File

@ -293,12 +293,6 @@ export interface IFileReadLimits {
* `FILE_TOO_LARGE` will be thrown.
*/
size?: number;
/**
* If the file exceeds the given size, an error of kind
* `FILE_EXCEEDS_MEMORY_LIMIT` will be thrown.
*/
memory?: number;
}
export interface IFileReadStreamOptions {
@ -610,7 +604,6 @@ export enum FileSystemProviderErrorCode {
FileNotFound = 'EntryNotFound',
FileNotADirectory = 'EntryNotADirectory',
FileIsADirectory = 'EntryIsADirectory',
FileExceedsMemoryLimit = 'EntryExceedsMemoryLimit',
FileExceedsStorageQuota = 'EntryExceedsStorageQuota',
FileTooLarge = 'EntryTooLarge',
FileWriteLocked = 'EntryWriteLocked',
@ -680,7 +673,6 @@ export function toFileSystemProviderErrorCode(error: Error | undefined | null):
case FileSystemProviderErrorCode.FileIsADirectory: return FileSystemProviderErrorCode.FileIsADirectory;
case FileSystemProviderErrorCode.FileNotADirectory: return FileSystemProviderErrorCode.FileNotADirectory;
case FileSystemProviderErrorCode.FileNotFound: return FileSystemProviderErrorCode.FileNotFound;
case FileSystemProviderErrorCode.FileExceedsMemoryLimit: return FileSystemProviderErrorCode.FileExceedsMemoryLimit;
case FileSystemProviderErrorCode.FileTooLarge: return FileSystemProviderErrorCode.FileTooLarge;
case FileSystemProviderErrorCode.FileWriteLocked: return FileSystemProviderErrorCode.FileWriteLocked;
case FileSystemProviderErrorCode.NoPermissions: return FileSystemProviderErrorCode.NoPermissions;
@ -711,8 +703,6 @@ export function toFileOperationResult(error: Error): FileOperationResult {
return FileOperationResult.FILE_PERMISSION_DENIED;
case FileSystemProviderErrorCode.FileExists:
return FileOperationResult.FILE_MOVE_CONFLICT;
case FileSystemProviderErrorCode.FileExceedsMemoryLimit:
return FileOperationResult.FILE_EXCEEDS_MEMORY_LIMIT;
case FileSystemProviderErrorCode.FileTooLarge:
return FileOperationResult.FILE_TOO_LARGE;
default:
@ -1187,7 +1177,7 @@ export class FileOperationError extends Error {
export class TooLargeFileOperationError extends FileOperationError {
constructor(
message: string,
override readonly fileOperationResult: FileOperationResult.FILE_TOO_LARGE | FileOperationResult.FILE_EXCEEDS_MEMORY_LIMIT,
override readonly fileOperationResult: FileOperationResult.FILE_TOO_LARGE,
readonly size: number,
options?: IReadFileOptions
) {
@ -1216,7 +1206,6 @@ export const enum FileOperationResult {
FILE_PERMISSION_DENIED,
FILE_TOO_LARGE,
FILE_INVALID_PATH,
FILE_EXCEEDS_MEMORY_LIMIT,
FILE_NOT_DIRECTORY,
FILE_OTHER_ERROR
}
@ -1300,12 +1289,6 @@ export async function whenProviderRegistered(file: URI, fileService: IFileServic
});
}
/**
* Native only: limits for memory sizes
*/
export const MIN_MAX_MEMORY_SIZE_MB = 2048;
export const FALLBACK_MAX_MEMORY_SIZE_MB = 4096;
/**
* Helper to format a raw byte size into a human readable label.
*/
@ -1343,23 +1326,6 @@ export class ByteSize {
// File limits
export interface IFileLimits {
readonly maxFileSize: number;
readonly maxHeapSize: number;
}
export const enum Arch {
IA32,
OTHER
}
export function getPlatformFileLimits(arch: Arch): IFileLimits {
return {
maxFileSize: arch === Arch.IA32 ? 300 * ByteSize.MB : 16 * ByteSize.GB, // https://github.com/microsoft/vscode/issues/30180
maxHeapSize: arch === Arch.IA32 ? 700 * ByteSize.MB : 2 * 700 * ByteSize.MB, // https://github.com/v8/v8/blob/5918a23a3d571b9625e5cce246bdd5b46ff7cd8b/src/heap/heap.cc#L149
};
}
export function getLargeFileConfirmationLimit(remoteAuthority?: string): number;
export function getLargeFileConfirmationLimit(uri?: URI): number;
export function getLargeFileConfirmationLimit(arg?: string | URI): number {

View File

@ -125,14 +125,8 @@ function throwIfCancelled(token: CancellationToken): boolean {
function throwIfTooLarge(totalBytesRead: number, options: ICreateReadStreamOptions): boolean {
// Return early if file is too large to load and we have configured limits
if (options?.limits) {
if (typeof options.limits.memory === 'number' && totalBytesRead > options.limits.memory) {
throw createFileSystemProviderError(localize('fileTooLargeForHeapError', "To open a file of this size, you need to restart and allow to use more memory"), FileSystemProviderErrorCode.FileExceedsMemoryLimit);
}
if (typeof options.limits.size === 'number' && totalBytesRead > options.limits.size) {
throw createFileSystemProviderError(localize('fileTooLargeError', "File is too large to open"), FileSystemProviderErrorCode.FileTooLarge);
}
if (typeof options?.limits?.size === 'number' && totalBytesRead > options.limits.size) {
throw createFileSystemProviderError(localize('fileTooLargeError', "File is too large to open"), FileSystemProviderErrorCode.FileTooLarge);
}
return true;

View File

@ -1620,54 +1620,6 @@ flakySuite('Disk File Service', function () {
assert.ok(!error);
});
test('readFile - FILE_EXCEEDS_MEMORY_LIMIT - default', async () => {
return testFileExceedsMemoryLimit();
});
test('readFile - FILE_EXCEEDS_MEMORY_LIMIT - buffered', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
return testFileExceedsMemoryLimit();
});
test('readFile - FILE_EXCEEDS_MEMORY_LIMIT - unbuffered', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
return testFileExceedsMemoryLimit();
});
test('readFile - FILE_EXCEEDS_MEMORY_LIMIT - streamed', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadStream);
return testFileExceedsMemoryLimit();
});
async function testFileExceedsMemoryLimit() {
await doTestFileExceedsMemoryLimit(false);
// Also test when the stat size is wrong
fileProvider.setSmallStatSize(true);
return doTestFileExceedsMemoryLimit(true);
}
async function doTestFileExceedsMemoryLimit(statSizeWrong: boolean) {
const resource = URI.file(join(testDir, 'index.html'));
let error: FileOperationError | undefined = undefined;
try {
await service.readFile(resource, { limits: { memory: 10 } });
} catch (err) {
error = err;
}
assert.ok(error);
if (!statSizeWrong) {
assert.ok(error instanceof TooLargeFileOperationError);
assert.ok(typeof error.size === 'number');
}
assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_EXCEEDS_MEMORY_LIMIT);
}
test('readFile - FILE_TOO_LARGE - default', async () => {
return testFileTooLarge();
});

View File

@ -35,6 +35,7 @@ import { IExplorerService } from 'vs/workbench/contrib/files/browser/files';
import { FileEditorInputSerializer, FileEditorWorkingCopyEditorHandler } from 'vs/workbench/contrib/files/browser/editors/fileEditorHandler';
import { ModesRegistry } from 'vs/editor/common/languages/modesRegistry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TextFileEditor } from 'vs/workbench/contrib/files/browser/editors/textFileEditor';
class FileUriLabelContribution implements IWorkbenchContribution {
@ -56,6 +57,18 @@ class FileUriLabelContribution implements IWorkbenchContribution {
registerSingleton(IExplorerService, ExplorerService, InstantiationType.Delayed);
// Register file editors
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create(
TextFileEditor,
TextFileEditor.ID,
nls.localize('textFileEditor', "Text File Editor")
),
[
new SyncDescriptor(FileEditorInput)
]
);
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create(
BinaryFileEditor,
@ -265,13 +278,6 @@ configurationRegistry.registerConfiguration({
'type': 'string',
'markdownDescription': nls.localize('defaultLanguage', "The default language identifier that is assigned to new files. If configured to `${activeEditorLanguage}`, will use the language identifier of the currently active text editor if any.")
},
'files.maxMemoryForLargeFilesMB': {
'type': 'number',
'default': 4096,
'minimum': 0,
'markdownDescription': nls.localize('maxMemoryForLargeFilesMB', "Controls the memory available to VS Code after restart when trying to open large files. Same effect as specifying `--max-memory=NEWSIZE` on the command line."),
included: isNative
},
'files.restoreUndoStack': {
'type': 'boolean',
'description': nls.localize('files.restoreUndoStack', "Restore the undo stack when a file is reopened."),

View File

@ -1,24 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform';
import { EditorExtensions } from 'vs/workbench/common/editor';
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IEditorPaneRegistry, EditorPaneDescriptor } from 'vs/workbench/browser/editor';
import { TextFileEditor } from 'vs/workbench/contrib/files/browser/editors/textFileEditor';
// Register file editor
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create(
TextFileEditor,
TextFileEditor.ID,
localize('textFileEditor', "Text File Editor")
),
[
new SyncDescriptor(FileEditorInput)
]
);

View File

@ -1,24 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform';
import { EditorExtensions } from 'vs/workbench/common/editor';
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IEditorPaneRegistry, EditorPaneDescriptor } from 'vs/workbench/browser/editor';
import { NativeTextFileEditor } from 'vs/workbench/contrib/files/electron-sandbox/textFileEditor';
// Register file editor
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create(
NativeTextFileEditor,
NativeTextFileEditor.ID,
nls.localize('textFileEditor', "Text File Editor")
),
[
new SyncDescriptor(FileEditorInput)
]
);

View File

@ -1,92 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { TextFileEditor } from 'vs/workbench/contrib/files/browser/editors/textFileEditor';
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
import { FileOperationError, FileOperationResult, IFileService, MIN_MAX_MEMORY_SIZE_MB, FALLBACK_MAX_MEMORY_SIZE_MB } from 'vs/platform/files/common/files';
import { createEditorOpenError } from 'vs/workbench/common/editor';
import { toAction } from 'vs/base/common/actions';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfiguration';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { INativeHostService } from 'vs/platform/native/common/native';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { IExplorerService } from 'vs/workbench/contrib/files/browser/files';
import { IProductService } from 'vs/platform/product/common/productService';
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import Severity from 'vs/base/common/severity';
import { IHostService } from 'vs/workbench/services/host/browser/host';
/**
* An implementation of editor for file system resources.
*/
export class NativeTextFileEditor extends TextFileEditor {
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IFileService fileService: IFileService,
@IPaneCompositePartService paneCompositeService: IPaneCompositePartService,
@IInstantiationService instantiationService: IInstantiationService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IStorageService storageService: IStorageService,
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
@IEditorService editorService: IEditorService,
@IThemeService themeService: IThemeService,
@IEditorGroupsService editorGroupService: IEditorGroupsService,
@ITextFileService textFileService: ITextFileService,
@INativeHostService private readonly nativeHostService: INativeHostService,
@IPreferencesService preferencesService: IPreferencesService,
@IExplorerService explorerService: IExplorerService,
@IUriIdentityService uriIdentityService: IUriIdentityService,
@IProductService private readonly productService: IProductService,
@IPathService pathService: IPathService,
@IConfigurationService configurationService: IConfigurationService,
@IHostService hostService: IHostService
) {
super(telemetryService, fileService, paneCompositeService, instantiationService, contextService, storageService, textResourceConfigurationService, editorService, themeService, editorGroupService, textFileService, explorerService, uriIdentityService, pathService, configurationService, preferencesService, hostService);
}
protected override handleSetInputError(error: Error, input: FileEditorInput, options: ITextEditorOptions | undefined): Promise<void> {
// Allow to restart with higher memory limit if the file is too large
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_EXCEEDS_MEMORY_LIMIT) {
const memoryLimit = Math.max(MIN_MAX_MEMORY_SIZE_MB, +this.textResourceConfigurationService.getValue<number>(undefined, 'files.maxMemoryForLargeFilesMB') || FALLBACK_MAX_MEMORY_SIZE_MB);
throw createEditorOpenError(localize('fileTooLargeForHeapError', "To open a file of this size, you need to restart and allow {0} to use more memory.", this.productService.nameShort), [
toAction({
id: 'workbench.action.relaunchWithIncreasedMemoryLimit', label: localize('relaunchWithIncreasedMemoryLimit', "Restart with {0} MB", memoryLimit), run: () => {
return this.nativeHostService.relaunch({
addArgs: [
`--max-memory=${memoryLimit}`
]
});
}
}),
toAction({
id: 'workbench.action.configureMemoryLimit', label: localize('configureMemoryLimit', "Configure Limit"), run: () => {
return this.preferencesService.openUserSettings({ query: 'files.maxMemoryForLargeFilesMB' });
}
}),
], {
forceMessage: true,
forceSeverity: Severity.Warning
});
}
// Fallback to handling in super type
return super.handleSetInputError(error, input, options);
}
}

View File

@ -250,10 +250,6 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
opts.execArgv.unshift('--prof');
}
if (this._environmentService.args['max-memory']) {
opts.execArgv.unshift(`--max-old-space-size=${this._environmentService.args['max-memory']}`);
}
// Catch all output coming from the extension host process
type Output = { data: string; format: string[] };
const onStdout = this._handleProcessOutputStream(this._extensionHostProcess.onStdout);

View File

@ -12,7 +12,7 @@ import { compareItemsByFuzzyScore, FuzzyScorerCache, IItemAccessor, prepareQuery
import { basename, dirname, join, sep } from 'vs/base/common/path';
import { StopWatch } from 'vs/base/common/stopwatch';
import { URI, UriComponents } from 'vs/base/common/uri';
import { Arch, getPlatformFileLimits } from 'vs/platform/files/common/files';
import { ByteSize } from 'vs/platform/files/common/files';
import { ICachedSearchStats, IFileQuery, IFileSearchProgressItem, IFileSearchStats, IFolderQuery, IProgressMessage, IRawFileMatch, IRawFileQuery, IRawQuery, IRawSearchService, IRawTextQuery, ISearchEngine, ISearchEngineSuccess, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedSearchSuccess, isFilePatternMatch, ITextQuery } from 'vs/workbench/services/search/common/search';
import { Engine as FileSearchEngine } from 'vs/workbench/services/search/node/fileSearch';
import { TextSearchEngineAdapter } from 'vs/workbench/services/search/node/textSearchAdapter';
@ -73,12 +73,18 @@ export class SearchService implements IRawSearchService {
}
private ripgrepTextSearch(config: ITextQuery, progressCallback: IProgressCallback, token: CancellationToken): Promise<ISerializedSearchSuccess> {
config.maxFileSize = getPlatformFileLimits(process.arch === 'ia32' ? Arch.IA32 : Arch.OTHER).maxFileSize;
config.maxFileSize = this.getPlatformFileLimits().maxFileSize;
const engine = new TextSearchEngineAdapter(config);
return engine.search(token, progressCallback, progressCallback);
}
private getPlatformFileLimits(): { readonly maxFileSize: number } {
return {
maxFileSize: process.arch === 'ia32' ? 300 * ByteSize.MB : 16 * ByteSize.GB
};
}
doFileSearch(config: IFileQuery, progressCallback: IProgressCallback, token?: CancellationToken): Promise<ISerializedSearchSuccess> {
return this.doFileSearchWithEngine(FileSearchEngine, config, progressCallback, token);
}

View File

@ -4,12 +4,11 @@
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals';
import { AbstractTextFileService } from 'vs/workbench/services/textfile/browser/textFileService';
import { ITextFileService, ITextFileStreamContent, ITextFileContent, IReadTextFileOptions, TextFileEditorModelState, ITextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { URI } from 'vs/base/common/uri';
import { IFileService, ByteSize, getPlatformFileLimits, Arch, IFileReadLimits } from 'vs/platform/files/common/files';
import { IFileService, IFileReadLimits } from 'vs/platform/files/common/files';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfiguration';
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
@ -79,7 +78,7 @@ export class NativeTextFileService extends AbstractTextFileService {
override async read(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileContent> {
// ensure --max-memory limit is applied
// ensure platform limits are applied
options = this.ensureLimits(options);
return super.read(resource, options);
@ -87,7 +86,7 @@ export class NativeTextFileService extends AbstractTextFileService {
override async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
// ensure --max-memory limit is applied
// ensure platform limits are applied
options = this.ensureLimits(options);
return super.readStream(resource, options);
@ -112,11 +111,6 @@ export class NativeTextFileService extends AbstractTextFileService {
ensuredLimits = ensuredOptions.limits;
}
if (typeof ensuredLimits.memory !== 'number') {
const maxMemory = this.environmentService.args['max-memory'];
ensuredLimits.memory = Math.max(typeof maxMemory === 'string' ? parseInt(maxMemory) * ByteSize.MB || 0 : 0, getPlatformFileLimits(process.arch === 'ia32' ? Arch.IA32 : Arch.OTHER).maxHeapSize);
}
return ensuredOptions;
}
}

View File

@ -109,7 +109,6 @@ import 'vs/workbench/contrib/logs/electron-sandbox/logs.contribution';
import 'vs/workbench/contrib/localization/electron-sandbox/localization.contribution';
// Explorer
import 'vs/workbench/contrib/files/electron-sandbox/files.contribution';
import 'vs/workbench/contrib/files/electron-sandbox/fileActions.contribution';
// CodeEditor Contributions

View File

@ -116,9 +116,6 @@ registerSingleton(ILanguagePackService, WebLanguagePacksService, InstantiationTy
// Logs
import 'vs/workbench/contrib/logs/browser/logs.contribution';
// Explorer
import 'vs/workbench/contrib/files/browser/files.web.contribution';
// Localization
import 'vs/workbench/contrib/localization/browser/localization.contribution';