[ruby/prism] Do not serialize common flags when PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS is set

* Note that we could shift the flags by 2 on serialize & deserialize
  but it does not seems worth it as it does not save serialized size
  in any significant amount, i.e. average was 0.799 before #2924.
* $ bundle exec rake serialized_size:topgems
Before:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  69477115
total serialized/total source: 0.770

Stats of ratio serialized/source per file:
average: 0.844
median:  0.825
1st quartile: 0.597
3rd quartile: 1.064
min - max: 0.078 - 3.792

After:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  66150209
total serialized/total source: 0.733

Stats of ratio serialized/source per file:
average: 0.800
median:  0.779
1st quartile: 0.568
3rd quartile: 1.007
min - max: 0.076 - 3.675

https://github.com/ruby/prism/commit/e012072f70
This commit is contained in:
Benoit Daloze 2024-07-24 21:57:11 +02:00 коммит произвёл git
Родитель 9cc2747ebb
Коммит 53f0d3b1f7
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -92,7 +92,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
size_t length_offset = buffer->length;
pm_buffer_append_string(buffer, "\0\0\0\0", 4); /* consume 4 bytes, updated below */
<%- end -%>
<%- unless Prism::Template::SERIALIZE_ONLY_SEMANTICS_FIELDS && !node.flags -%>
pm_buffer_append_varuint(buffer, (uint32_t) node->flags);
<%- end -%>
<%- node.fields.each do |field| -%>
<%- case field -%>
<%- when Prism::Template::NodeField -%>