Skip to content

Allowing FastExpressions to allocate on Stack? #326

Closed

Description

@CodingMadness

Pretty much title.

Is this somehow possible, when I can guarantee myself that the Expression wont ever escape the stack-frame it was declared in?

That would be kinda sick, but I fear, it has to do more with how the CLR of .net handles these allocations...

Activity

  1. dadhi commented on Mar 22, 2022

    @dadhi
    Owner

    @Shpendicus

    Once upon a time I was trying to do that. It was even somewhere in the branch (now deleted).
    But it is hard without inventing your own allocator on stack to represent tree-like nested structures (usually done with references). I could imagine it can be done, especially with the modern .NET and probably with data-oriented data structures, indexes as pointers, etc.

    Regarding the short-lived expressions I think it is a good inception for doing that.

    Another No for this approach (at least for now) is to have API surface compatibility with the System.Linq.Expressions. I immediately broke this rule when trying it out in the branch.

    Currently, I am trying to save allocations just by minimizing them, e.g. packing things, customizing expressions for the variant number of arguments, etc.

    But... any ideas are welcome!

  2. CodingMadness commented on Mar 23, 2022

    @CodingMadness
    Author

    Hey sry for the late answer, was not at home after my post anymore.

    Once upon a time I was trying to do that. It was even somewhere in the branch (now deleted). But it is hard without inventing your own allocator on stack to represent tree-like nested structures (usually done with references). I could imagine it can be done, especially with the modern .NET and probably with data-oriented data structures, indexes as pointers, etc.

    I share same belive!

    Regarding the short-lived expressions I think it is a good inception for doing that.
    Oh yea :D

    Another No for this approach (at least for now) is to have API surface compatibility with the System.Linq.Expressions. I immediately broke this rule when trying it out in the branch.

    For your interesst; I do know actually a way, to bring .NET objects from Heap to Stack, it involves some dirty ClR hacking but its not toooooo bad, actually. give me time til weekend cause I have to finish a project and then I will slowly begin my journey on this topic for your Library!

  3. dadhi commented on Jul 24, 2022

    @dadhi
    Owner

    Converting to discussion.

  4. Repository owner locked and limited conversation to collaborators on Jul 24, 2022
  5. converted this issue into a discussion #342 on Jul 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions