← Back to team overview

kicad-developers team mailing list archive

Re: RICHIO performance - 3 to 30 times slower than std::ifstream

 

On 3/2/2017 11:35 AM, John Beard wrote:
> On Thu, Mar 2, 2017 at 10:30 PM, Wayne Stambaugh <stambaughw@xxxxxxxxx> wrote:
>>
>> One thing I overlooked is wxWidgets provides wxBufferedInputStream[1]
>> which takes a reference to a wxInputStream object as an argument.  The
>> reason wxFileInputStream and wxFFileInputStream may be so slow is that
>> they are not buffered at all internally and need to be wrapped by
>> wxBufferedInputStream to perform the buffering.  It might be something
>> worth taking a look at.
> 
> I tried this out - there's a factor of just over 10 improvment over a
> plain wxFileInputStream and a 30% ish speedup over wxFFileStream, but
> it's still 20 times slower than std::ifstream. I can't help but think
> I'm just doing all the wx stuff wrong - it cannot be that bad for
> reals!

Are you testing debug builds or release builds?  It's possible that on
debug builds there is some debugging stuff coming into play.

> 
> 
> I have also noticed, doing this in a quieter room, that the 4000ms
> wxInputStream benchmarks (File, FFile and Buffered) cause the fans on
> my computer to kick up to full, so something is being computed
> furiously!
> 
> std::fstream                   317858 lines, acc: 25103384 in 16 ms
> std::fstream, reused           317858 lines, acc: 25103384 in 16 ms
> RICHIO                         317858 lines, acc: 25103384 in 95 ms
> RICHIO, reused                 317858 lines, acc: 25103384 in 93 ms
> std::ifstream L_R              317858 lines, acc: 25103384 in 21 ms
> std::ifstream L_R, reused      317858 lines, acc: 25103384 in 21 ms
> wxFileIStream                  317858 lines, acc: 25103384 in 4218 ms
> wxFileIStream, reused          317858 lines, acc: 25103384 in 4225 ms
> wxFFileIStream                 317858 lines, acc: 25103384 in 568 ms
> wxFFileIStream, reused         317858 lines, acc: 25103384 in 567 ms
> wxFileIStream. buf'd           317858 lines, acc: 25103384 in 380 ms
> wxFileIStream, buf'd, reused   317858 lines, acc: 25103384 in 383 ms
> wxFFileIStream. buf'd          317858 lines, acc: 25103384 in 376 ms
> wxFFileIStream, buf'd, reused  317858 lines, acc: 25103384 in 376 ms
> 
> For the wx streams, if you do more reps, there's a huge increase in
> releative slowness
>  (above is 2, below is 10):
> 
> std::fstream                   1589290 lines, acc: 125516920 in 81 ms
> wxFileIStream                  1589290 lines, acc: 125516920 in 21279 ms
> wxFileIStream. buf'd           1589290 lines, acc: 125516920 in 14394 ms
> 
> No idea what's behind all this, any I'll be happy to be told im
> Holding It Wrong (TM)!
> 
> Patch for adding buffered wx streams to the benchmark tool attached.

I committed this patch.  Thanks.

> 
> Cheers,
> 
> John
> 


References