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

[stdlib] Add InlineList struct (stack-allocated List) #2587

Closed

Conversation

gabrieldemarmiesse
Copy link
Contributor

@gabrieldemarmiesse gabrieldemarmiesse commented May 8, 2024

This struc is very useful to implement SSO, it's related to

If this is merged, I can take advantage of this in my PR that has the SSO POC

About InlineFixedVector: InlineList is different. Notably, InlineList have its capacity decided at compile-time, and there is no heap allocation (unless the elements have heap-allocated data of course).

InlineFixedVector stores the first N element on the stack, and the next elements on the heap. Since not all elements are not in the same spot, it makes it hard to work with pointers there as the data is not contiguous.

Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
@gabrieldemarmiesse gabrieldemarmiesse marked this pull request as ready for review May 8, 2024 12:38
@gabrieldemarmiesse gabrieldemarmiesse requested a review from a team as a code owner May 8, 2024 12:38
@JoeLoser JoeLoser added the imported-internally Signals that a given pull request has been imported internally. label May 8, 2024
Copy link
Collaborator

@JoeLoser JoeLoser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a few minor comments and a rebase is needed to fixup the constructor added to InlineArray.

stdlib/src/collections/inline_list.mojo Outdated Show resolved Hide resolved
stdlib/src/utils/static_tuple.mojo Outdated Show resolved Hide resolved
stdlib/test/collections/test_inline_list.mojo Outdated Show resolved Hide resolved
stdlib/test/collections/test_inline_list.mojo Outdated Show resolved Hide resolved
@JoeLoser JoeLoser self-assigned this May 9, 2024
Gabriel de Marmiesse and others added 5 commits May 9, 2024 12:51
Co-authored-by: Joe Loser <joeloser@fastmail.com>
Signed-off-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com>
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
@modularbot
Copy link
Collaborator

✅🟣 This contribution has been merged 🟣✅

Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours.

We use Copybara to merge external contributions, click here to learn more.

@modularbot modularbot added the merged-internally Indicates that this pull request has been merged internally label May 10, 2024
JoeLoser pushed a commit that referenced this pull request May 11, 2024
…39560)

[External] [stdlib] Add `InlineList` struct (stack-allocated List)

This struc is very useful to implement SSO, it's related to
* #2467
* #2507

If this is merged, I can take advantage of this in my PR that has the
SSO POC

About `InlineFixedVector`: `InlineList` is different. Notably,
`InlineList` have its capacity decided at compile-time, and there is no
heap allocation (unless the elements have heap-allocated data of
course).

`InlineFixedVector` stores the first N element on the stack, and the
next elements on the heap. Since not all elements are not in the same
spot, it makes it hard to work with pointers there as the data is not
contiguous.

Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com>
Closes #2587
MODULAR_ORIG_COMMIT_REV_ID: 86df7b19f0f38134fbaeb8a23fe9aef27e47c554
@JoeLoser
Copy link
Collaborator

Landed in today's nightly: #2615. Thanks for the great contribution! Excited to see this applied to your SSO work.

@JoeLoser JoeLoser added the merged-externally Merged externally in public mojo repo label May 11, 2024
@JoeLoser JoeLoser closed this May 11, 2024
lsh pushed a commit to lsh/mojo that referenced this pull request May 17, 2024
…39560)

[External] [stdlib] Add `InlineList` struct (stack-allocated List)

This struc is very useful to implement SSO, it's related to
* modularml#2467
* modularml#2507

If this is merged, I can take advantage of this in my PR that has the
SSO POC

About `InlineFixedVector`: `InlineList` is different. Notably,
`InlineList` have its capacity decided at compile-time, and there is no
heap allocation (unless the elements have heap-allocated data of
course).

`InlineFixedVector` stores the first N element on the stack, and the
next elements on the heap. Since not all elements are not in the same
spot, it makes it hard to work with pointers there as the data is not
contiguous.

Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com>
Closes modularml#2587
MODULAR_ORIG_COMMIT_REV_ID: 86df7b19f0f38134fbaeb8a23fe9aef27e47c554

Signed-off-by: Lukas Hermann <lukashermann28@gmail.com>
modularbot pushed a commit that referenced this pull request Jun 7, 2024
…39560)

[External] [stdlib] Add `InlineList` struct (stack-allocated List)

This struc is very useful to implement SSO, it's related to
* #2467
* #2507

If this is merged, I can take advantage of this in my PR that has the
SSO POC

About `InlineFixedVector`: `InlineList` is different. Notably,
`InlineList` have its capacity decided at compile-time, and there is no
heap allocation (unless the elements have heap-allocated data of
course).

`InlineFixedVector` stores the first N element on the stack, and the
next elements on the heap. Since not all elements are not in the same
spot, it makes it hard to work with pointers there as the data is not
contiguous.

Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com>
Closes #2587
MODULAR_ORIG_COMMIT_REV_ID: 86df7b19f0f38134fbaeb8a23fe9aef27e47c554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported-internally Signals that a given pull request has been imported internally. merged-externally Merged externally in public mojo repo merged-internally Indicates that this pull request has been merged internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants