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
We query TOKEN_USER and TOKEN_OWNER hundreds of times a day and since WIL doesn't use the fixed sizes for these types it's instead using multiple system calls to query the size, then multiple system calls to allocate virtual memory (also waiting/blocking the process heap lock) which is a significantly more slower and larger overhead than necessary.
The WIL templates should be doing something like this instead:
When I first added these helpers, templatizing on the type seemed right; instead, I should have templatized on the info class instead, and used that to imply the output type. I'll look into adding a variants that do that.When C++20 constexpr is enabled it should also make the code denser.
At the time, the goal was to avoid allocating more than necessary in the common case. The OS had lots of the "dual call" sequences, so I just lifted them all into this method.
However, I can see a parallel set of types that have a fixed buffer inside them that provide the T result on a block of bytes, appropriately aligned.
Hello,
The WIL library defines some token classes without fixed sizes. For example:
wil/include/wil/token_helpers.h
Lines 38 to 57 in a8cd266
TOKEN_USER was defined
FixedSize = false
when it has a fixed size defined in the Windows SDK:The others also have types in the Windows SDK:
As an example this WIL code:
Is expanded into:
wil/include/wil/token_helpers.h
Lines 177 to 188 in a8cd266
We query TOKEN_USER and TOKEN_OWNER hundreds of times a day and since WIL doesn't use the fixed sizes for these types it's instead using multiple system calls to query the size, then multiple system calls to allocate virtual memory (also waiting/blocking the process heap lock) which is a significantly more slower and larger overhead than necessary.
The WIL templates should be doing something like this instead:
The text was updated successfully, but these errors were encountered: