nancygold's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Wednesday, July 24th, 2024

    Time Event
    1:41a
    Implementing ECS related data structures
    Integer to value maps, while simple, require a lot of copy pasted code to implement.

    So I have to emulate C++ templates with macros.

    That gets messy when only template uses other templates.
    Because we get a small combinatorial explosion.
    A single template invocation easily adds several kilobytes to the executable.
    That is annoying, but these are core types, so I have sacrifice something.
    Generally it is a bad idea to use templates, because they clog instruction cache.



    Current Mood: amused
    12:07p
    At one point Dutch were the only europeans allowed to Japan
    https://www.artelino.com/articles/dutch_nagasaki.asp

    Current Mood: amused
    4:34p
    Large Bitmaps Implementation
    Ok. Since my bitmap code isn't fast enough (takes 5 seconds to set a 32bit address space to 1s, bit by bit), I was looking at what other people use. The most popular package appears to be https://github.com/RoaringBitmap/CRoaring it is especially recommended for columnar databases and ECS games.

    To test it I ran the following snippet
    for (uint64_t i = 0; i < (uint64_t)1<<32; i++) roaring64_bitmap_add(r1, i);


    Yet it it is almost 10 times slower than my naive implementation!
    $ gcc -O2 test.c -o test && time ./test.exe
    real    0m 45.53s
    user    0m 1.71s
    sys     0m 0.01s


    WTF? That roaring.c is a whooping megabyte of terse C code and compiles to 350kb executable!!! Where are the optimizations?

    Anyway, I asked ChatGPT, and it recommended using a simple hashtable, where key is start of a bitrange and value is the end of bitrange. As long as I use an open hashing table, it should be blazing fast, while at the same time guaranteeing that sparse bits wont kill performance significantly.

    Current Mood: amused
    7:18p
    "The Desktop Window Manager process has exited."
    Ok. The hashtable thing ChatGPT recommended wasn't as effective (albeit faster than roaring bitmap) and in fact taught me the hard way that running out of memory on Windows 11 tends to crash the display manager, which wont restart automatically and there is nothing one can do to restart it. 1/10. don't recommend.

    Have to proceed with my naive solution.

    BTW, that roaring bitmaps is apparently used by serious businesses, which do analytics on trillions of entities (i.e. user clicked this button event at second T), so it is slow, but compresses a terabyte dataset into a 128mb one, allowing to perform otherwise impossible computation on a phone:
    https://vikramoberoi.com/posts/using-bitmaps-to-run-interactive-retention-analyses-over-billions-of-events-for-less-than-100-mo/

    I think I can implement something comparable by compressing the currently unused bitmaps regions.

    Current Mood: amused

    << Previous Day 2024/07/24
    [Calendar]
    Next Day >>

About LJ.Rossia.org