`<chrono>`: Can we avoid including `<format>`?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
On reddit, u/tgolyi reports:
std::formatis very cool, but why did you include<format>to<chrono>? This change alone slowed down compilation for our project by 20%. Is it required by the standard now to include<format>(to supportstd::formatterspecialization)? It's just that<chrono>is included by so many other headers like<mutex>and<thread>and Qt too.
Separately from any throughput improvements for <format>, I believe it should be possible to remove this dependency:
The fix would presumably involve some combination of:
- Forward declarations (of
formatteretc.) - Extracting common machinery to a centralized header somewhere (used sparingly, since this costs throughput)
- Possibly templatizing stuff so that it isn't instantiated until needed (need to follow the Standard's lookup rules)
Related to DevCom-10046069 "Including chrono and compiling with -std:c++20 is ten time slower than before" and internal VSO-1543202 / AB#1543202 .
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at stl/inc/chrono lines 37-40 and trace why includes , including the formatter declarations and standard lookup requirements. Evaluate the proposed forward declarations or shared machinery, with completion requiring removal of the unnecessary dependency without violating the standard or regressing compilation throughput.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100