-
Federico Mena Quintero authored
A Path contains a boxed slice of PathCommand, which is the shrunk-to-fit Vec<PathCommand> from the PathBuilder. The boxed slice doesn't have the overhead of the capacity value. For the huge map file in issue #574, this reduces path overhead by a nice bit: Before: -------------------------------------------------------------------------------- n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) -------------------------------------------------------------------------------- 23 22,751,613,855 1,560,916,408 1,493,746,540 67,169,868 0 95.70% (1,493,746,540B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc. ->43.94% (685,929,024B) 0x49FF0BB: alloc (alloc.rs:84) | ->43.94% (685,929,024B) 0x49FF0BB: exchange_malloc (alloc.rs:206) | ->43.94% (685,929,024B) 0x49FF0BB: new<rsvg_internals::element::Element> (boxed.rs:121) | ... | ->36.05% (562,764,384B) 0x49CC457: realloc (alloc.rs:128) | ->36.05% (562,764,384B) 0x49CC457: realloc (alloc.rs:187) | ->36.05% (562,764,384B) 0x49CC457: reserve_internal<rsvg_internals::path_builder::PathCommand,alloc::alloc::Global> (raw_vec.rs:693) | ->36.05% (562,764,384B) 0x49CC457: alloc::raw_vec::RawVec<T,A>::reserve (raw_vec.rs:520) | ->22.36% (349,090,560B) 0x49927B0: reserve<rsvg_internals::path_builder::PathCommand> (vec.rs:501) | | ->22.36% (349,090,560B) 0x49927B0: push<rsvg_internals::path_builder::PathCommand> (vec.rs:1150) After: -------------------------------------------------------------------------------- n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) -------------------------------------------------------------------------------- 30 22,796,106,012 1,553,581,072 1,329,943,324 223,637,748 0 85.61% (1,329,943,324B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc. ->44.15% (685,929,024B) 0x49FF25B: alloc (alloc.rs:84) | ->44.15% (685,929,024B) 0x49FF25B: exchange_malloc (alloc.rs:206) | ->44.15% (685,929,024B) 0x49FF25B: new<rsvg_internals::element::Element> (boxed.rs:121) | The ones with slack space: ->22.53% (350,014,176B) 0x4A23300: realloc (alloc.rs:128) | ->22.53% (350,014,176B) 0x4A23300: realloc (alloc.rs:187) | ->22.53% (350,014,176B) 0x4A23300: shrink_to_fit<rsvg_internals::path_builder::PathCommand,alloc::alloc::Global> (raw_vec.rs:633) | ->22.53% (350,014,176B) 0x4A23300: shrink_to_fit<rsvg_internals::path_builder::PathCommand> (vec.rs:623) | ->22.53% (350,014,176B) 0x4A23300: alloc::vec::Vec<T>::into_boxed_slice (vec.rs:679) | ->22.53% (350,014,176B) 0x4A03410: into_path (path_builder.rs:316) | | ... | The ones without slack space: ->03.48% (54,029,952B) 0x49CC577: realloc (alloc.rs:128) | ->03.48% (54,029,952B) 0x49CC577: realloc (alloc.rs:187) | ->03.48% (54,029,952B) 0x49CC577: reserve_internal<rsvg_internals::path_builder::PathCommand,alloc::alloc::Global> (raw_vec.rs:693) | ->03.48% (54,029,952B) 0x49CC577: alloc::raw_vec::RawVec<T,A>::reserve (raw_vec.rs:520) | ->02.98% (46,292,544B) 0x49927E0: reserve<rsvg_internals::path_builder::PathCommand> (vec.rs:501) | | ->02.98% (46,292,544B) 0x49927E0: push<rsvg_internals::path_builder::PathCommand> (vec.rs:1150) | | ->02.98% (46,292,544B) 0x49927E0: line_to (path_builder.rs:325)
fc44abd1