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

Slow compilation of extensive record types. #4478

Open
wclr opened this issue Jun 21, 2023 · 0 comments
Open

Slow compilation of extensive record types. #4478

wclr opened this issue Jun 21, 2023 · 0 comments

Comments

@wclr
Copy link
Contributor

wclr commented Jun 21, 2023

Description

While working with app's code I noticed that compilation times of some modules became significantly slower: not the biggest module in the world ~1500 lines, complied in ~5sec.

It turned out that the main reason for this was a large app's model type which is a type synonim record and functions that used that type.

I removed all signatures in the module of the app compilation times decreased twise to ~2sec. I wrapped the app's model in a newtype, and compilations times just dropped significantly.

It seems that it is not in the complex type itself, but type signatures that cause the slow down, the more signatures used the type the slower compilation times.

It probably refers to dealising process. If this issue exists with large types, it probably still contributes to compilation performance issues with less extensive types too.

To Reproduce

It is easy to reproduce, just need to emulate a large complex form with nested records.

module Slow where

type Field =
  { a01 :: Int
  , a02 :: Int
  , a02 :: Int
  -- some fields below
}


type Rec =
  { field00 :: Field
  , field01 :: Field
  , field02 :: Field
  , field03 :: Field
  , field04 :: Field
  , field05 :: Field
  -- some fields below
}

-- some functions that work with the record type
fn1 :: Rec -> Rec
fn1 model = model

-- if to remove signatures time drops
fn2 :: Rec -> Rec
fn2 model = fn1 model

Here is the gist with the sample code:
https://gist.github.com/wclr/9abb95f623322a6c92635f436697660f

If to remove signatures that use this type or replace a synonym with a newtype compilation time drops significantly.

I assume that this problem is known from practice (though I didn't see any active issues about it), want to draw some attention to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants