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

Improve low level struct performance #46104

Open
1 of 5 tasks
jaredpar opened this issue Dec 15, 2020 · 8 comments
Open
1 of 5 tasks

Improve low level struct performance #46104

jaredpar opened this issue Dec 15, 2020 · 8 comments
Labels
area-TypeSystem-coreclr Bottom Up Work Not part of a theme, epic, or user story User Story A single user-facing feature. Can be grouped under an epic.
Milestone

Comments

@jaredpar
Copy link
Member

jaredpar commented Dec 15, 2020

This is a "User Story" to track the proposed improvements to low level struct performance improvements.

C# Language Features

The feature proposal for both C# features is captured here

Related Runtime Requests:

@jaredpar jaredpar added User Story A single user-facing feature. Can be grouped under an epic. Bottom Up Work Not part of a theme, epic, or user story labels Dec 15, 2020
@jaredpar jaredpar added this to the 6.0.0 milestone Dec 15, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Dec 15, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@benaadams
Copy link
Member

What about...?

Span<object> span = stackalloc object[5];

Which is sorta

struct Obj5
{
    object o0;
    object o1;
    object o2;
    object o3;
    object o4;
}

Obj5 objs = default;
Span<object> span = CreateSpan(ref objs.o0, 5);

@jaredpar
Copy link
Member Author

The stackalloc primitive doesn't support reference types.

@benaadams
Copy link
Member

localloc returning a byte* pointer is obv problematic for a reference type; however if it was limited to a Span<ref type> receiver and a fixed size rather than variable size then t could be translated to something closer to the safe fixed sized buffer proposal? e.g.

struct <Buffer>e__FixedBuffer_1024<T>
{
    private T _e0;
    private T _e1;
    // _e2 ... _e1023
    private T _e1024;

    public ref T this[int index] => ref (uint)index <= 1024u ?
                                         ref RefAdd<T>(ref _e0, index):
}

Not sure what the GC would make of referring only to an internal element of a stack struct (if it was sliced)

@jkotas
Copy link
Member

jkotas commented Dec 16, 2020

I think #25423 is the proposal we should follow to improve stackalloc.

@mangod9 mangod9 removed the untriaged New issue has not been triaged by the area owner label Jan 12, 2021
@mangod9
Copy link
Member

mangod9 commented Apr 12, 2021

@jaredpar this is unlikely for 6 due to statics in interfaces work. Ok to move out?

@mangod9
Copy link
Member

mangod9 commented May 10, 2021

Moving this to future, since this is moved out of .net 6.

@mangod9 mangod9 modified the milestones: 6.0.0, Future May 10, 2021
@iSazonov
Copy link
Contributor

Fore reference #38743

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TypeSystem-coreclr Bottom Up Work Not part of a theme, epic, or user story User Story A single user-facing feature. Can be grouped under an epic.
Projects
None yet
Development

No branches or pull requests

6 participants