Forged Alliance Forever Forged Alliance Forever Forums 2018-05-04T20:20:55+02:00 /feed.php?f=45&t=15908 2018-05-04T20:20:55+02:00 2018-05-04T20:20:55+02:00 /viewtopic.php?t=15908&p=163084#p163084 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>
When building a PC system, it seems interesting to think about finding the good memory recipe.

object

Statistics: Posted by Franck83 — 04 May 2018, 20:20


]]>
2018-04-30T14:54:17+02:00 2018-04-30T14:54:17+02:00 /viewtopic.php?t=15908&p=163012#p163012 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>
Anihilnine wrote:
This is perfectly achievable with various forms of multi-threading

I think it's ambitious to do that
1. with an external dll call
2. without a desync

The guy in the other thread that Franck linked had the external dlls working i think, being called by Lua code, and while desync may be a problem, it has nothing to do directly with multithreading, as explained.

Anihilnine wrote:
3. through all of the engine hoops
4. with it actually causing a performance increase


These are the real problems. Making some threads and joing them back in every tick will probably be slower than single-threaded. If it's somehow possible to have a thread-pool with some workers, that live over the course of multiple ticks, it could work though. Still, i see the best shot at improving Lua performance in switching out the Lua interpreter in favor of LuaJit, and, like Usevo said, optimizing memory layout for more cache hits, if that is possible in Lua besides just using less memeory.

Statistics: Posted by Katharsas — 30 Apr 2018, 14:54


]]>
2018-04-30T10:18:05+02:00 2018-04-30T10:18:05+02:00 /viewtopic.php?t=15908&p=163005#p163005 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>

This is perfectly achievable with various forms of multi-threading


I think it's ambitious to do that
1. with an external dll call
2. without a desync
3. through all of the engine hoops
4. with it actually causing a performance increase

Statistics: Posted by nine2 — 30 Apr 2018, 10:18


]]>
2018-04-29T21:42:42+02:00 2018-04-29T21:42:42+02:00 /viewtopic.php?t=15908&p=162996#p162996 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>
Anihilnine wrote:
Sorry for being so quick to be negative.

I could be wrong but my understanding is
- multicoring is achieved through threading
- threading will desync immediately


Your understanding is wrong. For the game to not desync, there is a simple condition: Every player, provided with the game state of the previous tick and all actions of all players to be processed, needs to be able to calculate the game state at the next tick deterministically (-> have same result on any hardware/software). This is perfectly achievable with various forms of multi-threading, for example:

Spoiler: show
Say we have a given game state and player input, and x0, y0, u, v, x1, y1 are all just numbers / variables:

game_state_at_tick_0 = { unit_A_position : x0, unit_B_position : y0 }
player_input_at_tick_0 = move unit_A for u, move unit_B for v

Then we use single-threaded simulation code to cacluclate next game state:
Main thread:
unit_A_pos_new = x0 + u = x1
unit_B_pos_new = y0 + v = y1
game_state_at_tick_1 = { unit_A_position : x1, unit_B_position : y1 }

or we could use muti-threading:
Thread 1:
unit_A_pos_new = x0 + u = x1
Thread 2 (at the same time):
unit_B_pos_new = y0 + v = y1
Main thread (waiting until Thread 1 & 2 have finished and then collects results):
game_state_at_tick_1 = { unit_A_position : x1, unit_B_position : y1 }

Both methods will have calculated an identical, deterministic result, and there is no desync in the simulation. You could even run clients with and without multi-threading in same game. As long as they calculate the same things, everything is fine. WHO FAST this happenes, does not matter, because faster clients simply wait for the slowest until they proceed with next sim tick.


Now, of course things get more complicated if we get into Lua coroutines and how they could be multithreaded, and i don't think that would work very well. My understanding is that Lua supports coroutines in the same way that for example Javascript supports async function execution. BUT this is very different from real multithreading, because it doesn't require REAL synchronization, locks, semaphores or whatever you need when working with state that is shared accross multiple threads.
In javascript async function (unless using webworker), you never need to worry about what a will happen to a variable when two threads try to write to it ast the SAME time, because even if functions are async, they can never be executed at the same time. because the Javascript executor runs single-threaded, like a Lua host does as well i guess.
But maybe you can to very clever things in the Lua Host that the game using. Wich leads me to the question:

Which Lua Host does the game use ot execute Lua? There are massive differences in performance between some of them, There is for example this:
http://luajit.org/

Which shows massive performance improvements in regard to control structures (control structures are things like "if", "for", "while", etc..), and probably also for pure calculations, but probably does not help too much if the Lua code is bottlenecked by memory access / bad cache layout.

Edit:
I think i misunderstood Franck. He doesn't want to parallelize the Lua execution, he simply wants to call native code FROM Lua (and this native code can, of course, be multi-threaded). That should work fine.

Statistics: Posted by Katharsas — 29 Apr 2018, 21:42


]]>
2018-03-30T12:19:47+02:00 2018-03-30T12:19:47+02:00 /viewtopic.php?t=15908&p=162267#p162267 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>

Surprise surprise, it's RAM speed.


You totally right, i switched my Ram speed from DDR3-1600 to DDR3-2133, played with the timings and i saw + 10-15% fps increase.

Statistics: Posted by Franck83 — 30 Mar 2018, 12:19


]]>
2018-02-16T19:04:11+02:00 2018-02-16T19:04:11+02:00 /viewtopic.php?t=15908&p=160934#p160934 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>
Why we have absurd fast CPU's for Supcom and still lag!?!
While having some PC here i did some testing.

Surprise surprise, it's RAM speed.

For example; i changed from DDR3 to DDR4 RAM (I have a board with DDR3 and DDR4 slots).
The simspeed was increasing from +5 to +6
I got also good results when overclocking the HT-link (AMD -> connection between Northbridge and RAM) or overclocking the RAM itself (low CAS Latency, 4xBank Interleaving, reduced refresh cycle(yeah, i know, i know... :) ))

Maybe we should try to not waste too much LUA memory in huge arrays :)
(Memory use from big unit models, LOD settings etc are not influencing the game speed)

Some benchmarks to compare:
18328 QuadCore Q8400 @ 2,5GHz
18543 FX-8150 @ 4,2GHz
18545 PhenomII-X4-955 @ 3,8GHz / 200MHz
18547 PhenomII-X4-955 @ 3,8GHz / 211MHz
18559 PhenomII-X4-955 @ 4,0GHz / 200MHz
18576 PhenomII-X4-955 @ 4,2GHz / 205MHz
18585 PhenomII-X4-955 @ 4,1GHz / 200MHz NB 2200
18589 PhenomII-X4-955 @ 4,0GHz / 200MHz NB 2400
18595 PhenomII-X4-955 @ 4,1GHz / 200MHz NB 2400
18645 i7 6700K @ 4.4GHz
18708 i7 4790K @ 4.4GHz

Statistics: Posted by Uveso — 16 Feb 2018, 19:04


]]>
2018-02-16T10:15:43+02:00 2018-02-16T10:15:43+02:00 /viewtopic.php?t=15908&p=160920#p160920 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>
But you right about desync with other players since no everybody got the same CPU power. We are always linked to the slowest CPU.

Statistics: Posted by Franck83 — 16 Feb 2018, 10:15


]]>
2018-02-16T00:58:03+02:00 2018-02-16T00:58:03+02:00 /viewtopic.php?t=15908&p=160910#p160910 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>
I could be wrong but my understanding is
- multicoring is achieved through threading
- threading will desync immediately

Statistics: Posted by nine2 — 16 Feb 2018, 00:58


]]>
2018-02-16T00:12:23+02:00 2018-02-16T00:12:23+02:00 /viewtopic.php?t=15908&p=160909#p160909 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>
Just say that i would have use of some multicore power from dll for modding.

Statistics: Posted by Franck83 — 16 Feb 2018, 00:12


]]>
2018-02-15T16:05:31+02:00 2018-02-15T16:05:31+02:00 /viewtopic.php?t=15908&p=160890#p160890 <![CDATA[Re: Lua / C++ DLL linking - Multi core use]]>
The engine needs a rewrite, not some magic dll.

The benefits of multi core has always been overstated.

Statistics: Posted by nine2 — 15 Feb 2018, 16:05


]]>
2018-02-15T12:05:27+02:00 2018-02-15T12:05:27+02:00 /viewtopic.php?t=15908&p=160884#p160884 <![CDATA[Lua / C++ DLL linking - Multi core use]]>
https://github.com/FAForever/supcom-se/ ... /scse/scse

I seems that we can use DLL to dispatch some intensive CPU task between all CPU cores. Of course we cannot interrupt sim execution to wait DLL results.

But it may be cool to unlock all this cores power to mod dev. I'm thinking about all in game units dataprocessing....

Statistics: Posted by Franck83 — 15 Feb 2018, 12:05


]]>