Skip to content

Multithreading attempt

Carlos Duarte do Nascimento (Chester) edited this page Feb 2, 2014 · 2 revisions

Attempted to run each chip on a thread (to maybe speed the emulator up in multicore machines).

Never did multi-threading on Ruby, but it seemed simple. Also, introducing that logic now that chip syncing moved from TIA into FrameGenerator was quite trivial:

https://github.com/chesterbr/ruby2600/compare/0fa0e0...1747124

(I'd usually have written tests, but it was mostly a feasibility spike)

Unfortunately, it seems that the game (CPU + Cart) is picking up TIA or RIOT in an inconsistent state, putting the game out of sync. Could add synchronization, but it would negate the very idea of parallelizing.

Also, "System" CPU time spiked, possibly due to the sleeping on every chip tick (which I could maybe reduce to a third of the tick TIA, but would still be high). Guess I'll refrain from that strategy for now.

Also worth registering: MRI kinda choked on the sleep/wakeup cycle. JRuby handled it fine.

Clone this wiki locally