atoone / BeastEm

MicroBeast Z80 Computer emulator
zlib License
22 stars 5 forks source link

CPU issues #2

Closed mengstr closed 1 year ago

mengstr commented 1 year ago

Directly after starting the emulator, with the bios loaded, the CPU load is about 50% on a single core of an M1. When the emulator clock is started, set to the default 8MHz, the core is pegged at 100%, the entire window get really sluggish (takes several seconds to mark keypresses on the softkeyboard). Then after a while the MacOS busy-indicator pinwheel of death is shown.

There must be some tight busy-polling loop going on in the code...

atoone commented 1 year ago

That's... interesting. I'll investigate.

atoone commented 1 year ago

It appears that the mktime call in the RTC (used to regularise time updates) is very expensive on Linux systems. Enabling the RTC in MicroBeast slowed down the emulator enormously.

The latest release removes that call and checks the time update by hand. Performance is now much better.

mengstr commented 1 year ago

Confirmed. 50% load on one core now, plus another 10% if the audio is enabled. Everything feels responsive and nice.