FAQ:Performance: Difference between revisions

From MAMEDEV Wiki
(New page: ==Why do some games run so slowly on my system?== ==How can I get games to run faster?== ==There are occasional speed problems.== ==Does MAME benefit from SMP (symmetric multiprocessing) /...)
 
 
(20 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Return to the main [[Frequently Asked Questions]] page.
==Why do some games run so slowly on my system?==
==Why do some games run so slowly on my system?==
There are many things that are difficult to emulate without expending a large amount of CPU power. Some specific examples are:
* Emulating analog (discrete) audio circuits accurately requires higher math functions executed repeatedly, millions of times per second. Many older games which would otherwise be a walk in the park to emulate quickly can be bogged down with simulation of the analog audio. Reducing the sound output rate can help improve performance for these games.
* Games with multiple CPUs that share memory often have very tight timing requirements. In order to prevent the two CPUs from getting out of sync, MAME must essentially execute one instruction at a time on each CPU in turn. Even if the CPUs don't get out of sync, running the two CPUs in lockstep like this improves the overall emulation accuracy.
* Games with 3D graphics. As of this writing, MAME does not pass polygons down to the video card of your system; instead, it renders all 3D graphics by hand in software. Although this code is generally optimized to take advantage of multiple CPUs, it is still quite taxing to do this. Some 3D games give you control of the output resolution; reducing it will reduce the CPU requirements.
One thing that is counterintuitive is that it is generally the older games that require analog audio simulation or very tight CPU synchronization. This means that even something as innocuous as Donkey Kong might require a pretty beefy system to run at full speed.
It is important to keep in mind that MAME's primary goal is to accurately reproduce the game hardware. In some cases, it may not be possible to do this on any system that exists today.
==How can I get games to run faster?==
==How can I get games to run faster?==
This is the most commonly-asked question in the emulation world. In general, there is not really that much you can do to significantly speed up a game. However, here are some things you can try to improve MAME's performance:
* Use a faster CPU. This is the most reliable speed-increaser.
* Upgrade your graphics card, or update your present card's drivers. Swapping your generic (cheap) card for a high-quality (not cheap) card will certainly boost performance. If you are using on-board (integrated) video, you'll see a great performance increase by simply getting a new graphics card. Check your graphics card drivers, too. Newer drivers — especially for cheaper cards — can make all the difference.
* Get the latest MAME version. Or try an older/different one. MAME is in constant development. Due to transitional changes in the core code, some games run better/faster with different versions. Try and see for yourself which works best.
MAME itself also has many options that can increase your speed:
* Lower the sound quality. Try adding -sr 11025 to the command line, which will decrease sound playback quality and use less processor time. This mostly affects games that use discrete audio.
* Disable the joystick and use the keyboard (-nojoy).
* Use frameskip to speed up animation. Frameskip skips a certain number of frames per second, so your system does less work. Sometimes the trade-off is choppy animation; sometimes the difference is negligible. Experiment. While playing, press '''F8''' / '''F9''' to control frameskip; or set global frameskip in mame.ini. Some games don't benefit from frameskip though, for example the newer Williams bitmap graphics games or the Atari filled polygon games.
==There are occasional speed problems.==
==There are occasional speed problems.==
This can be caused by several factors.  If you press F11 when playing, you can see the FPS meter.  if it is normally running at full speed, but ocassionally gets slow, you might check the following:
# See if there are any background processes running.  Sometimes other applications open at the same time as MAME can cause slowness. 
# Try increasing or decreasing frameskip
# It is possible that you have a virus or spyware on your computer
# Some games require more CPU power at certain times in the game than other times.
==Does MAME benefit from SMP (symmetric multiprocessing) / HT (Hyper-Threading) / dual cores?==
==Does MAME benefit from SMP (symmetric multiprocessing) / HT (Hyper-Threading) / dual cores?==
==Why is MAME so slow? These games ran at less than 10 MHz, and my CPU is 500 MHz!==
Yes, MAME uses multi-threading to allow some tasks to be split up across multiple CPUs/cores.  In addition to the main emulation thread, MAME may create additional threads for the following tasks, depending on the system being emulated and your configuration:
* Up to three threads for triangle rendering when emulating accelerated 3D graphics hardware, including those 3dfx Voodoo
* Up to three matrix solver threads for emulating analog sound synthesis, TTL logic, and other analog/digital circuitry
* A texture upload thread when using bgfx video output (for uploading textures from MAME to your GPU)
* A thread to handle MAME's output handlers and built-in HTTP server
* Additional threads for OpenMP loop acceleration (requires special compile options, not enabled by default)
 
In pathological cases, MAME can make use of eight or more CPU cores.  Additionally, it helps if you have at least one CPU core to handle the OS and background tasks so MAME doesn't have to relinquish the CPU.  Note that parallelisation also increases memory bandwidth and cache requirements.  MAME's working set is somewhat larger than a typical benchmark suite, or an AV compressor.
 
==Why is MAME so slow? These games ran at less than 200 MHz, and my CPU is 2 GHz!==
You are comparing apples and oranges.
 
MAME emulates every function of the emulated CPU(s), video hardware, audio hardware, and anything else on the board (including potentially IDE or SCSI harddisks and CD-ROMs).  This is simply not something that can be done quickly in a high-quality fashion.
 
==Why don't the developers put more hacks in MAME?==
==Why don't the developers put more hacks in MAME?==
Hacks, while maybe appearing to be good in a short perspective, are always bad and destructive in the long perspective. The more hacks you put into the code, the harder it becomes to make new additions neatly as the hacks will require workaround hacks, so you'll end up on a downward slope of more and more crappy hacks, until everything collapses under its own weight.  Hack-based emulators typically have a short life because it quickly becomes impossible to debug or extend them.
==Why does MAME become slower all the time?==
==Why does MAME become slower all the time?==
Contrary to popular belief, the amount of drivers or the size of the executable does not make MAME slower.
The point is that the drivers are constantly improved and the improved emulation is more accurate to the actual original hardware so for MAME's purposes it's superior. Emulation accuracy trumps playability concerns in MAME.
Another thing to consider is a paradigm called "moving the optimization point". MAME's "sweet spot" is currently aimed at hardware with tilemaps, sprites, more than 256 colors on screen, and at least 2 CPUs, which is a common late-80s paradigm. Real-world examples of this include the Konami Twin16 games, the Sega X and Y boards, Namco System 2, Taito Z System, etc. It means that MAME makes more advanced games run faster at the expense of simpler hardware. The simpler hardware will work out in the end anyway due to ever-faster PCs (Pac-Man is very sub-optimal now compared with [[MAME 0.29]] for instance, but almost any average modern system runs it with 100% speed).

Latest revision as of 12:05, 22 September 2017

Return to the main Frequently Asked Questions page.

Why do some games run so slowly on my system?

There are many things that are difficult to emulate without expending a large amount of CPU power. Some specific examples are:

  • Emulating analog (discrete) audio circuits accurately requires higher math functions executed repeatedly, millions of times per second. Many older games which would otherwise be a walk in the park to emulate quickly can be bogged down with simulation of the analog audio. Reducing the sound output rate can help improve performance for these games.
  • Games with multiple CPUs that share memory often have very tight timing requirements. In order to prevent the two CPUs from getting out of sync, MAME must essentially execute one instruction at a time on each CPU in turn. Even if the CPUs don't get out of sync, running the two CPUs in lockstep like this improves the overall emulation accuracy.
  • Games with 3D graphics. As of this writing, MAME does not pass polygons down to the video card of your system; instead, it renders all 3D graphics by hand in software. Although this code is generally optimized to take advantage of multiple CPUs, it is still quite taxing to do this. Some 3D games give you control of the output resolution; reducing it will reduce the CPU requirements.

One thing that is counterintuitive is that it is generally the older games that require analog audio simulation or very tight CPU synchronization. This means that even something as innocuous as Donkey Kong might require a pretty beefy system to run at full speed.

It is important to keep in mind that MAME's primary goal is to accurately reproduce the game hardware. In some cases, it may not be possible to do this on any system that exists today.

How can I get games to run faster?

This is the most commonly-asked question in the emulation world. In general, there is not really that much you can do to significantly speed up a game. However, here are some things you can try to improve MAME's performance:

  • Use a faster CPU. This is the most reliable speed-increaser.
  • Upgrade your graphics card, or update your present card's drivers. Swapping your generic (cheap) card for a high-quality (not cheap) card will certainly boost performance. If you are using on-board (integrated) video, you'll see a great performance increase by simply getting a new graphics card. Check your graphics card drivers, too. Newer drivers — especially for cheaper cards — can make all the difference.
  • Get the latest MAME version. Or try an older/different one. MAME is in constant development. Due to transitional changes in the core code, some games run better/faster with different versions. Try and see for yourself which works best.

MAME itself also has many options that can increase your speed:

  • Lower the sound quality. Try adding -sr 11025 to the command line, which will decrease sound playback quality and use less processor time. This mostly affects games that use discrete audio.
  • Disable the joystick and use the keyboard (-nojoy).
  • Use frameskip to speed up animation. Frameskip skips a certain number of frames per second, so your system does less work. Sometimes the trade-off is choppy animation; sometimes the difference is negligible. Experiment. While playing, press F8 / F9 to control frameskip; or set global frameskip in mame.ini. Some games don't benefit from frameskip though, for example the newer Williams bitmap graphics games or the Atari filled polygon games.

There are occasional speed problems.

This can be caused by several factors. If you press F11 when playing, you can see the FPS meter. if it is normally running at full speed, but ocassionally gets slow, you might check the following:

  1. See if there are any background processes running. Sometimes other applications open at the same time as MAME can cause slowness.
  2. Try increasing or decreasing frameskip
  3. It is possible that you have a virus or spyware on your computer
  4. Some games require more CPU power at certain times in the game than other times.

Does MAME benefit from SMP (symmetric multiprocessing) / HT (Hyper-Threading) / dual cores?

Yes, MAME uses multi-threading to allow some tasks to be split up across multiple CPUs/cores. In addition to the main emulation thread, MAME may create additional threads for the following tasks, depending on the system being emulated and your configuration:

  • Up to three threads for triangle rendering when emulating accelerated 3D graphics hardware, including those 3dfx Voodoo
  • Up to three matrix solver threads for emulating analog sound synthesis, TTL logic, and other analog/digital circuitry
  • A texture upload thread when using bgfx video output (for uploading textures from MAME to your GPU)
  • A thread to handle MAME's output handlers and built-in HTTP server
  • Additional threads for OpenMP loop acceleration (requires special compile options, not enabled by default)

In pathological cases, MAME can make use of eight or more CPU cores. Additionally, it helps if you have at least one CPU core to handle the OS and background tasks so MAME doesn't have to relinquish the CPU. Note that parallelisation also increases memory bandwidth and cache requirements. MAME's working set is somewhat larger than a typical benchmark suite, or an AV compressor.

Why is MAME so slow? These games ran at less than 200 MHz, and my CPU is 2 GHz!

You are comparing apples and oranges.

MAME emulates every function of the emulated CPU(s), video hardware, audio hardware, and anything else on the board (including potentially IDE or SCSI harddisks and CD-ROMs). This is simply not something that can be done quickly in a high-quality fashion.

Why don't the developers put more hacks in MAME?

Hacks, while maybe appearing to be good in a short perspective, are always bad and destructive in the long perspective. The more hacks you put into the code, the harder it becomes to make new additions neatly as the hacks will require workaround hacks, so you'll end up on a downward slope of more and more crappy hacks, until everything collapses under its own weight. Hack-based emulators typically have a short life because it quickly becomes impossible to debug or extend them.

Why does MAME become slower all the time?

Contrary to popular belief, the amount of drivers or the size of the executable does not make MAME slower.

The point is that the drivers are constantly improved and the improved emulation is more accurate to the actual original hardware so for MAME's purposes it's superior. Emulation accuracy trumps playability concerns in MAME.

Another thing to consider is a paradigm called "moving the optimization point". MAME's "sweet spot" is currently aimed at hardware with tilemaps, sprites, more than 256 colors on screen, and at least 2 CPUs, which is a common late-80s paradigm. Real-world examples of this include the Konami Twin16 games, the Sega X and Y boards, Namco System 2, Taito Z System, etc. It means that MAME makes more advanced games run faster at the expense of simpler hardware. The simpler hardware will work out in the end anyway due to ever-faster PCs (Pac-Man is very sub-optimal now compared with MAME 0.29 for instance, but almost any average modern system runs it with 100% speed).