C3 Architect Request list

0 favourites
From the Asset Store
Template for scrollable list, fully documented in comment and video
  • By the way, just to counter all that downer talk: this has become a really awesome document. I haven't looked a it in a few weeks, so most of this is completely new (to me).

    In particular, I'd never heard of Duff's Device loops. Why, exactly, are they faster? Would there be any way to hard-mod a bit of the engine code to give them a test run?

    For anyone that wants to run the tests:

    http://jsperf.com/duffs-device

  • I agree c3 ide must support versatile custom extensions, but just wanted to share my thoughts on the subject and just communicate what's even more important.

  • Joannesalfa

    Thanks for pointing out the trolling, and taking a pic. Unfortunate. Some one else however seems to have reverted. Which whomever it was. It's appreciated

    TiAm megatronix

    I agree with wanting C3 done right out the gate as of 1.0. however doing it right out the gate would require very long time; along the lines of 2/3 years of a tool developed in isolation. With C3 IDE need to be redone instead of built on top of. What I'm hoping for is the beta to be released very light and "soon". With a lot of tools missing non existent. So that beta developers can help evolve C3 towards it's 1.0 release and weigh in what would be best for 1.0 release.

    TiAm

    It's a compiler method. Non reference code(ie pointed else where to in memory) is just faster. This comes down to memory cache for values. In a loop memory needs to be recycled which uses up time. Where as hard coded declared the memory use at compile time. There is also memory referencing of loops as a loop is scoped piece of code and so also has to have memory properly allocated every iteration with the next set of values.

    By unraveling a loop by n the compiler preallocates the memory, and also reduced the loop cache scope by a division of n. By having memory better handled and less code scopes, the result is increased performance. it's just unraveling a 50 line loop by 8 is going to produce a code file of 50lines x8unravel or 400 lines, instead of just 50. So that means if the loop needs editing, then you need to make sure each unravel needs to be updated.

    I would love to see Construct 3 use duffs device on the main game loop. Looking through C2 game loop, there would be little benefit. As C2 itterates through each object Type first(so 4 different sprite type objects, are their own loop of main logic). That's also the reason why my push for C3 to use a singular world object. Then C3 can use duffs device to unravel the world object code and we could work to get more performance out of C3 than we can from C2.

  • megatronx

    TiAm

    An extendable architect not only could help 3part plugin developers, but also make scirra developers add new features more quickly.

  • I couldn't have put it better myself. Rex nails the the subject a lot better than my verbose reasoning. Some times terse is much better.

  • Everade

    That's in the documentation as a Prefab, it's the only Unity term used. It's also appropriate as it's the for word for "Prefabrication".

    C3 Prefabs? If they added this, I would be incredibly excited!

    This discussion is amazing, it's hard to believe I haven't noticed it until just now.

    Has anyone mentioned adding in an online content browser to the IDE itself? Many engines now do that, and I feel like requesting an adjustment to the core website may be pointless. If we had a content browser where people could upload their custom made projects, prefabs (if they get added to the engine), art, plugins, behaviors, etc. Game designing would be much quicker than normal, and nobody would have to go searching for things within the forums. The could be organized and rated by the C3 users as well, allowing people to find the best of what they need on the fly, instead of going through Google to find it (which I often find myself doing now).

    I didn't read the whole forum, or much information about C3, so I'm unsure of whether or not this will be included, so I'm sorry if my post is incredibly naive.

  • jayderyu

    TiAm

    Yes I understand that, but that doesn't mean that certain features should be in the ide from the start. Personally don't care how will they be implemented.

  • Well that's why I tried to create a focus on the architecture requests. So that such features as IDE connectivity to say web pages, or other online resources could be made. I would love for the Scirra store to be fully integrated into C3. Import assets into a project as needed. Also other aspects would help too. Sublime Text for example has a magnificent plugin resource tool. Where an IDE plugin installs other plugins from a repository. Just fantastic and a pleasure to use. Helps my development a lot when using Sublime Text.

    Yes. I would love C3 to have prefabs, they are super awesome.

  • jayderyu

    I really like where this is going. If they make C3 the way that the people want it, it will be unbeatable as far as 2D engines go, that's to say if you don't think like me and believe C2 is already unbeatable. I'm excited for this.

  • I'd be more than happy to advocate a prefab system if it made picking amongst modular objects with shared behaviour easier, as I've stated earlier in the topic. Prefabs and the parent/child system makes easy changes to individual objects easier in Unity.

    Also, the Rewired asset for Unity is a fantastic example of a control system done right.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I wrote this as an update to the document draft. However I think this could improve game performance overall going forward.

    https://docs.google.com/document/d/1pNR ... ZGe8/edit#

    it's better formatted at google docs

    Engine Runtime Code execution

    Having spent some more time in the main game loop and ways to take advantange of memory, cache optimization for Duff’s Device(below) has led to a different suggestion. The current design of C2 main game loop for objects is

    Current Loop

    loop through all objects types

    loop through instances of Object type

    do object pre tick

    do update

    loop through behaviours

    execute behaviour update

    do object post tick

    This is the actual loop. The loop is repeated twice.

    for (i = 0, leni = this.types_by_index.length; i < leni; i++)

    {

    type = this.types_by_index;

    if (type.is_family || (!type.behaviors.length && !type.families.length))

    continue;

    for (j = 0, lenj = type.instances.length; j < lenj; j++)

    {

    inst = type.instances[j];

    for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++)

    {

    inst.behavior_insts[k].tick();

    }

    }

    }

    for (i = 0, leni = this.types_by_index.length; i < leni; i++)

    {

    type = this.types_by_index;

    if (type.is_family || (!type.behaviors.length && !type.families.length))

    continue; // type doesn't have any behaviors

    for (j = 0, lenj = type.instances.length; j < lenj; j++)

    {

    inst = type.instances[j];

    for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++)

    {

    binst = inst.behavior_insts[k];

    if (binst.posttick)

    binst.posttick();

    }

    }

    }

    In the above loop the loop is jumps into a multi embedded function. because the loop goes down, then back up the system is constantly clearing cache for a new behaviour, then going back to the behaviour for the next instance. There is little opportunity for the JIT to truly optimize cpu cache for both function variable cache, or object function cache.(as related to Duff’s device). As an analogy GPU/WebGL/GPU in general. Part of efficient rendering is to package sprites together on a texture. That way there is less swapping textures, which reduces memory transfer to the gpu cache, less draw calls and overall way better performance. Which C2 already works towards. however the CPU also benefits from caching code, and memory variable(as Duff Device below) significantly.

    I propose a loop that the CPU can take advantage of code/behaviour batching which can improve JIT optimization at runtime. Less deep than above, and also offers the awesome feature of priority behaviour control. this of course still works off the basic idea of world object and everything is a behaviour.

    Proposed loop

    loop through different behaviours

    loop through all of the same behaviour on all objects

    execute behavior update

    How does this work instead.

    This loop does not loop through Objects.

    This loop does not go through behaviors in an object

    This has the behavior at the top, and then manipulates it’s world object

    There is a BehaviourList. this list contains a BehaviourInstanceArray. And the array contains a reference to each and every instance of the behavior.

    abstract sample below

    BList[ Sprite[]

    Collision[]

    Platform[]

    Solid[]

    Pin[]

    ]

    When an object is created, the code adds the behavior instance to the array. When the object is destroyed then the behavior is removed from the array. This also means that the CPU can cache the update function and run through them all in one go. Doing so offers the benefit of Duff below. However the system also offers another benefit.

    Sort-able behavior execution. The above sample shows Sprite at the top, and Pin at the bottom. however this list can be sorted. Offering control as to what should be executed first to last.

    So the loop is

    for(int i = 0, int length = blist.length; i < length; i++)

    {

    var bInstList = blist[ i ];

    var n = iterations % 8;

    while (n--) {

    bInstList[ n ].tick();

    }

    n = (iterations * 0.125) ^ 0;

    while (n--) {

    bInstList[ n - 0 ].tick();

    bInstList[ n - 1 ].tick();

    bInstList[ n - 2 ].tick();

    bInstList[ n - 3 ].tick();

    bInstList[ n - 4 ].tick();

    bInstList[ n - 5 ].tick();

    bInstList[ n - 6 ].tick();

    bInstList[ n - 7 ].tick();

    }

    }

    So here is the game loop. Takes advantage CPU caching. Far simpler in design. Allows for Behavior execution order. So instead of Object top down, It’s behavior top down. There are probably other optimization techniques that can be applied.

  • Wow Jayderyu,

    That very thorough explainations about Construct architecture... very informative and very useful, thanks d=(^___^)=b

    Your new architecture for Construct is also amazing... so flexible and look like can produce much better and faster performance... i hope Ashley will implement it on Construct 3

  • No interface lag and correct file association with the steam version would be nice, but since I doubt this problem will be reliably eliminated in C3, an autoupdate feature for C3's non-steam version would be nice.

  • this would not work. - behaviour for loops as described.

    let's say you have 5 items with 5 behaviours - that's 25 iterations that have to happen. now let's say that one item is instead using 3 behavs - therefore

    23 iterations.

    you would have to do 4x5 and 1x3 loop. best way to do this is - foreach object - foreach behaviour in it - update behav. when there's no more behavs 2nd loop stops

    and first iterates next. what you're suggesting is that you do behavs globally foreach object, by inserting object into behaviour list. you haven't done really anything else.

    you have to do all 5behavs on each 5 items, just vice versa. also calling tick in one while 8-10 times- big no.

    what i'd suggest is something better - way better - behviours and plugins should have event listeners for ticking. once tick happens - each object / each behaviour updates globally, therefore no for loops at all. of course this could be pretty hard to achieve because we want some way of updating our objects - we don't want the last object to update first. so i'd do a list of objects - where you call tick over objects - which fires their events for every behaviour. ofc then we have only 1 loop that goes through all the objects ONLY. (instead of 3 loops). still again - do we want all the behaviours / plugins to happen in a particular order or chaotically?

    also another suggestions (which i don't know much about) - parallel loops? parallel.for? (c# has it, not sure about JS)

    also i've just had an idea - when you click on a function name - it automatically takes you to function definition. (make it clickable in event sheet)

  • http://en.wikipedia.org/wiki/Duff's_device

    https://jsperf.com/duffs-device

    The current loop is

    foreach Object, then foreach behaviour.

    And it's not the best way. As previously addressed the CPU optimization is similar to a GPU optmization in concept. Handling the same code in scope in chunks allows for better optimization and performance. Running through a ForEach(object) then ForEach(Behaviour) results in the object at the top. So the loop starts with object, then goes to the first behaviour, however since all following behaviours are never the same the CPU never optimizes as well as saying just handling all the same behaviours at once. As for ignoring Duff's device. I would do so in non game programming, but in game engine programming. It's all about finding optimal performance. Games are intensive and there is no reason not to take advantage of any and all coding tricks.

    Unless your relying on IRQ, all listeners are still based on loop. An event happens, then the event loops through the listener firing off the event. In this case everything. Which as you point out would be chaotic. Since this would be a chaotic loop that would result in little to no optimization of runtime.

    As for parallel loops, this might as well call it threading. In this case that would be done with a webworker. This is doable, but the this comes down to managing effective data transfer between the different threads with no conflict. I would love to see threading implemented in a game loop, but since memory needs to be transfered. I'm not entirely sure if the memory moving would save on time. It could do so in large memory batches.

    on a note. I did forget to write that there is a post and pretick loops. Which also again would take advantage to scope cache in a DuffDevice.

    I like the idea of clicking on a function. which then take you to the defintion. That's good <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)