Decadent Singularity
 
[Most Recent Entries] [Calendar View] [Friends View]

Saturday, May 18th, 2024

    Time Event
    2:13a
    Implementing Arrays with ECS
    To implement an array of N items we first allocate an entity for it.
    Now add component `array`, with the value `N` to that entity.
    Then we just add `N` to the id counter.
    Presto! We now have an array of N void entities.
    They don't even consume any memory, as long as we don't add components to them.
    Such arrays are similar to the C/C++ arrays.
    And they do support array of arrays, as long as each row get properly sizing.
    You can implement a playfield or a framebuffer grid that way, exposing raw pixels.
    The main issue is that offsets begin from 1.
    One solution is adding id, but that will make the `array` holding entity unreachable.
    And the array will get deallocated on GC.
    It also doesn't have bounds checks in the raw form.
    So I'm still brainstorming on the best way to use it as Symta's core list structure.
    But once it is ready, Symta's compiler code will be so much cleaner.
    No more hacks with wrapping metadata around SEXPs for sure.

    Insane stuff.

    Current Mood: contemplative
    2:16p
    Rethinking the Symta's Runtime
    Apparently I was doing pointer tagging thing incorrectly the whole time.
    I did stole the fixnum idea from Lisp/Haskell.
    But that was pretty much all.
    For example, I had the closure storing it's size inside the object on heap.
    That incurred performance penalty even for the functions having no closure.
    Yet it is useful to have fixnums with custom types.
    So the right thing is allocating a type tag range for functions.
    After all, a program can't have more than a million functions.
    Now we can either have it point to the area of memory with functions.
    Or to a pointer vector. Without any heap overhead.
    Generally, most tagged pointers, like entities, don't need a heap object.
    I.e. most of my functions are not closures.
    With entities I just temporarily bring them to existence as a specific type.
    Which then gets dropped after the processing is done.
    Going through a heap object creation is super inefficient.
    The difference between 6 FPS and 60 FPS

    TLDR: preparing runtime for transitioning to ECS.

    Current Mood: contemplative

    << Previous Day 2024/05/18
    [Calendar]
    Next Day >>

About LJ.Rossia.org