Announcement

Collapse
No announcement yet.

Multi-Threading Quake

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multi-Threading Quake

    Has anybody given any thought to mulit-threading Quake I?

  • #2
    Conceptually, it might be interesting to look for some optimizations in some of the heavier source ports. I think Darkplaces has some very basic multithreading going on, but it won't ever use more than one CPU core.

    But do you think that Quake 1 (or source ports based on it) have poor performance on modern hardware where the CPU is the bottleneck where it would need to be multi-threaded?

    Comment


    • #3
      FTE does some multithreading. various things are loaded on different threads. sound is mixed on a different thread. dns lookups too. you can offload lightmap+ebo generation too.
      what really matters is separating the server+client - many mods do a whole load of things that can stall etc.
      dp has an 'experimental' cvar or something to run the server parts on a different thread, while fte has its 'mapcluster' mode that runs (potentially multiple) servers in entirely different processes (which is more robust, but certainly more weird at the same time).

      the main issue here is that a qcvm CANNOT be multithreaded. It abuses globals - even the VM itself was designed around doing so (sure you can have multiple vms on different threads, but not the same vm on multiple threads). Any mutexes used to isolate one entity from others and their think/touch functions etc, would just create more overhead without all that much gain.
      adding threading after the fact is not trivial, every single line of the code needs to be reviewed in order to ensure that there are no race conditions. no globals (quake+quakec loves to abuse those), no cvars - especially strings (which can potentially be changed on a whim by the main thread), etc.

      There is one project to multi-thread mvdsv+ktx (which is written in C so does not require a qcvm), however it violates the GPL by not providing source so I refuse to give any names/urls. iirc, the guy behind it claimed that while it spread the load well enough, it had an extra 50% cpu overhead - if you have idle cpu cores then you probably won't care, but it should cope better with multiple under-powered cpus.
      Naturally, mvdsv lacks various extensions found in fte+dp, many of which would make such multithreading much more messy - the limited engines are so often the easiest to modify.
      Some Game Thing

      Comment


      • #4
        Yep, that's exactly what I was wondering about, specifically putting the server and client in different threads.

        I am attempting to add a non-linear acceleration curves to the joystick axes. Using a third order polynomial was my first choice for that, but evaluating the exponential function for just one axis turned out to be too CPU intensive for single thread/single core operation of DP on my machine and resultingly brought the frame rate significantly down.

        Next I tried approximating with lookup tables, although lookup tables which use simpler functions but a lot more steps evaluating on three axes numerous times a second still places a noticeable although tolerable load at 3 GHz on a single core. That got me wondering what would happen if the client and server were run on different cores.

        I'll have to see if DP will multi-thread with my set up. That would solve the problem.
        Last edited by Syber Raith; 02-13-2017, 12:14 PM.

        Comment


        • #5
          Originally posted by Spike View Post
          dp has an 'experimental' cvar or something to run the server parts on a different thread
          Does anyone know what this cvar is?

          I'm not finding it on this list (though it hasn't been updated in 10 years)

          https://icculus.org/twilight/darkpla...nsoleVariables

          Comment


          • #6
            sv_threaded
            Some Game Thing

            Comment


            • #7
              Would it be possible to start up a server on my machine, then start up a client and connect to it on the same machine? I have yet to try that. Since I have a multi-core machine, then the OS will just load balance the then two separate processes across the cores as usual.

              ***

              Setting sv_threaded to 1 caused DP to hang while loading on my machine. I'm using the SDL version if that matters. I guess I compile up a server and see how that works. Now I'll have to figure out how to run and connect to the server. Hmm, standalone servers are for multiplayer games. Anyway to play a single player game on one?

              How does anybody ever learn this stuff without a reference manual on the architecture of the engine and the source code?
              Last edited by Syber Raith; 02-13-2017, 01:22 PM.

              Comment


              • #8
                Originally posted by Syber Raith View Post
                Would it be possible to start up a server on my machine, then start up a client and connect to it on the same machine?
                If you are using an operating system that supports multi-tasking like Windows, Linux or a Mac, the answer is yes.

                And the fun thing is, you don't even need multiple cores to do it.
                Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

                So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

                Comment


                • #9
                  Originally posted by Syber Raith View Post
                  Setting sv_threaded to 1 caused DP to hang while loading on my machine. I'm using the SDL version if that matters. I guess I compile up a server and see how that works. Now I'll have to figure out how to run and connect to the server.
                  Why are you using the SDL version?

                  Comment


                  • #10
                    Originally posted by Syber Raith View Post
                    Setting sv_threaded to 1 caused DP to hang while loading on my machine.
                    hey, I did say it was experimental...
                    even the cvar description says 'EXPERIMENTAL, may be crashy'.

                    try starting it up twice, once with: -dedicated 1 +coop 0 +deathmatch 0 +map start
                    and once with +connect localhost

                    note that fte's 'mapcluster' command effectively does this automatically, but you need to use the client's 'ssv' command in order to issue console commands to the (hidden) dedicated server (instead of needing to alt-tab), and it'll be killed automatically by the client as needed.
                    Some Game Thing

                    Comment


                    • #11
                      Baker: I'm running Win7 Pro on a 8 core AMD machine with a relatively old and small graphics card. I see that I can start up one client with -dedicated and -ip 127.0.0.1 then start up a second client and connect to that game. I think that basically what you just said.

                      That seems to spread the load over 4 cores, although I lose some features like rain and fog in the process.

                      I'm using SDL because I think the regular client failed to work well with my joystick, and because I read somewhere that the SDL version usually runs faster. My benchmarking found that both versions run basically at the same frame rate on my setup. I'll try some more options on starting up with sv_threaded enabled.

                      I see the Q3 engine is multi-threaded. Is there any chance Q1 maps and such will work on the ioquake engine?
                      Last edited by Syber Raith; 02-13-2017, 03:36 PM.

                      Comment


                      • #12
                        Originally posted by Syber Raith View Post
                        I'm using SDL because I think the regular client failed to work well with my joystick, and because I read somewhere that the SDL version usually runs faster. My benchmarking found that both versions run basically at the same frame rate on my setup. I'll try some more options on starting up with sv_threaded enabled.
                        OpenGL SHOULD always be faster than SDL.

                        As far as I know, SDL still only does 2D hardware acceleration, and it generally does that by passing the calls back to DirectX or OpenGL based on the platform and it does no hardware acceleration for 3D.

                        If you have a video card, OpenGL should be considerably faster.

                        I'm curious how/why you're getting faster SDL performance. Do you not have a video card? Do you not have recent video card drivers installed? Do you have a laptop with the combination on-board Intel GPU and Nvidia GPU and it isn't switching over to the Nvidia GPU for gaming (I've seen this quite a bit).

                        Comment


                        • #13
                          It's a desktop with a 1GB AMD Radeon HD 5450 video adapter with the most recent drivers. It's pretty old and slow compared to the newest and fastest.

                          SDL and the regular client were at the slowest speeds virtually identical at about 20 fps with my setup. the higher speeds varied somewhat, but they were like in the 120 to 140+ fps range.

                          Comment


                          • #14
                            Originally posted by enderandrew View Post
                            OpenGL SHOULD always be faster than SDL.

                            As far as I know, SDL still only does 2D hardware acceleration, and it generally does that by passing the calls back to DirectX or OpenGL based on the platform and it does no hardware acceleration for 3D.

                            If you have a video card, OpenGL should be considerably faster.

                            I'm curious how/why you're getting faster SDL performance. Do you not have a video card? Do you not have recent video card drivers installed? Do you have a laptop with the combination on-board Intel GPU and Nvidia GPU and it isn't switching over to the Nvidia GPU for gaming (I've seen this quite a bit).
                            That's like on the horribly wrong in so many different ways it scores 99/100 on how wrong a post can be every single way.

                            Someone else braver than myself will have to do the explaining.

                            But wanted to point out that it is, in fact, wrong in an astonishing number of ways all at the same time.
                            Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

                            So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

                            Comment


                            • #15
                              Originally posted by Baker View Post
                              That's like on the horribly wrong in so many different ways it scores 99/100 on how wrong a post can be every single way.

                              Someone else braver than myself will have to do the explaining.

                              But wanted to point out that it is, in fact, wrong in an astonishing number of ways all at the same time.
                              In testing on hardware I've ever seen in my life, OpenGL is always considerably faster than SDL.

                              I just looked up the SDL 2.0 spec and it said it only does 2D hardware acceleration by passing on calls to DirectX or OpenGL by platform.

                              I didn't see a clarification on 3D hardware acceleration, but SDL has never supported that to my knowledge.

                              On SDL's site, I can only see hardware acceleration for 2D.

                              https://wiki.libsdl.org/SDL_CreateRenderer

                              How is that 99% wrong when it is what SDL's own site says?

                              And this FAQ:

                              https://wiki.libsdl.org/FAQDevelopme...cceleration.21

                              SDL passes on hardware acceleration to DirectX on Windows.

                              Comment

                              Working...
                              X