Skip to content

Commit 827448d

Browse files
Merge branch 'develop'
2 parents 791df1d + e90edbd commit 827448d

File tree

34 files changed

+301
-131
lines changed

34 files changed

+301
-131
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ Document some advanced types so users may try them out and provide feedback. The
1818

1919
IDL 9.1 introduces new, command-line based progress bars. We have a first-pass of support for these progress bars inside IDL Notebooks.
2020

21+
## 4.6.2 - September 2024
22+
23+
Changed the language server startup process to remove all files from memory after initial startup. This reduces RAM by 0.25-0.5 GB of memory after startup, depending on the volume of code in workspaces and on your path.
24+
25+
When we clean up the language server (happens every 5 minutes), we now check our in-memory cache and remove any files that haven't been accessed recently. Helps reduce overall RAM when VSCode is open for long periods at a time.
26+
27+
Changed the way that the language server sends work to the threads that parse code. The main difference is that we no longer send the parsed version of code back to the main thread which we were doing.
28+
29+
For large files, this had a significant impact on perceived performance as the worker threads could get locked serializing and de-serializing objects (also leads to more memory usage). Now, large files like slicer3.pro which are included in the IDL installation, provide auto-complete and hover help in about ~0.5 seconds instead of 5+ seconds.
30+
31+
Fixed an issue where, from the JSON settings editor, a valid extension setting would be highlighted as being an incorrect value.
32+
33+
Fixed an issue where the "don't ask again" options didn't honor your choice for using IDL as the formatter.
34+
2135
## 4.6.1 - September 2024
2236

2337
Added layer controls to the Notebook Map.

apps/package-json/src/contributes/config/questions-config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,32 @@ export function AddQuestionsConfig(nls: IPackageNLS) {
4242
properties: {
4343
forIDLDir: {
4444
type: 'boolean',
45-
default: false,
4645
description: TranslationFromConfiguration(
4746
IDL_EXTENSION_CONFIG_KEYS.dontAskForIDLDir,
4847
nls
4948
),
5049
},
5150
forIconChange: {
5251
type: 'boolean',
53-
default: false,
5452
description: TranslationFromConfiguration(
5553
IDL_EXTENSION_CONFIG_KEYS.dontAskForIconChange,
5654
nls
5755
),
5856
},
5957
forFormatterChange: {
6058
type: 'boolean',
61-
default: false,
6259
description: TranslationFromConfiguration(
6360
IDL_EXTENSION_CONFIG_KEYS.dontAskForFormatterChange,
6461
nls
6562
),
6663
},
64+
toOpenDocs: {
65+
type: 'boolean',
66+
description: TranslationFromConfiguration(
67+
IDL_EXTENSION_CONFIG_KEYS.dontAskToOpenDocs,
68+
nls
69+
),
70+
},
6771
// toInitConfig: {
6872
// type: 'boolean',
6973
// default: false,

apps/parsing-worker/src/main.ts

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ import {
77
ChangeDetection,
88
GetCompletionRecipes,
99
GetHoverHelpLookup,
10+
GetParsedPROCode,
1011
GetSyntaxProblems,
1112
IDL_INDEX_OPTIONS,
1213
IDLIndex,
1314
ReduceGlobals,
1415
} from '@idl/parsing/index';
15-
import { RemoveScopeDetail } from '@idl/parsing/syntax-tree';
16+
import {
17+
IParsedLightWeight,
18+
RemoveScopeDetail,
19+
} from '@idl/parsing/syntax-tree';
1620
import { IDL_TRANSLATION } from '@idl/translation';
1721
import {
1822
ChangeDetectionResponse,
@@ -107,7 +111,8 @@ client.on(
107111
LSP_WORKER_THREAD_MESSAGE_LOOKUP.MIGRATE_CODE,
108112
async (message, cancel) => {
109113
// index the file
110-
const parsed = await WORKER_INDEX.getParsedProCode(
114+
const parsed = await GetParsedPROCode(
115+
WORKER_INDEX,
111116
message.file,
112117
message.code,
113118
cancel
@@ -179,7 +184,8 @@ client.on(
179184
/**
180185
* Clean up and return memory usage
181186
*/
182-
client.on(LSP_WORKER_THREAD_MESSAGE_LOOKUP.CLEAN_UP, async () => {
187+
client.on(LSP_WORKER_THREAD_MESSAGE_LOOKUP.CLEAN_UP, async (message) => {
188+
await WORKER_INDEX.clearParsedCache(message?.all);
183189
await WORKER_INDEX.cleanUp();
184190
});
185191

@@ -247,18 +253,23 @@ client.on(
247253
LSP_WORKER_THREAD_MESSAGE_LOOKUP.PARSE_FILE,
248254
async (message, cancel) => {
249255
// index the file
250-
const parsed = await WORKER_INDEX.getParsedProCode(
256+
const parsed = await GetParsedPROCode(
257+
WORKER_INDEX,
251258
message.file,
252259
WORKER_INDEX.getFileStrings(message.file),
253260
cancel,
254261
message
255262
);
256263

257-
// make non-circular
258-
RemoveScopeDetail(parsed, cancel, true);
264+
const lightParsed: IParsedLightWeight = {
265+
disabledProblems: parsed.disabledProblems,
266+
global: parsed.global,
267+
parseProblems: parsed.parseProblems,
268+
postProcessProblems: parsed.postProcessProblems,
269+
};
259270

260271
// return
261-
return parsed;
272+
return lightParsed;
262273
}
263274
);
264275

@@ -269,7 +280,9 @@ client.on(
269280
LSP_WORKER_THREAD_MESSAGE_LOOKUP.PARSE_CODE,
270281
async (message, cancel) => {
271282
// index the file
272-
const parsed = await WORKER_INDEX.getParsedProCode(
283+
284+
const parsed = await GetParsedPROCode(
285+
WORKER_INDEX,
273286
message.file,
274287
message.code,
275288
cancel,
@@ -279,8 +292,15 @@ client.on(
279292
// make non-circular
280293
RemoveScopeDetail(parsed, cancel, true);
281294

295+
const lightParsed: IParsedLightWeight = {
296+
disabledProblems: parsed.disabledProblems,
297+
global: parsed.global,
298+
parseProblems: parsed.parseProblems,
299+
postProcessProblems: parsed.postProcessProblems,
300+
};
301+
282302
// return
283-
return parsed;
303+
return lightParsed;
284304
}
285305
);
286306

@@ -390,12 +410,12 @@ client.on(
390410
/**
391411
* Skip if we dont have a file. Could happen from parsing errors
392412
*/
393-
if (!WORKER_INDEX.tokensByFile.has(files[i])) {
413+
if (!WORKER_INDEX.parsedCache.has(files[i])) {
394414
continue;
395415
}
396416

397417
// save lines
398-
resp.lines += WORKER_INDEX.tokensByFile.lines(files[i]);
418+
resp.lines += WORKER_INDEX.parsedCache.lines(files[i]);
399419

400420
// track globals
401421
resp.globals[files[i]] = WORKER_INDEX.getGlobalsForFile(files[i]);
@@ -457,18 +477,20 @@ client.on(
457477
LSP_WORKER_THREAD_MESSAGE_LOOKUP.GET_NOTEBOOK_CELL,
458478
async (message, cancel) => {
459479
// get parsed code and return
460-
const parsed = await WORKER_INDEX.getParsedProCode(
480+
const parsed = await GetParsedPROCode(
481+
WORKER_INDEX,
461482
message.file,
462483
message.code,
463484
cancel
464485
);
465486

466-
// make non-circular
467-
if (parsed !== undefined) {
468-
RemoveScopeDetail(parsed, cancel, true);
469-
}
470-
471-
return parsed;
487+
const lightParsed: IParsedLightWeight = {
488+
disabledProblems: parsed.disabledProblems,
489+
global: parsed.global,
490+
parseProblems: parsed.parseProblems,
491+
postProcessProblems: parsed.postProcessProblems,
492+
};
493+
return lightParsed;
472494
}
473495
);
474496

@@ -481,7 +503,7 @@ client.on(
481503
/** Get files */
482504
const files = Array.isArray(message.files)
483505
? message.files
484-
: WORKER_INDEX.tokensByFile.allFiles();
506+
: WORKER_INDEX.parsedCache.allFiles();
485507

486508
// post process, no change detection
487509
const missing = await WORKER_INDEX.postProcessProFiles(
@@ -511,12 +533,12 @@ client.on(
511533
/**
512534
* Skip if we dont have a file. Could happen from parsing errors
513535
*/
514-
if (!WORKER_INDEX.tokensByFile.has(files[i])) {
536+
if (!WORKER_INDEX.parsedCache.has(files[i])) {
515537
continue;
516538
}
517539

518540
// save lines
519-
resp.lines += WORKER_INDEX.tokensByFile.lines(files[i]);
541+
resp.lines += WORKER_INDEX.parsedCache.lines(files[i]);
520542

521543
// populate problems
522544
resp.problems[files[i]] = problems[files[i]] || [];
@@ -559,7 +581,7 @@ client.on(
559581
await WORKER_INDEX.removeWorkspaceFiles(message.files, false);
560582

561583
/** Get files that we manage */
562-
const ourFiles = WORKER_INDEX.tokensByFile.allFiles();
584+
const ourFiles = WORKER_INDEX.parsedCache.allFiles();
563585

564586
// post process all of our files again
565587
const missing = await WORKER_INDEX.postProcessProFiles(
@@ -588,7 +610,7 @@ client.on(
588610
/**
589611
* Skip if we dont have a file. Could happen from parsing errors
590612
*/
591-
if (!WORKER_INDEX.tokensByFile.has(ourFiles[i])) {
613+
if (!WORKER_INDEX.parsedCache.has(ourFiles[i])) {
592614
continue;
593615
}
594616

libs/assembling/assembler/src/lib/assembler-with-index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FormatterType, IAssemblerInputOptions } from '@idl/assembling/config';
22
import { CancellationToken } from '@idl/cancellation-tokens';
3-
import { IDLIndex } from '@idl/parsing/index';
3+
import { GetParsedPROCode, IDLIndex } from '@idl/parsing/index';
44

55
import { Assembler } from './assembler';
66

@@ -15,7 +15,7 @@ export async function AssembleWithIndex<T extends FormatterType>(
1515
formatting?: Partial<IAssemblerInputOptions<T>>
1616
): Promise<string | undefined> {
1717
// get the tokens for our file
18-
const parsed = await index.getParsedProCode(file, code, cancel);
18+
const parsed = await GetParsedPROCode(index, file, code, cancel);
1919

2020
// format and return
2121
return Assembler(parsed, cancel, formatting);

libs/parsing/index/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from './lib/auto-complete/get-completion-recipes';
22
export * from './lib/change-detection/change-detection';
3+
export * from './lib/get-parsed/get-parsed-pro-code';
34
export * from './lib/global-index.class';
45
export * from './lib/global-index.interface';
56
export * from './lib/helpers/get-routine';

libs/parsing/index/src/lib/auto-complete/get-completion-recipes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
} from '@idl/types/auto-complete';
3434
import { Position } from 'vscode-languageserver/node';
3535

36+
import { GetParsedPROCode } from '../get-parsed/get-parsed-pro-code';
3637
import { GetTypeBefore } from '../helpers/get-type-before';
3738
import { IDLIndex } from '../idl-index.class';
3839
import { GetCompileOptCompletionOptions } from './completion-for/completion-compile-opts';
@@ -103,7 +104,8 @@ export async function GetCompletionRecipes(
103104
const recipes: AutoCompleteRecipe<AutoCompleteType>[] = [];
104105

105106
// get the tokens for our file
106-
const parsed = await index.getParsedProCode(
107+
const parsed = await GetParsedPROCode(
108+
index,
107109
file,
108110
code,
109111
new CancellationToken(),

libs/parsing/index/src/lib/change-detection/change-detection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export function ChangeDetection(
2727
const missingFiles: string[] = [];
2828

2929
/** Get the current indexed files */
30-
const files = index.tokensByFile.allFiles();
30+
const files = index.parsedCache.allFiles();
3131

3232
// process each file
3333
for (let z = 0; z < files.length; z++) {
3434
// get our parsed file
35-
const uses = index.tokensByFile.uses(files[z]);
35+
const uses = index.parsedCache.uses(files[z]);
3636

3737
// check for a match
3838
for (let i = 0; i < changed.length; i++) {
@@ -56,7 +56,7 @@ export function ChangeDetection(
5656
PostProcessParsed(
5757
index,
5858
postProcessThese[z],
59-
index.tokensByFile.get(postProcessThese[z]),
59+
index.parsedCache.get(postProcessThese[z]),
6060
token
6161
);
6262
} catch (err) {

libs/parsing/index/src/lib/get-parsed/get-parsed-notebook-cell.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export async function GetParsedNotebookCell(
3737
}
3838

3939
// check if we have already parsed the file
40-
if (index.tokensByFile.has(cellFile)) {
41-
if (index.tokensByFile.checksumMatches(cellFile, checksum)) {
42-
return index.tokensByFile.get(cellFile);
40+
if (index.parsedCache.has(cellFile)) {
41+
if (index.parsedCache.checksumMatches(cellFile, checksum)) {
42+
return index.parsedCache.get(cellFile);
4343
}
4444
}
4545

libs/parsing/index/src/lib/get-parsed/get-parsed-pro-code.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ export async function GetParsedPROCode(
6969
}
7070

7171
// check if we have the file in our cache and it matches our checksum
72-
if (index.tokensByFile.has(file)) {
73-
if (index.tokensByFile.checksumMatches(file, checksum)) {
74-
return index.tokensByFile.get(file);
72+
if (index.parsedCache.has(file)) {
73+
if (index.parsedCache.checksumMatches(file, checksum)) {
74+
return index.parsedCache.get(file);
7575
}
7676
}
7777

@@ -107,7 +107,7 @@ export async function GetParsedPROCode(
107107
const newPending: IGetParsedPROCodePending = {
108108
checksum,
109109
token: resp.token,
110-
promise: resp.response,
110+
promise: resp.response as any,
111111
};
112112

113113
// save new pending file
@@ -144,7 +144,7 @@ export async function GetParsedPROCode(
144144
const newPending: IGetParsedPROCodePending = {
145145
checksum,
146146
token: resp.token,
147-
promise: resp.response,
147+
promise: resp.response as any,
148148
};
149149

150150
// save new pending file
@@ -176,7 +176,7 @@ export async function GetParsedPROCode(
176176
}
177177

178178
// make sure that we never cache in memory if we are the main thread
179-
index.tokensByFile.remove(file);
179+
index.parsedCache.remove(file);
180180

181181
// return the tokens from the worker
182182
return current;

libs/parsing/index/src/lib/helpers/get-code-semantic-tokens.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export async function GetCodeSemanticTokens(
2626
/**
2727
* Check if it is in our lookup
2828
*/
29-
case index.tokensByFile.has(file):
30-
return index.tokensByFile.semantic(file);
29+
case index.parsedCache.has(file):
30+
return index.parsedCache.semantic(file);
3131

3232
/**
3333
* Parse to get the outline

0 commit comments

Comments
 (0)