5 ms·
Are there any programming languages which change the data layout beyond naively sorting struct members by alignment? (which at best helps with reducing padding
by flohofwoe 4mo ago
Are there any programming languages which change the data layout beyond naively sorting struct members by alignment? (which at best helps with reducing padding bytes but can be either good or bad for performance, depending on the code which accesses the data).
- londons_explore 4mo agoOne simple optimization is to change arrays of struts into struts of arrays. To my knowledge, nothing even makes those changes, despite them being safe and having a huge potential performance benefit.
- flohofwoe 4mo agoNow that you mention it... :) Zig has MultiArrayList in the stdlib which does the SoA transform via comptime: https://ziglang.org/documentation/master/std/#std.multi_array_list.MultiArrayList https://ziglang.org/documentation/master/std/#std.multi_arra... Zig also sorts struct members by size/alignment, but has two escape hatches ('extern struct' which is for C compatibility, and 'packed struct' which offers an explicit bit-by-bit memory layout). AFAIK Odin and Jai offer the SoA transform as specialized language features, e.g. in Odin: https://odin-lang.org/docs/overview/#soa-data-types https://odin-lang.org/docs/overview/#soa-data-types I'd still always want such data layout transforms as an explicit language feature though, not the compiler making this decision for me.
- pillmillipedes 4mo agovarious SQLs and APLs come to mind :) the industry still has a lot to learn from them both
- fulafel 4mo agoHalide comes to mind (though it a DSL and not a full independent language). I wonder if Futhark does? Eg https://futhark-lang.org/student-projects/pedersen-nelin-msc-thesis.pdf https://futhark-lang.org/student-projects/pedersen-nelin-msc...