Author Topic: [TOO HARD] Multithreading?  (Read 96 times)

HunterZ

  • Posts: 1
[TOO HARD] Multithreading?
« on: June 08, 2017, 10:23:43 PM »
So I noticed that OBLIGE seems to be single-threaded. Since almost everyone has a 2-8 hardware core/thread CPU these days, it would be cool if it could maybe gain a massive performance increase by using threads to generate multiple levels simultaneously.
« Last Edit: August 01, 2017, 11:55:05 PM by andrewj »

andrewj

  • Developer
  • *****
  • Posts: 1473
Re: Multithreading?
« Reply #1 on: June 08, 2017, 11:42:55 PM »
I have thought about this, but it would be very difficult to make OBLIGE work in a multi-threaded way.

Firstly, the most time consuming stuff happens in the Lua interpreter, and while the Lua interpreter supports "co-routines" I believe that it does not support Lua code actually running in parallel (on different CPU cores).

The alternative is having two (or more) separate Lua vms, and running them in parallel, each one working in on a different map.  It would be very difficult to set this up, getting each vm to have the correct state (enabling or disabling addons requires OBLIGE to be restarted, for similar reasons).

Apart from Lua stuff, the other time-consuming things are the CSG step (merging all brushes to create the DOOM format map) and the nodes building step.  These can potentially run in parallel with Lua map generating code.

Ultimately I don't think the extra complexity is worth it.