vscode-clang
vscode-clang copied to clipboard
Heavy CPU usage when typing fast!!!
I am using Arch Linux. vscode Version 1.23.1 Commit d0182c3417d225529c6d5ad24b7572815d0de9ac Date 2018-05-10T16:04:33.747Z Shell 1.7.12 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64 I have an 8GB Ram and 1.7GHZ processor. When i type fast, my CPU become almost 100%. And when a folder with lot of files opened in the editor, then when i type fast the system freezes and i can't type anymore.
But with this extension disabled, everything seems to be working well.
Am facing the same issue here on both VSCode version 1.25.0 (insiders) and 1.24.0 (stable). Arch Linux, 6GB RAM, x64 architecture and 2.6GHz processor.
Same issue here, I have noticed that this extension spams clang processes like crazy... up to moment when VS Code freezes.
Same issue, the extension seems to spawn a lot of clang processes that eat all the CPU VsCode 1.25.1 Ubuntu 16.04, x64, 8GB RAM, Xeon 12 cores, 3.20GHz
I'm having the same issue, if I even type 2 letters the CPU goes to 90% let alone trying to type more faster, vscode spawns way too many clang process VSCode 1.25.1 Linux Mint 18.09, 8GB RAM, Intel Core i5-3210M, 3.1GHz
Solution: set: "clang.executable": "",
i found another solution: disable clang dynamnoic.
I'm using another solution:
while true
pkill clang
end
@mitaki28 Please fix this when you have time. This problem makes the extension unusable. Thanks.
Same issue here. I can only use the extension if one the options clang.completion.enabled
or clang.diagnostic.enabled
are false. Generally it is diagnostic that is the issue.
Platform: VS Code 1.28.0-Insider Arch LInux 4.14.9-arch1-1-ARCH, 8gb RAM, x64, Intel i5-6600K 3.40GHz
In case anyone is still waiting for a solution here, I, being a js newbie, propose a monkey patch :smiley:
In src/diagnostic.ts
(~/.vscode/extensions/mitaki28.vscode-clang-*/out/src/diagnostic.ts
), look for this function
export function registerDiagnosticProvider(selector: vscode.DocumentSelector, provider: DiagnosticProvider, name: string): vscode.Disposable {
let collection: vscode.DiagnosticCollection = vscode.languages.createDiagnosticCollection(name);
let cancellers = new Map<string, vscode.CancellationTokenSource>();
let subsctiptions: vscode.Disposable[] = [];
vscode.workspace.onDidChangeTextDocument((change) => {
if (!vscode.languages.match(selector, change.document)) return;
const uri = change.document.uri;
const uriStr = uri.toString();
if (cancellers.has(uriStr)) {
cancellers.get(uriStr).dispose();
}
cancellers.set(uriStr, new vscode.CancellationTokenSource);
delay(cancellers.get(uriStr).token).then(() => {
cancellers.get(uriStr).dispose();
cancellers.set(uriStr, new vscode.CancellationTokenSource);
return provider.provideDiagnostic(change.document, cancellers.get(uriStr).token);
}).then((diagnostics) => {
cancellers.get(uriStr).dispose();
cancellers.delete(uriStr);
collection.set(uri, diagnostics);
}, (_) => { /* do nothing */ });
}, null, subsctiptions);
return {
dispose() {
collection.dispose();
for (let canceller of Array.from(cancellers.values())) {
canceller.dispose();
}
vscode.Disposable.from(...subsctiptions).dispose();
}
};
}
, find the first occurrence of
if (cancellers.has(uriStr)) {
cancellers.get(uriStr).dispose();
}
and change it into
if (cancellers.has(uriStr)) {
cancellers.get(uriStr).cancel();
cancellers.get(uriStr).dispose();
}
Depending on which version the vscode extension repo adopts, line number may vary; however as for now this patch works for me, namely, pressing one key on a .c
file will not fork-bomb my computer with clang
and clang-6.0
any more.
@ThinerDAS Oh, that's right.
Now I have fixed this problem and published it.
Thank you.
@ThinerDAS Oh, that's right.
Now I have fixed this problem and published it.
Thank you.
It seems still not solved yet. version 0.2.3 has the same issue on my computer. Lot's of clang.exe fail to terminate themselves and eat up all my cpu time. This happens even if I type very slow, i.e., type a letter then wait 10 seconds then delete it, a clang.exe remains, eating up 40% of my cpu.