svn-scm icon indicating copy to clipboard operation
svn-scm copied to clipboard

Extension causes high cpu load

Open Yanpas opened this issue 6 years ago • 20 comments

  • Issue Type: Performance
  • Extension Name: svn-scm
  • Extension Version: 1.54.4
  • OS Version: Linux x64 5.0.0-27-generic
  • VSCode version: 1.38.0

johnstoncode.svn-scm-unresponsive.cpuprofile.txt

CPU-20190906T165520.186Z.cpuprofile.txt

For a long time i was using 1.48.1 with some of my edits, recently upgraded to 1.38 vscode and 1.54.4 extension without any edits. When I edit the files under version control (especially after saving) - vscode process consumes a lot of CPU. Disabling extension helps.

Find more details here: https://github.com/Microsoft/vscode/wiki/Explain:-extension-causes-high-cpu-load

Yanpas avatar Sep 06 '19 16:09 Yanpas

1.48.1 seems to be okay

Yanpas avatar Sep 06 '19 17:09 Yanpas

I'm pretty sure it's this extension that's causing a huge cpu usage. I look under htop and it's def from vscode and it's spawning a bunch of "svn status --xml --no-auth-cache" children. like a lot of them. starts out with maybe only 20 or so, but after a few minutes it becomes hundres

sirus20x6 avatar Sep 12 '19 16:09 sirus20x6

I'm encountering high CPU load as well, which is really bogging down the extension host and making other extensions nearly unusable.

Extension Version: 1.54.4 OS Version: Linux x64 5.0.0-29-generic VSCode version: 1.38.1

My cpuprofile file: johnstoncode.svn-scm-unresponsive.cpuprofile.txt

I quickly looked over the cpuprofile and from what I can tell, most of the delay is caused by liberal use of replace() in the isDescendant() function? I'm sure you have more insight, but would it be helpful to cache the results of this function if it is causing such a delay? Maybe I'm misinterpreting things here.

AHilyard avatar Sep 27 '19 22:09 AHilyard

Got same error on 1.48.1. Stack:

rejected promise not handled within 1 second: TypeError: Cannot read property 'on' of undefined
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:38
_doInvokeHandler @ rpcProtocol.ts:394
_invokeHandler @ rpcProtocol.ts:379
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:572
fire @ ipc.net.ts:449
_receiveMessage @ ipc.net.ts:729
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:588
fire @ event.ts:572
acceptChunk @ ipc.net.ts:235
_register._socket.onData.e @ ipc.net.ts:196
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94
console.ts:137 [Extension Host] stack trace: TypeError: Cannot read property 'on' of undefined	at on (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svn.js:114:20)	at exec.Promise.all.resolve (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svn.js:124:21)	at new Promise (<anonymous>)	at Svn.<anonymous> (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svn.js:122:17)	at Generator.next (<anonymous>)	at __awaiter (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svn.js:7:71)	at new Promise (<anonymous>)	at __awaiter (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svn.js:3:12)	at Svn.exec (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svn.js:82:16)	at Repository.<anonymous> (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svnRepository.js:57:29)	at Generator.next (<anonymous>)	at __awaiter (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svnRepository.js:13:71)	at new Promise (<anonymous>)	at __awaiter (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svnRepository.js:9:12)	at Repository.exec (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svnRepository.js:54:16)	at Repository.<anonymous> (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svnRepository.js:49:39)	at Generator.next (<anonymous>)	at __awaiter (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svnRepository.js:13:71)	at new Promise (<anonymous>)	at __awaiter (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svnRepository.js:9:12)	at Repository.updateInfo (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/svnRepository.js:48:16)	at Repository.<anonymous> (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/repository.js:78:35)	at Generator.next (<anonymous>)	at __awaiter (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/repository.js:13:71)	at new Promise (<anonymous>)	at __awaiter (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/repository.js:9:12)	at Repository.constructor._fsWatcher.onDidSvnAny (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/repository.js:77:44)	at events.map.event (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/util.js:21:85)	at event (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/util.js:30:91)	at event (/home/yan/.vscode/extensions/johnstoncode.svn-scm-2.48.1/out/util.js:30:91)	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:50:207)	at define.constructor.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:546:667)	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:50:207)	at u.$onFileEvent (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:547:710)	at d._doInvokeHandler (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:623:396)	at d._invokeHandler (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:623:88)	at d._receiveRequest (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:621:783)	at d._receiveOneMessage (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:620:605)	at define.constructor._protocol.onMessage.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:618:791)	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:50:207)	at v.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:186:579)	at i.constructor.e.onMessage.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:783:484)	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:50:207)	at v.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:186:579)	at x._receiveMessage (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:191:17)	at define.constructor._socketDisposables.push._socketReader.onMessage.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:188:116)	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:50:207)	at f.acceptChunk (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:184:17)	at define.constructor._register._socket.onData.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:183:372)	at Socket.t (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:192:491)	at Socket.emit (events.js:182:13)	at addChunk (_stream_readable.js:283:12)	at readableAddChunk (_stream_readable.js:264:11)	at Socket.Readable.push (_stream_readable.js:219:10)
ypeError: Cannot read property 'on' of undefined
	at on (/home/yan/.vscode/ex…48.1/out/svn.js:114)
	at exec.Promise.all.resolve (/home/yan/.vscode/ex…48.1/out/svn.js:124)
	at new Promise (<anonymous>)
	at Svn.<anonymous> (/home/yan/.vscode/ex…48.1/out/svn.js:122)
	at Generator.next (<anonymous>)
	at __awaiter (/home/yan/.vscode/ex…2.48.1/out/svn.js:7)
	at new Promise (<anonymous>)
	at __awaiter (/home/yan/.vscode/ex…2.48.1/out/svn.js:3)
	at Svn.exec (/home/yan/.vscode/ex….48.1/out/svn.js:82)
	at Repository.<anonymous> (/home/yan/.vscode/ex…svnRepository.js:57)
	at Generator.next (<anonymous>)
	at __awaiter (/home/yan/.vscode/ex…svnRepository.js:13)
	at new Promise (<anonymous>)
	at __awaiter (/home/yan/.vscode/ex…/svnRepository.js:9)
	at Repository.exec (/home/yan/.vscode/ex…svnRepository.js:54)
	at Repository.<anonymous> (/home/yan/.vscode/ex…svnRepository.js:49)
	at Generator.next (<anonymous>)
	at __awaiter (/home/yan/.vscode/ex…svnRepository.js:13)
	at new Promise (<anonymous>)
	at __awaiter (/home/yan/.vscode/ex…/svnRepository.js:9)
	at Repository.updateInfo (/home/yan/.vscode/ex…svnRepository.js:48)
	at Repository.<anonymous> (/home/yan/.vscode/ex…ut/repository.js:78)
	at Generator.next (<anonymous>)
	at __awaiter (/home/yan/.vscode/ex…ut/repository.js:13)
	at new Promise (<anonymous>)
	at __awaiter (/home/yan/.vscode/ex…out/repository.js:9)
	at Repository.constructor._fsWatcher.onDidSvnAny (/home/yan/.vscode/ex…ut/repository.js:77)
	at events.map.event (/home/yan/.vscode/ex…48.1/out/util.js:21)
	at event (/home/yan/.vscode/ex…48.1/out/util.js:30)
	at event (/home/yan/.vscode/ex…48.1/out/util.js:30)
	at u.fire (/usr/share/code/reso…onHostProcess.js:50)
	at define.constructor.e (/usr/share/code/reso…nHostProcess.js:546)
	at u.fire (/usr/share/code/reso…onHostProcess.js:50)
	at u.$onFileEvent (/usr/share/code/reso…nHostProcess.js:547)
	at d._doInvokeHandler (/usr/share/code/reso…nHostProcess.js:623)
	at d._invokeHandler (/usr/share/code/reso…nHostProcess.js:623)
	at d._receiveRequest (/usr/share/code/reso…nHostProcess.js:621)
	at d._receiveOneMessage (/usr/share/code/reso…nHostProcess.js:620)
	at define.constructor._protocol.onMessage.e (/usr/share/code/reso…nHostProcess.js:618)
	at u.fire (/usr/share/code/reso…onHostProcess.js:50)
	at v.fire (/usr/share/code/reso…nHostProcess.js:186)
	at i.constructor.e.onMessage.e (/usr/share/code/reso…nHostProcess.js:783)
	at u.fire (/usr/share/code/reso…onHostProcess.js:50)
	at v.fire (/usr/share/code/reso…nHostProcess.js:186)
	at x._receiveMessage (/usr/share/code/reso…nHostProcess.js:191)
	at define.constructor._socketDisposables.push._socketReader.onMessage.e (/usr/share/code/reso…nHostProcess.js:188)
	at u.fire (/usr/share/code/reso…onHostProcess.js:50)
	at f.acceptChunk (/usr/share/code/reso…nHostProcess.js:184)
	at define.constructor._register._socket.onData.e (/usr/share/code/reso…nHostProcess.js:183)
	at Socket.t (/usr/share/code/reso…nHostProcess.js:192)
	at Socket.emit (events.js:182)
	at addChunk (_stream_readable.js:283)
	at readableAddChunk (_stream_readable.js:264)
	at Socket.Readable.push (_stream_readable.js:219)
	at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94)

image

Yanpas avatar Oct 02 '19 17:10 Yanpas

@AHilyard "liberal use of replace()" :D love it. But yes correct

JohnstonCode avatar Oct 03 '19 14:10 JohnstonCode

getOpenRepository is what is causing the performance hit. Im assuming very large checked out projects and that is why only some people are having the issue

JohnstonCode avatar Oct 03 '19 14:10 JohnstonCode

Yep, my repo is very big. Also a lot of svn processes

Yanpas avatar Oct 03 '19 15:10 Yanpas

Does your project have many externals?

JohnstonCode avatar Oct 03 '19 15:10 JohnstonCode

No, it doesn't have any. With 1.54.4 I notice it more often, since I start editing some file, maybe svn diff is called too often.

Yanpas avatar Oct 03 '19 15:10 Yanpas

Think i might have a fix for this

JohnstonCode avatar Oct 03 '19 15:10 JohnstonCode

The project I am working with is large and has many externals, but I have the same issue with other large projects with no externals.

AHilyard avatar Oct 03 '19 17:10 AHilyard

@AHilyard Can you try setting svn.detectExternals and svn.detectIgnored to false and see if that helps

JohnstonCode avatar Oct 07 '19 14:10 JohnstonCode

@JohnstonCode Setting both of those to false has seemed to make a big difference, yes.

AHilyard avatar Oct 08 '19 15:10 AHilyard

@edgardmessias Do you think scanExternals and scanIgnored should be debounced?

JohnstonCode avatar Oct 10 '19 09:10 JohnstonCode

Not good, I think we need improve the idea of check repository owner of file, maybe we can use a map with full file path.

edgardmessias avatar Oct 10 '19 13:10 edgardmessias

Im not sure what you mean

JohnstonCode avatar Oct 10 '19 15:10 JohnstonCode

Each repository has a group of ignored files, but, the Model try find repository owner of current file. On each ignored file, the model try again and again, building a full path and checking all files on each repository.

My idea: create a map of files in repository <path>:<file info>, and refactor the model to check the path exists

edgardmessias avatar Oct 10 '19 22:10 edgardmessias

Im not sure how that would help. Wouldent an isDescendant check still need to happen?

JohnstonCode avatar Nov 08 '19 16:11 JohnstonCode

According to this profile sorting inside openRepositoriesSorted takes a lot of time. exthsotporfile.txt.

SourceControlManager.open is the only way to increase size of array.

In the top of the bottom of the stack there is onPossibleSvnRepositoryChange, specifically: const possibleSvnRepositoryPath = uri.fsPath.replace(/\.svn.*$/, ""); line 156.

I have a lot of svn like files in my repository: $ find ~/ssd/work/trunk/.svn/ -name '*svn*' | wc -l 54088. I guess they are caught by this event sometimes.

yanpas@svn-scm$ find ~/ssd/work/trunk/.svn/ -name '*svn*' | head -n 20
/home/yanpas//ssd/work/trunk/.svn/
/home/yanpas//ssd/work/trunk/.svn/tmp/svn-PQz2VL
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea639c303ac7496275849fb456ec0975723bcccd.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea6c8b75475cf428552e053e593c68d6a99b2fce.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea534875690e22c1cb245f51f94cdae4ae44a910.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/eabd426eca9a45f7e5888408051b6a1f857baa19.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/eaf6db653eb1ff40782608e96ca912899962e156.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea322d9d041790754e0fb0f8e6d232056b887381.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea8a54f76f3abd5a02fcffd6ebeecbdf35019ba2.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea024516d5e35b76283d0cc1e415cbeef7fb05fb.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea81f73d3ec01950e5434607d76f487a87613812.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ead35faab60f2adcd2ad3e6f12524860e1873c99.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea11082558429cd9b1cd945562251e1ce0e2f8fa.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea64a72176b172275e47751ea6ebb09038958c7a.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea4e252c4fe1cde3d38d0b812494e8f1761b554b.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea5d3504daed1fb1e87dbb279e4e5f805b4fd873.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/eaabfc963bef43862d469a77f6e6883247daa3b4.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea1098a4a0850eeeb57c7b3b9a26873d4ba8b3e0.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/ea154f954f6d2f2c60483162f02cca298f8c9a83.svn-base
/home/yanpas//ssd/work/trunk/.svn/pristine/ea/eae4f6bf5aadf153104efd3817ef4f1d050b1988.svn-base

Yanpas avatar Mar 26 '20 17:03 Yanpas

Found the root cause: it's java extension, when you edit files it constantly recompiles classes all over the project.

Yanpas avatar Apr 15 '20 22:04 Yanpas