microsoft / microsoft/STL

`<xmemory>`: Consider updating the overalignment for large allocations

Open
#2,215 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance vNext
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

In the _Allocate function (the backend used by std::allocator::allocate):

https://github.com/microsoft/STL/blob/d6f9987d7ec694b8599fe21e87e3653c36566223/stl/inc/xmemory#L219-L238

we have some magic to manually overalign "large" allocations:

https://github.com/microsoft/STL/blob/d6f9987d7ec694b8599fe21e87e3653c36566223/stl/inc/xmemory#L228-L230

with the goal of helping compilers to effectively autovectorize. The current value of _Big_allocation_alignment is 32:

https://github.com/microsoft/STL/blob/d6f9987d7ec694b8599fe21e87e3653c36566223/stl/inc/xmemory#L108

which is an excellent choice for SSE and AVX, but it appears that AVX512 would prefer 64-byte alignment. See the discussion in #2104. We should consider "bumping" the value of _Big_allocation_alignment in vNext to better accommodate future processors.


vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the _Allocate function and _Big_allocation_alignment in stl/inc/xmemory, then read the discussion in #2104 and the vNext guidance in #169. Evaluate the alignment choice for future processors, accounting for the stated binary-compatibility constraint; the issue is done when an agreed vNext change is specified and validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.