DOSBOX eating up CPU

General information and assistance with DOSBox.

DOSBOX eating up CPU

Postby stecdose » 2018-11-06 @ 14:08

Hi,

when I start DOSBOX one of my two cores goes up to 100% usage by dosbox. When I start dosidle in dosbox, this goes down to 80%. On 100% the fan in my laptop starts to make loud noise. On 80% it is much better.

Is there a way to reduce this even further? Why isn't idle-handling not yet in dosbox, when almost every os since mid 90s uses HLT to save power?

//edit: a KVM / VTx backend for dosbox would be awesome.
stecdose
Newbie
 
Posts: 17
Joined: 2018-10-27 @ 20:59

Re: DOSBOX eating up CPU

Postby DosFreak » 2018-11-06 @ 14:19

That's not normal behavior:
Post specs
Use the official ver of DOSBox
Post your dosbox.conf
Are you running a game in DOSBox? If so name it.

KVM/VTx would not be awesome for DOSBox. Use dosemu2,vmware,QEMU/KVM if that's what you want.
User avatar
DosFreak
l33t++
 
Posts: 10009
Joined: 2002-6-30 @ 16:35
Location: Your Head

Re: DOSBOX eating up CPU

Postby stecdose » 2018-11-06 @ 15:30

Okay, specs are:

OS: Linux (debian, gentoo, both the same)
System: i5 520m, 2.40GHz, 4GB RAM
DOSBOX: 0.74, 0.74-2, SVN

I always have used official version of dosbox. This behaviour is everytime, no program but command shell loaded. See the attached dosbox.conf autoexec section. A few mounts, keyboard, done.

It is difficult to catch dosbox with top with screenshot tool. The moment the screenshot is taken, dosbox is already somewhere else in list.
It jumps always between 88% and 100%, sometimes I see 90%, 95%, 100%, but never goes below 88% and most of the time it is near 100%.

I am using a stock dosbox.conf that comes with distro-packages. Just have edited autoexec-section to my needs.

Booting a whole VM like qemu is a waste of time. I usually use dosbox for cross-development on my linux-box. This way I can really easy test:
Makefile contains a "make test" target. This target starts dosbox and the program I am currently working on. This goes within max. 2 seconds.
Does dosemu2 take advantage of KVM/VTx?

Okay, I havent thought to the end. Havin dosbox with KVM will result in a way too fast system. But slowing it down again with "NOPs" would bring a huge efficiency benefit compared to emulating a CPU.
While waiting for the cycle-time to be complete the host-system is free for other tasks.
Attachments
dosbox-SVN.conf
(10.56 KiB) Downloaded 15 times
stecdose
Newbie
 
Posts: 17
Joined: 2018-10-27 @ 20:59

Re: DOSBOX eating up CPU

Postby kjliew » 2018-11-06 @ 23:03

I just tried my DOSBox SVN in Ubuntu 16.04LTS on the aging system with Core2 Q9300/NVIDIA graphics. With "cycles=auto", DOSBox started up with 3000 cycles, and the TOP showed max %CPU at ~10%. Ubuntu System Monitor also showed similar result on CPU history. Different output options (surface, opengl, openglnb) do not make any difference. 3000 cycles is too petty regardless if DOSBox rendering window was in focus for any CPU/GPU from the past 10 years.

With "cycles=max 105%, DOSBox would eat CPU when the rendering window was in focus. TOP/System Monitor showed %CPU at ~97%. If the rendering window was not in focus, then DOSBox consumed ~50% CPU. The system remained responsive even if DOSBox at ~97% CPU since it only used 1 core. The 3 remaining cores were at <10% CPU.
kjliew
Member
 
Posts: 260
Joined: 2004-1-08 @ 03:03

Re: DOSBOX eating up CPU

Postby krcroft » 2018-11-07 @ 03:18

That sounds normal to me. When you set "100%", you're telling DOSBox to emulate as many dos-cycles/s as possible given the limits of your host cpu. On the other hand, setting DOSBox to emulate 3000 cycles/s is pretty easy for a modern host cpu (in this case, DOSBox needs about 100 MHz on a modern cpu, so you might notice that your cpu is clocked down to its lowest speed as well).

When it comes to host cpu usage, I think emulating cpu "noop" cycles (or idling) in DOSBox is no different than emulating any other instruction. Like revving a car engine to 8,000 RPM; the engine does the same work regardless if you drive from A to B or if it's stationary on a dynamo.

I'm not sure if it's possible or elegant in DOSBox to detect and short circuit cpu "idle" states and replace them with an OS busy/wait call, like select() on Linux, without negatively impacting proper emulation of hardware peripherals like the sound card or video card, which are cuurently emulated serially in the same thread.
(maybe possible if each peripheral were emulated in a separate thread? interesting topic though!)
User avatar
krcroft
Member
 
Posts: 128
Joined: 2017-4-29 @ 15:07
Location: Ogden's Retreat

Re: DOSBOX eating up CPU

Postby Azarien » 2018-11-07 @ 20:41

Just set cycles=auto and you should be good. Anything else is rarely needed.
Azarien
Oldbie
 
Posts: 581
Joined: 2015-5-14 @ 07:14

Re: DOSBOX eating up CPU

Postby stecdose » 2018-11-08 @ 09:27

I have cycles=auto. When I try to change cycles it does not affect cpu usage by more than 5%. Even if I go down to 100 cycles, where norton commander takes a couple of seconds to start.

I'm afraid this almost 9 nine year old mobile i5 is a very weak performer... (i5 520m).
stecdose
Newbie
 
Posts: 17
Joined: 2018-10-27 @ 20:59

Re: DOSBOX eating up CPU

Postby DosFreak » 2018-11-08 @ 09:48

No something else is going on. If you use DOSBox from a liveCD to you have the same issue?
User avatar
DosFreak
l33t++
 
Posts: 10009
Joined: 2002-6-30 @ 16:35
Location: Your Head

Re: DOSBOX eating up CPU

Postby Qbix » 2018-11-08 @ 10:04

Try with frameskip set to 1 or 2
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10707
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: DOSBOX eating up CPU

Postby kjliew » 2018-11-08 @ 21:37

stecdose wrote:I'm afraid this almost 9 nine year old mobile i5 is a very weak performer... (i5 520m).

That is still much more powerful than AMD mobile C60, and as I said 3000 cycles is petty on any CPU/GPU for the past 10 years. ASUS EeePC 900MHz can also handle 3000 cycles with less than 30% CPU on Windows XP, and that's with the crappy i910 Intel Graphics.

I think you need to check your SDL or the display driver aspects on your Linux distro. The only reason that I can think of that the CPU/GPU cannot handle 3000 cycles is due to an un-accelerated display issue.

Have you tried different output options in the conf file? In your attached conf file, you have "output=opengl". You should check out "output=surface". Perhaps your setup has issues with OpenGL acceleration, and it was using software rendering.
kjliew
Member
 
Posts: 260
Joined: 2004-1-08 @ 03:03

Re: DOSBOX eating up CPU

Postby stecdose » 2018-11-08 @ 22:51

I tried a few settings now.

frameskip=1 does not change anything, same as frameskip=5 does not change anything.

changed to surface, also tried openglnb and overlay. No change in CPU usage. I ran glxgears for testing opengl capability, this goes well. It runs 60fps.

Also I played around with cpu core and cputype (auto, dynamic, normal, simple, 386, 386_slow).

Just tried dosemu 1.4.1 which is in my distro's repos, this takes 3% cpu when idling with a command shell.
stecdose
Newbie
 
Posts: 17
Joined: 2018-10-27 @ 20:59


Return to DOSBox General

Who is online

Users browsing this forum: No registered users and 2 guests