Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wonder what kind of hardware OP runs on, and which compiler is used.

Here on my laptop (Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz), on linux, compiling an eigen example takes 0.7 seconds

    clang++ -fuse-ld=lld eigen.cpp -I/usr/include/eigen3/  0,66s user 0,07s system 100% cpu 0,728 total
if I put the eigen header in a PCH this drops to 0.1 seconds

    clang++ -fuse-ld=lld eigen.cpp -I/usr/include/eigen3/ -include-pch   0,08s user 0,02s system 104% cpu 0,099 total
I have a hard time seeing how 300 lines of code (vs the 10 lines of the example) would multiply compile times by 300 - here's the example I used

    #include <iostream>
    #include <Eigen/Dense>
 
    using Eigen::MatrixXd;
 
    int main()
    {
      MatrixXd m(2,2);
      m(0,0) = 3;
      m(1,0) = 2.5;
      m(0,1) = -1;
      m(1,1) = m(1,0) + m(0,1);
      std::cout << m << std::endl;
    }
I develop a GUI software with boost, Qt, and a fair amount of TMP and my average turn-around time from a change in the average file to the program running is between in and 2 seconds. Maybe it could get down to 0.1~ seconds if using C, but there would be so many less checks and guards !


Haven’t used Eigen for quite a while, but I do remember it being rather slow to compile once it proliferates. Those templates are clever but also quite taxing.


Even so, using another math library would have been the solution then.


The bits of eigen that make it slow to compile are the same bits that make it both easy to use and fast. I'm sure there are improvements that could be made, but ultimately eigen is big and slow to compile for a reason.


Unfortunately our example isn't representative, and avoids a lot of things that make eigen slow to work with. Parsing the header file will take a constant time, but template expansion etc. can take a long time if you have more code.

Try adding a bunch of matrix operations (particularly chained ones resulting in massive expression templates), fixed size matrices of various sizes, and compile with optimisation and SIMD enabled, and you'll see different results. I really like eigen and use it a lot, but it can definitely result in long compile times.


Does it get significantly slower if you use Eigen's fixed size matrices? I have a C++ project which uses Eigen and some other templates (but nothing crazy) and it is quite slow to compile. Not complaining though because I don't compile often.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: