Closed tomwhoiscontrary closed 3 months ago
1.32 introduced lazy cashflows, it might be related to that change - I'll try to reproduce using your test code
When you say newer compiler versions cause performance issues, do you mean longer build times or degraded performance during runtime?
@pcaspers I mean degraded performance during runtime. It's been a while since i tried though. I am trying to set up some infrastructure to explore this in a reproducible and shareable way - hopefully i can update you on that at some point.
Ok interesting. Keep us updated on that topic.
@tomwhoiscontrary The usual high Sharpe ratio way to find the source of slow code is to use a profiler like VTune Profiler. Maybe you can try that and let us know what you find?
I couldn't reproduce it on my Mac—if anything, 1.34 was slightly faster. Compiled with the configure and cxx flags you reported, but of course it's clang, not gcc, and I have the latest boost installed.
The same goes for an Ubuntu 22.04.4 machine, default gcc 11.4. No difference.
Interesting. That's encouraging, because it means there might be a problem with my build environment, but frustrating, because it means there might be a problem with my build environment.
I'm trying to set up a simple self-contained build in a docker container, where i can vary the compiler, Boost version, and QuantLib version. This is proving a surprisingly rocky road so far, though. Will keep you posted.
Thanks!
I have written a script to run this demo in a docker container with a defined version of GCC and QuantLib: https://github.com/tomwhoiscontrary/QuantLibDemo
It gets Boost from the distro package manager, so that depends on the version of Debian used by the GCC image. It doesn't seem to make much difference, though. I would like to get that under vcpkg at some point.
The results from this are interesting - all combinations of GCC and QuantLib give a result of about 21 - 26 ms per iteration. It mostly gets faster with later GCC versions, and mostly stays the same across QuantLib versions. There are deviations from that pattern which might be meaningful and might be noise, but are fairly minor.
So the good (?) news is that this does not reproduce my core worry, that QL has got significantly slower. On the strength of that, i'm happy to close this bug. I'll keep working on this, and let you know if i find anything.
One thing that's different between this and my real codebase is that here, the same compiler is used for QuantLib and the demo code, whereas for in the real code, we build QuantLib with GCC 7 and the Demo with GCC 13. I'd be surprised if that combination was faster in this setting.
Something that's quite odd here is that the performance is >20 ms, whereas in my local build outside a container, using QuantLib 1.31, it's 10 ms.
Well, I would say "good to hear" if it wasn't for your problem...
Thanks for the analysis, and do keep us informed!
I resolved this. There was no problem with QuantLib at all. There was an incidental change to our build scripts around the same time as QuantLib 1.33 came out which disabled optimisations!
Ok, this time I can say "good to hear" :)
We have been running on 1.31 for a while. I am attempting to upgrade to 1.34. Once the necessary changes were made, i found that my application produced identical results, but was considerably slower - measured at a very coarse granularity (roughly "build a particular curve and evaluate a lot of metrics"), things took 2x - 3x longer.
I have picked one fairly simple subsystem and extracted it into a standalone program which just needs QuantLib to build. The program runs in a loop building an ESTR curve from OIS quotes, and then pricing swaps, timing how long it takes to price the swaps. It does twenty warmup iterations, then twenty measurement iterations, and prints the time taken in milliseconds for each of the latter (along with the minimum and maximum calculated swap rates, as a sanity check). This shows a roughly 4x - 5x slowdown in pricing swaps.
With 1.31 it prints:
With 1.34 it prints:
See DiscountingCurveDemo.cpp.txt for the code.
My versions of QuantLib carry some small patches affecting the calculation of swap BPS, but that should not be relevant here.
I compiled QuantLib with GCC 7.2.0, and Boost 1.66.0. My build script contains:
I compiled the app with GCC 13.1.0. My CMakeLists.txt includes:
The reason i'm compiling QuantLib with such an old GCC is that i've seen significant performance regressions using newer ones.
I'm on Ubuntu 22.04.4.
Do you have any thoughts on this? Can you reproduce this difference? If not, do you see any obvious differences between your setup and mine? I am happy to spend time changing things around at my end - but so far, the difference has been unavoidable, so i would like to have some high-Sharpe-ratio ideas on what to change!