Skip to content

toARec doesn't inline properly #153

Description

@Philonous

At the moment toARec is much slower than just using the Rec constructors, IMO that performance penalty is largely unnecessary.

The way toARec works is this pipeline:

Rec f us 
=go=> [Any] 
=listArray=> Array Int Any
=ARec=> ARec f us

There's two problems with this:

  • because go is recursive, it can't be inlined, even though the length of the list is statically known
  • The intermediate list isn't eliminated

As an example, I benchmarked this code:

mkToARec :: Int -> ARec ElField Fields
mkToARec i= toARec (Field i :& Field i :& Field i :& Field i :&
                  Field i :& Field i :& Field i :& Field i :&
                  Field i :& Field i :& Field i :& Field i :&
                  Field i :& Field i :& Field i :& Field 99 :&
                  RNil)

Here's the relevant part of the core:
https://gist.github.com/Philonous/135480d9016a9b51568a1495dacdf63f

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions