You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Is my first PR so I expect plenty of fun times and issues 😅
In my benchmarking the non-buffered version is about 400-700ns faster, which is not as much as I would have hoped, but I do not think there is a huge amount of room in the design of format and Window's write API for great gains.
The format API ties the iterator type to everything, so we always must go through _Fmt_iterator_buffer writing char's into the buffer and flushing on demand, so using _fputc_nolock is hard since we never actually do anything character by character for the wrapped iterator and the type is important.
Instead I've generalised the optimization vector and string were doing of a customization point for the wrapped iterator when we flush and used that in these custom iterators to write to the stream or to the console with the parent holding a lock. This avoids need to ever allocate the final std::string or re-take the lock.
If we write to the console we must additionally transcode to wchar_t so we can call WriteConsoleW, I've reduced allocation there as well since it can often fit in a buffer but it is still work being done.
Its still a speedup, and I'm sure there is extra room for gains, but I tried various approaches and this was the "simplest" and reduced the most allocation calls.
(default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
(when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
Thanks, this is incredible! 😻 I pushed individual commits for the remaining issues I noticed, all small (the absence of const on a test format being the most significant).
We merge PRs to the GitHub and MSVC-internal repos in a semi-manual process, batched up to save time. Your PR will be part of the next batch, likely next week. I'll post comments here as I prepare it for merging!
Thanks for implementing this C++23 DR, and congratulations on your first microsoft/STL commit! 😻 🥳 🍰
This change is expected to ship in Preview 1 of whatever comes after VS 2022 17.12 (we don't know what it'll be yet, so we're calling it VS Meow in the Changelog until we do know).
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4509
Is my first PR so I expect plenty of fun times and issues 😅
In my benchmarking the non-buffered version is about 400-700ns faster, which is not as much as I would have hoped, but I do not think there is a huge amount of room in the design of format and Window's write API for great gains.
The format API ties the iterator type to everything, so we always must go through _Fmt_iterator_buffer writing char's into the buffer and flushing on demand, so using _fputc_nolock is hard since we never actually do anything character by character for the wrapped iterator and the type is important.
Instead I've generalised the optimization vector and string were doing of a customization point for the wrapped iterator when we flush and used that in these custom iterators to write to the stream or to the console with the parent holding a lock. This avoids need to ever allocate the final std::string or re-take the lock.
If we write to the console we must additionally transcode to wchar_t so we can call WriteConsoleW, I've reduced allocation there as well since it can often fit in a buffer but it is still work being done.
Its still a speedup, and I'm sure there is extra room for gains, but I tried various approaches and this was the "simplest" and reduced the most allocation calls.