← Back to team overview

kicad-developers team mailing list archive

Re: Strokefont change from std::deque to std::vector

 

Hi Seth,

Trying to keep track of lengths is going to be ugly.  I did re-write the bounding-box calc (which saves a bunch), and re-mapped the initialisation to use stack storage until all the points had been allocated (which saves a little).

But it’s still too slow (especially when you try to edit a pad).

A glyph is an array of strokes; a stroke is an array of points.  Do you remember which was giving the issue?  (Or was it both?)

Changing the glyph back to a deque (and leaving the strokes vectors) would probably alleviate much of the performance hit — but I’m not sure if it would bring back the memory issues or not.

Cheers,
Jeff.


> On 3 Dec 2019, at 00:57, Seth Hillbrand <seth@xxxxxxxxxxxxx> wrote:
> 
> On 12/2/19 3:45 PM, Jeff Young wrote:
>> Hi Seth,
>> 
>> What was the reason for the change from std::deque to std::vector?  Building the stroke font is now accounting for 50% of document load time (I think because we’re using a 2D vector so that any resize of any constituent vector has to reallocate the whole shebang).
>> 
>> We also load the font twice, which is something I’ll look at fixing irrespective of the above.
>> 
>> Thanks,
>> Jeff.
>> 
>> 
> 
> Hmm... That's true.  As we are allocating, we don't have pre-knowledge of the Hershey point list lengths, so the vectors get resized as we add.  How much will depend a bit on implementation.  But we'll gain speed by cycling once over the font and building our length knowledge first.
> 
> The vector change was due to the deque overhead.  A deque takes a fair amount of memory for the structure.  We generate a bunch of vectors with only 3-4 elements and the size of the deque is dominated by the structure overhead.  There was so much that JP's machine was crashing with the extra CJK fonts.
> 
> Best-
> Seth
> 
> -- 
>  
> Seth Hillbrand
> Lead Developer
> +1-530-302-5483‬ <tel:+12126039372>
> Davis, CA
> www.kipro-pcb.com <https://www.kipro-pcb.com/>    info@xxxxxxxxxxxxx <mailto:info@xxxxxxxxxxxxx>
>  <https://twitter.com/KiProEDA>   <https://twitter.com/KiProEDA>	 <https://www.linkedin.com/company/kicad>   <https://www.linkedin.com/company/kicad>_______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp


Follow ups

References