4 ms·
> you can stripe the data for one object into multiple arrays and use the same handle to index each of them which can improve locality. I wish programming lang
by jagger27 6y ago
> you can stripe the data for one object into multiple arrays and use the same handle to index each of them which can improve locality.
I wish programming languages made it easy to structure arrays of objects like this. I think Johnathan Blows’s JAI has some kind of transparent support for SoA.
- yiyus 6y agoThis basically is how tables work in k. Tables are defined as a list of dictionaries, but in fact stored as an array for each element (ie. each column of the table is an array, but each row can be read as a dictionary).
- gumby 6y agoIt’s trivial to do this in C++ and often the caller doesn’t even realize.
- aks_tldr 6y agodo you have any pointers of such implementation ?
- gumby 6y agoWe have a mixin class that will allocate a subclass with its own array of handles (the handles overload * and -> so they act like pointers). If you have an instance variable you can choose to give it a different allocator, where that instance variable of object with handle `n` is the nth object in the new area. Then your instance method `barf& foo();`, instead of getting the instance variable `barf m_foo` Instead does some inlined arithmetic and gives the caller a reference to the object.