melt-umn / silver

An attribute grammar-based programming language for composable language extensions
http://melt.cs.umn.edu/silver/
GNU Lesser General Public License v3.0
57 stars 7 forks source link

"ECS-style" Nodes #765

Open remexre opened 1 year ago

remexre commented 1 year ago

Putting this here as a note -- this is an experiment I wanna try after the deadline.

Instead of storing an array of attributes per-node, we could assign each node an int ID (unique per TopNode, "densely assigned") and give it a pointer to the TopNode, then store a HashMap<AttributeId, Object[]> on the TopNode, where the indices in the arrays are the node IDs.

This feels like it oughta be a quick enough change to try out in a week or so.

krame505 commented 1 year ago

What does "ECS-style" mean?

Is the goal of this to reduce memory usage? Or performance?

remexre commented 1 year ago

Performance; improved cache locality, mainly.

ECS is a style of OO some games / game engines do as a library, where objects are just int(-sized struct)s (Entities), you store arrays (or some other sparser data structure) of their fields (Components), and you perform computations over them as "for every entity with non-null values for components A, B, and C," which are easy to parallelize and have nice cache usage (Systems).