About Monkey 2 › Forums › Monkey 2 Projects › Ted2Go IDE
This topic contains 596 replies, has 46 voices, and was last updated by 
 nerobot 3 months ago.
- 
		AuthorPosts
 - 
		
			
				
August 28, 2017 at 11:55 pm #10080
nerobot, wonder if you could have a look at CPU usage?
I noticed while running this code…
http://monkeycoder.co.nz/forums/topic/mark-troubling-memory-leak/#post-10079
… that CPU usage is a constant 5-7% CPU, which is quite a lot for an application that should be doing almost nothing (while my program runs)!
I’m on an AMD FX 6350 (approx 3.9 to 4.2 GHz as standard), probably a few years old now, but I know from past conversations that this is likely to be in the region of 10-15% CPU on slower processors (probably a lot more on Raspberry Pi, etc)…
I realise it’s basically using a ‘game’ app framework, but my understanding is that mojo should still just sit and wait for OS events, rather than constantly update, so I wonder where the CPU usage might be coming from if that’s correct.
August 29, 2017 at 2:45 am #10081I’ve been using the dev branch from yesterday, and it sits between 40% and 50% CPU use when I’m not doing anything. Don’t think this happened in whatever previous version I was using.
MacOS, quad core processor laptop.
August 29, 2017 at 4:49 am #10087I always liked the Blitz help being on a tab in the IDE, rather than having to launch a separate browser and wait for the page to load, etc
There is a Help tab near to project browser, where you can type words to find.
CPU usage… There is a method in ted2go sources:
Monkey1234567891011121314151617Method OnAppIdle()_docsManager.Update()_fileActions.Update()_editActions.Update()_findActions.Update()_buildActions.Update()_forceStop.Enabled=_buildConsole.Running Or _outputConsole.Running_saveItem.SetIcon( _fileActions.save.Enabled ? 1 Else 0 )_saveAllItem.SetIcon( _fileActions.saveAll.Enabled ? 1 Else 0 )App.Idle+=OnAppIdleGCCollect() 'thrash that GC!Endwhich runs every time app is idle (endless “game loop” is here).
What will happen if I comment GCCollect() ?
August 29, 2017 at 5:10 am #10089You should definitely comment out GCCollect(), although if the app is idle it’s probably not hurting much.
I’ve also just experimented a bit with adding optional clip rect params to App.RequestRender (defaults to entire window) and View.RequestRender (defaults to view bounds, view+border etc). This appears to be working quite well so far (window repainting is no longer always ALL the window) but needs a lot more work. At the very least, it should mean entire TextView (currently entire window) isn’t redrawn everytime cursor blinks!
Reducing CPU usage is likely to be an ongoing mission that will likely involve myself and nerobot working together on it over time. I don’t actually have any complaints re: ted2go performance myself, it uses about 5% on Windows 10, 10% on macos and I’m OK with that. Although it’s true I don’t use the ‘micro view’…
August 29, 2017 at 6:12 am #10090If we do nothing – cpu usage can be significatntly less because of SDL_WaitEvent().
But if we just move mouse pointer – there is some extra work.
One design concept I disagree is relayout whole app each frame. Maybe that’a a drop in the sea..
I’ve also just experimented a bit with adding optional clip rect params to App.RequestRender
It sounds super-cool!
If you’ll use Min( clipRect,appClipRect ) inside of TextView to decrease rendered lines..
So I’m waiting what do you do in the result.
August 29, 2017 at 6:15 am #10091To the people above that mentions high CPU usage, is that cause of the CodeMap?
Are you guys using newest version with the CodeMap improvements?The CodeMap now renders everything in a single pass, and since that update my Ted2Go has acted the same with and without the CodeMap.
Here’s the new version with the CodeMap enabled:
August 29, 2017 at 6:17 am #10092Although it’s true I don’t use the ‘micro view’…
Hah! As soon as I read that, I turned off the Codemap in the preferences and… CPU usage went from over 40% to… about 2% most of the time!
August 29, 2017 at 7:16 am #10093Just tested quickly — yep, it’s the codemap! Goes to 0-1% here when turned off, mostly 0%!
August 29, 2017 at 7:18 am #10094I’ve already confirmed it’s the CodeMap a few posts back hehe
http://monkeycoder.co.nz/forums/topic/ted2go-fork/page/26/#post-10063But are you guys using the new CodeMap, the one that renders everything in one pass?
Since that update the CodeMap hardly uses any CPU on my machine.At Ted2Go 2.5 the improved CodeMap rendering is included.
August 29, 2017 at 7:43 am #10095One design concept I disagree is relayout whole app each frame. Maybe that’a a drop in the sea..
This would defnitely be nice to improve on, but I think really it’s just a drop in the sea.
Try adding this at the top of the LayoutWindow method in window.monkey2:
Monkey12If Keyboard.KeyDown( Key.F9 ) ReturnHere, it makes no apparent difference to CPU usage whether or not I hold down F9. If layout was having any kind of major impact, holding down F9 should reduce CPU usage, right? You can tell it’s working too by holding down F9 and resizing the window.
So codemap looks like it’s the major CPU slayer – I suspected it wasn’t gonna be quite that easy! This should probably be pre-rendered to a separate image, and updated only when TextView emits LinesModified() so you’re only drawing the lines you need to. Offscreen image could even be double buffered so you ‘insert’ and ‘delete’ range of lines via DrawImage from current buffer (advanced!).
Just pre-rendering the codemap alone should make a big impact anyway, even if you don’t get too fancy. Its using a lot of CPU even if you’re not typing, so I assume you’re re-rendering the entire codemap all the time? Just updating a pre-rendered version when the document changes should be a big improvement on its own.
Just read Hezkore’s bit – is the new codemap in ted2go master branch? If so I’ll pull it ASAP and include in the next release.
This is also starting to make a really good case for the ‘profile’ config I’ve wanted to add for ages. It would be much nicer if we could just see what’s taking the most time visually!
August 29, 2017 at 8:46 am #10096The First
I tried to render codemap into image by textview changed only.
You can look and try it grabbing codemap_dev branch.
I see that this version eat more CPU when scrolling doc. Because of creation new canvas every render (or why?)
Or maybe I took mistake somewhere?
The Second
Why are you looking at task manager? Please wait for a while (10 sec or more) – ide parse all modules at startup and use extra cpu for that.
August 29, 2017 at 8:48 am #10097Just read Hezkore’s bit – is the new codemap in ted2go master branch? If so I’ll pull it ASAP and include in the next release.
Yes. Current master is v2.5 with new codemap.
August 29, 2017 at 10:30 am #10099Maybe create the CodeMap rendering canvas at start and don’t destroy it after rendering?
Clearing a canvas is pretty heavy though, so it’d probably be best if you just draw over everything each time you render it so no clear is needed.August 29, 2017 at 10:32 am #10100Canvas is a local variable here – it should be GC collected when exit from render – render occur only when textview has changes.
Image live until resize codemap – by moving / show / hide debug consoles.
EDIT: I tried to store canvas as field method and recreate only when image, have no appreciable effect.
August 29, 2017 at 10:36 am #10101Yeah but it’d be easier on the CPU if you didn’t didn’t create it each time it needs to be rendered, keep the canvas global.
But ideally, this should be done to the TextFieldView (not just CodeMap) cause CodeView and CodeMapView would all get this improvement then! - 
		AuthorPosts
 
You must be logged in to reply to this topic.