News for hackers. Stuff that matters.
Re:Optimizing the unoptimizable: a journey to faster C++ com... by widdershins on Sunday January 07, 2024 @04:31AM (#38899817)
So why on earth is std::string so slow to compile, if it's possible to compile this full-featured formatting library in 1/4 of the time?
Re:Optimizing the unoptimizable: a journey to faster C++ com... by vitaut on Sunday January 07, 2024 @10:48AM (#38902177)
AFAICS the main problem is that <string> pulls in a lot of dependencies.
Re:Optimizing the unoptimizable: a journey to faster C++ com... by mkoubaa on Sunday January 07, 2024 @03:51PM (#38905007)
Surely this is an implementation detail that vendors can change
Re:Optimizing the unoptimizable: a journey to faster C++ com... by vitaut on Sunday January 07, 2024 @05:03PM (#38905622)
Implementations can be improved somewhat but there is a certain set of dependencies that must be included according to the standard and for string it's pretty big.
Re:Optimizing the unoptimizable: a journey to faster C++ com... by pjmlp on Sunday January 07, 2024 @03:19PM (#38904758)
It isn't when using modules, import std brings in the whole standard C++ faster than that #include.

EDIT:

This compiles in 1 second on an i7 laptop.

    import std;

    int main()
    {
        std::cout << "Hello World!\n";
    }
Re:Optimizing the unoptimizable: a journey to faster C++ com... by vitaut on Sunday January 07, 2024 @05:35PM (#38905916)
Unfortunately the std module alone doesn't help much because 1 second is 3x slower than before the optimization described in the post but maybe more fine-grained modules will (or if std module import made faster).
Re:Optimizing the unoptimizable: a journey to faster C++ com... by pjmlp on Monday January 08, 2024 @02:02AM (#38909009)
For the whole library, everything.

Also Microsof Office team has been migrating to modules, with great build improvements.

Re:Optimizing the unoptimizable: a journey to faster C++ com... by za3faran on Monday January 08, 2024 @09:36AM (#38912487)
Any place where I can read up more about this?
Re:Optimizing the unoptimizable: a journey to faster C++ com... by pjmlp on Monday January 08, 2024 @09:57AM (#38912822)
https://devblogs.microsoft.com/cppblog/integrating-c-header-...

https://devblogs.microsoft.com/cppblog/integrating-c-header-...

Key takeway

"Fortunately, we were able to show a build performance improvement great enough that the team agreed to adopt header units into the Office production build system alongside msvc 17.6.6!"

Unfortunely the performance findings blogpost is still WIP.

Re:Optimizing the unoptimizable: a journey to faster C++ com... by OskarS on Monday January 08, 2024 @03:37AM (#38909500)
Not to be "that guy", but... one second is a VERY VERY long time to compile a hello world program.
Re:Optimizing the unoptimizable: a journey to faster C++ com... by pjmlp on Monday January 08, 2024 @03:46AM (#38909556)
Including compiling from scratch the complete C++ standard library on first use, which I should probably have mentioned.
Re:Optimizing the unoptimizable: a journey to faster C++ com... by OskarS on Tuesday January 09, 2024 @11:32AM (#38928062)
What's the incremental compile time? If you just change that "Hello World" string to something else, does it compiler faster the second time?