Re: Data oriented programming
OvermindDL1 <[email protected]> Sun, 17 Oct 2010 17:45:30 -0600
| Newsgroups | gmane.games.devel.sweng |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Oct 17, 2010 at 9:36 AM, Jon Watte <[email protected]> wrote: > tl;dr: > Either, you walk the data in memory order, and switch on type, or you group > the data in type order, and do all types separately. > In the first case, you get branch mis-predictions, which can be expensive, > and you also get higher I-cache pressure and even D-cache pressure because > you have to keep a bunch of different "subsystems" (type handlers?) in > memory. > In the second case, you have to map xyz->object (and object->xyz) in some > way other than the three-dimensional array, such as a sparse array > implemented as a hash table. That will cause more cache misses when locating > the item for any particular element, but it will let you walk elements of > the same type using linear memory access, and have less I and D cache > pressure and better branch prediction. > Which one is faster depends on whether you do mostly "update all of type X" > or do mostly "find element by xyz" operations per frame. You'll simply have > to come up with realistic workloads and profile it both ways. > Sincerely, That is what I figured, problem is I am going to be doing a lot of operations all on single types within a large area, and also going to be getting everything in range to send to the client often as well as their view area changes and on how blocks can affect other nearby blocks... Basically create both systems I guess and benchmark, how fun... _______________________________________________ Sweng-Gamedev mailing list [email protected] http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com