Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce inclusion for <queue> and <stack> #4707

Merged

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Jun 2, 2024

Towards #3599.

Test options

  • cl /nologo /Bt /Zs /TP /w repro.cpp /std:c++14 /permissive- repro.cpp
  • cl /nologo /Bt /Zs /TP /w repro.cpp /std:c++17 /permissive- repro.cpp
  • cl /nologo /Bt /Zs /TP /w repro.cpp /std:c++20 /permissive- repro.cpp
  • cl /nologo /Bt /Zs /TP /w repro.cpp /std:c++latest /permissive- repro.cpp

Test programs

#include <stack>
int main() {}
#include <queue>
int main() {}

Results

On my old laptop, the changes reduced the consumed time

  • for <queue>, from ~1.08s to ~0.57s in C++23 mode;
  • for <queue>, from ~0.62s to ~0.49s in C++20 mode;
  • for <queue>, from ~0.43s to ~0.37s in C++17 mode;
  • for <queue>, from ~0.37s to ~0.33s in C++14 mode;
  • for <stack>, from ~0.77s to ~0.51s in C++23 mode.
  • not significantly for <stack> in older modes.

Notes

Escape hatch _LEGACY_CODE_ASSUMES_QUEUE_INCLUDES_ALGORITHM can be used to restore the inclusion of <algorithm>.

MSVC-internal changes are needed due to the new internal headers.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner June 2, 2024 07:43
@StephanTLavavej StephanTLavavej added the throughput Must compile faster label Jun 4, 2024
@StephanTLavavej StephanTLavavej self-assigned this Jun 4, 2024
@StephanTLavavej StephanTLavavej added the decision needed We need to choose something before working on this label Jun 11, 2024
@StephanTLavavej StephanTLavavej removed their assignment Jun 11, 2024
@StephanTLavavej

This comment was marked as resolved.

@StephanTLavavej StephanTLavavej removed the decision needed We need to choose something before working on this label Jun 12, 2024
@StephanTLavavej

This comment was marked as resolved.

@StephanTLavavej
Copy link
Member

I pushed commits:

  • Rename to <__msvc_ranges_to.hpp>.
    • I found <__msvc_transform_view_to.hpp> confusing because it defines a lot more than transform_view and ranges::to. I think it's better to focus on how it provides ranges::to, instead of mentioning some-but-not-all C++20 machinery in the filename.
  • Add a comment explaining what the header provides.
    • But then let's clarify the intent of the header here.
  • Move _HAS_CXX23 <xmemory> inclusion to avoid disrupting auto-sorting.
  • Transfer all overloads of ranges::to.
  • <algorithm>: Fuse _HAS_CXX20 namespace ranges regions.
  • Update comment to mention both <xutility> and <__msvc_ranges_to.hpp>.
  • <ranges>: Fuse _HAS_CXX23 regions.

@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 3d781e6 into microsoft:main Jun 18, 2024
39 checks passed
@StephanTLavavej
Copy link
Member

Thanks for queuing up this giant stack of throughput improvements! 😹 🎉 🐱

@frederick-vs-ja frederick-vs-ja deleted the throughput-queue-stack branch June 18, 2024 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
throughput Must compile faster
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants