Reimplement folly::Function to improve compile times.
Summary:
folly::Function is causing significant compile time regressions. Reimplement it in a simpler way.
These are the times for a file containing 1000 instantiations of folly::Fuction (old), folly::Function (new), and std::function with **g++ 4.8 -O3** on my CentOS7 server.
| | Old `folly::Function` | `std::function` | New `folly::Function` |
|--------|-----------------------|-----------------|-----------------------|
| Time | 10m37s | 0m16.81s | 0m14.75s |
And for the executable size:
| | Old `folly::Function` | `std::function` | New `folly::Function` |
|--------|-----------------------|-----------------|-----------------------|
| Size | 10,409,504 | 732,150 | 562,781 |
That's a **43X** improvement in compile times and an **18X** reduction in executable bloat over the old implementation.
The times for **clang (trunk)** are very different:
| | Old `folly::Function` | `std::function` | New `folly::Function` |
|-------|-----------------------|-----------------|-----------------------|
| Time | 4m6s | 0m45.27s | 0m11.78s |
That's a **20X** improvement over the old implementation and almost a **4X** improvement over `std::function`.
For **gcc-5.3.0**, compile times are again different:
| | Old `folly::Function` | `std::function` | New `folly::Function` |
|-------|-----------------------|-----------------|-----------------------|
| Time | 2m49s | 0m18.99s | 0m20.70s |
With gcc-5.3, the new implementation "only" compiles 8x faster than the old one, and is roughly the same as `std::function`.
Reviewed By: spacedentist, ot, luciang
Differential Revision:
D3199985
fb-gh-sync-id:
b97982a9dc3a63140510babea34988932e89f2d9
fbshipit-source-id:
b97982a9dc3a63140510babea34988932e89f2d9