From 6d5b85427d99e77092a3621dbace765247b5271a Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 18 Apr 2023 07:32:23 +0200 Subject: [PATCH] debt - remove unsupported `max_old_space_size` option (#180183) --- cli/src/commands/args.rs | 7 -- resources/completions/bash/code | 5 +- resources/completions/zsh/_code | 1 - src/main.js | 6 -- src/vs/code/node/cli.ts | 9 -- src/vs/platform/environment/common/argv.ts | 1 - src/vs/platform/environment/node/argv.ts | 1 - .../platform/environment/node/argvHelper.ts | 6 -- src/vs/platform/files/common/fileService.ts | 16 +--- src/vs/platform/files/common/files.ts | 36 +------- src/vs/platform/files/common/io.ts | 10 +- .../node/diskFileService.integrationTest.ts | 48 ---------- .../files/browser/files.contribution.ts | 20 ++-- .../files/browser/files.web.contribution.ts | 24 ----- .../electron-sandbox/files.contribution.ts | 24 ----- .../files/electron-sandbox/textFileEditor.ts | 92 ------------------- .../localProcessExtensionHost.ts | 4 - .../services/search/node/rawSearchService.ts | 10 +- .../electron-sandbox/nativeTextFileService.ts | 12 +-- src/vs/workbench/workbench.desktop.main.ts | 1 - src/vs/workbench/workbench.web.main.ts | 3 - 21 files changed, 31 insertions(+), 305 deletions(-) delete mode 100644 src/vs/workbench/contrib/files/browser/files.web.contribution.ts delete mode 100644 src/vs/workbench/contrib/files/electron-sandbox/files.contribution.ts delete mode 100644 src/vs/workbench/contrib/files/electron-sandbox/textFileEditor.ts diff --git a/cli/src/commands/args.rs b/cli/src/commands/args.rs index 49c07803a8e..8687819f893 100644 --- a/cli/src/commands/args.rs +++ b/cli/src/commands/args.rs @@ -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, - /// 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()); } diff --git a/resources/completions/bash/code b/resources/completions/bash/code index c9e4b167309..9f1b3d682d3 100644 --- a/resources/completions/bash/code +++ b/resources/completions/bash/code @@ -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 diff --git a/resources/completions/zsh/_code b/resources/completions/zsh/_code index 087ea61f56a..97d163c13c3 100644 --- a/resources/completions/zsh/_code +++ b/resources/completions/zsh/_code @@ -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' ) diff --git a/src/main.js b/src/main.js index 8149f4082a1..f777d4e8a4a 100644 --- a/src/main.js +++ b/src/main.js @@ -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' ] }); diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index 01f5c343bc6..ecec7074911 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -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 { }); } - 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 diff --git a/src/vs/platform/environment/common/argv.ts b/src/vs/platform/environment/common/argv.ts index 3fd7438bad4..75f79f3fa59 100644 --- a/src/vs/platform/environment/common/argv.ts +++ b/src/vs/platform/environment/common/argv.ts @@ -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; diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 8f94ff9c6c4..b858cbddc9d 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -110,7 +110,6 @@ export const OPTIONS: OptionDescriptions> = { '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 }, diff --git a/src/vs/platform/environment/node/argvHelper.ts b/src/vs/platform/environment/node/argvHelper.ts index 610ba3d774a..85ba80151bd 100644 --- a/src/vs/platform/environment/node/argvHelper.ts +++ b/src/vs/platform/environment/node/argvHelper.ts @@ -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; } diff --git a/src/vs/platform/files/common/fileService.ts b/src/vs/platform/files/common/fileService.ts index 28c71b42042..f02b7d159dd 100644 --- a/src/vs/platform/files/common/fileService.ts +++ b/src/vs/platform/files/common/fileService.ts @@ -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); } } diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index 687f42370ce..113618a2b79 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -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 { diff --git a/src/vs/platform/files/common/io.ts b/src/vs/platform/files/common/io.ts index a03975d71f6..2d9a5544a92 100644 --- a/src/vs/platform/files/common/io.ts +++ b/src/vs/platform/files/common/io.ts @@ -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; diff --git a/src/vs/platform/files/test/node/diskFileService.integrationTest.ts b/src/vs/platform/files/test/node/diskFileService.integrationTest.ts index e44548e3985..b0a68fcb60d 100644 --- a/src/vs/platform/files/test/node/diskFileService.integrationTest.ts +++ b/src/vs/platform/files/test/node/diskFileService.integrationTest.ts @@ -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(); }); diff --git a/src/vs/workbench/contrib/files/browser/files.contribution.ts b/src/vs/workbench/contrib/files/browser/files.contribution.ts index ffd76194863..9618b193df9 100644 --- a/src/vs/workbench/contrib/files/browser/files.contribution.ts +++ b/src/vs/workbench/contrib/files/browser/files.contribution.ts @@ -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(EditorExtensions.EditorPane).registerEditorPane( + EditorPaneDescriptor.create( + TextFileEditor, + TextFileEditor.ID, + nls.localize('textFileEditor', "Text File Editor") + ), + [ + new SyncDescriptor(FileEditorInput) + ] +); + Registry.as(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."), diff --git a/src/vs/workbench/contrib/files/browser/files.web.contribution.ts b/src/vs/workbench/contrib/files/browser/files.web.contribution.ts deleted file mode 100644 index 2a8263831fd..00000000000 --- a/src/vs/workbench/contrib/files/browser/files.web.contribution.ts +++ /dev/null @@ -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(EditorExtensions.EditorPane).registerEditorPane( - EditorPaneDescriptor.create( - TextFileEditor, - TextFileEditor.ID, - localize('textFileEditor', "Text File Editor") - ), - [ - new SyncDescriptor(FileEditorInput) - ] -); diff --git a/src/vs/workbench/contrib/files/electron-sandbox/files.contribution.ts b/src/vs/workbench/contrib/files/electron-sandbox/files.contribution.ts deleted file mode 100644 index 53db0d4a555..00000000000 --- a/src/vs/workbench/contrib/files/electron-sandbox/files.contribution.ts +++ /dev/null @@ -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(EditorExtensions.EditorPane).registerEditorPane( - EditorPaneDescriptor.create( - NativeTextFileEditor, - NativeTextFileEditor.ID, - nls.localize('textFileEditor', "Text File Editor") - ), - [ - new SyncDescriptor(FileEditorInput) - ] -); diff --git a/src/vs/workbench/contrib/files/electron-sandbox/textFileEditor.ts b/src/vs/workbench/contrib/files/electron-sandbox/textFileEditor.ts deleted file mode 100644 index 070274c21b9..00000000000 --- a/src/vs/workbench/contrib/files/electron-sandbox/textFileEditor.ts +++ /dev/null @@ -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 { - - // Allow to restart with higher memory limit if the file is too large - if ((error).fileOperationResult === FileOperationResult.FILE_EXCEEDS_MEMORY_LIMIT) { - const memoryLimit = Math.max(MIN_MAX_MEMORY_SIZE_MB, +this.textResourceConfigurationService.getValue(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); - } -} diff --git a/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts b/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts index b7bbe429bb6..b022ce95dcd 100644 --- a/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts +++ b/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts @@ -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); diff --git a/src/vs/workbench/services/search/node/rawSearchService.ts b/src/vs/workbench/services/search/node/rawSearchService.ts index 622a04195d6..608b8f2eb96 100644 --- a/src/vs/workbench/services/search/node/rawSearchService.ts +++ b/src/vs/workbench/services/search/node/rawSearchService.ts @@ -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 { - 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 { return this.doFileSearchWithEngine(FileSearchEngine, config, progressCallback, token); } diff --git a/src/vs/workbench/services/textfile/electron-sandbox/nativeTextFileService.ts b/src/vs/workbench/services/textfile/electron-sandbox/nativeTextFileService.ts index 62275369af4..0565862a337 100644 --- a/src/vs/workbench/services/textfile/electron-sandbox/nativeTextFileService.ts +++ b/src/vs/workbench/services/textfile/electron-sandbox/nativeTextFileService.ts @@ -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 { - // 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 { - // 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; } } diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts index f95f43c8fd8..4fb365f2288 100644 --- a/src/vs/workbench/workbench.desktop.main.ts +++ b/src/vs/workbench/workbench.desktop.main.ts @@ -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 diff --git a/src/vs/workbench/workbench.web.main.ts b/src/vs/workbench/workbench.web.main.ts index caaabcf3778..b61bfdc854b 100644 --- a/src/vs/workbench/workbench.web.main.ts +++ b/src/vs/workbench/workbench.web.main.ts @@ -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';