LinuxCNC / linuxcnc

LinuxCNC controls CNC machines. It can drive milling machines, lathes, 3d printers, laser cutters, plasma cutters, robot arms, hexapods, and more.
http://linuxcnc.org/
GNU General Public License v2.0
1.79k stars 1.15k forks source link

Reorder member variables in 'block_struct' #2876

Closed havardAasen closed 8 months ago

havardAasen commented 8 months ago

The variables were arranged in alphabetical order, resulting in more than 10% of the total struct size being occupied by padding. However, by reorganizing the variables, the size was reduced from 1088 bytes to 960 bytes.

All variables is default initialized in the struct.

andypugh commented 8 months ago

Given that there may be many, many blocks, this might be worthwhile. Though at that point perhaps it is worth looking at the size of the comment field?

havardAasen commented 8 months ago

Given that there may be many, many blocks, this might be worthwhile. Though at that point perhaps it is worth looking at the size of the comment field?

I looked up RS274NGC version 3 and this specifies 256 characters, so if we decrease our field, we would deviate from the standard. Not sure how important it is to be consistent, I believe that 256 characters for a comment is on the larger side.

andypugh commented 8 months ago

I don't recall if G-code supports multi-line comments. It might, using the braces version. In that case 256 is possible.