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 efficiency of building Internal.InfoTable #2394

Open
lukaszcz opened this issue Sep 26, 2023 · 0 comments
Open

Improve efficiency of building Internal.InfoTable #2394

lukaszcz opened this issue Sep 26, 2023 · 0 comments
Assignees
Labels
Milestone

Comments

@lukaszcz
Copy link
Collaborator

The following code in Juvix.Compiler.Internal.Data.InfoTable takes ridiculously long:

letFunctionDefs :: (Data from) => from -> [FunctionDef]
letFunctionDefs e =
  concat
    [ concatMap (toList . flattenClause) _letClauses
      | Let {..} <- universeBi e
    ]
  where
    flattenClause :: LetClause -> NonEmpty FunctionDef
    flattenClause = \case
      LetFunDef f -> pure f
      LetMutualBlock (MutualBlockLet fs) -> fs

It is responsible for over 10% of compilation time.

The problem seems to be the use of generic traversal with universeBi and automatically derived instances. The documentation of uniplate mentions that one can achieve a 5x speedup by using Data.Generics.Uniplate.Direct instead of Data.Generics.Uniplate.Data and implementing the instances manually.

@lukaszcz lukaszcz added enhancement New feature or request refactor labels Sep 26, 2023
@lukaszcz lukaszcz added this to the 0.5.3 milestone Sep 26, 2023
@jonaprieto jonaprieto modified the milestones: 0.5.3, 0.5.4 Oct 31, 2023
@jonaprieto jonaprieto modified the milestones: 0.5.4, 0.5.5 Nov 17, 2023
@jonaprieto jonaprieto modified the milestones: 0.5.5, 0.5.6 Dec 1, 2023
@jonaprieto jonaprieto modified the milestones: 0.5.6, 0.6.1 Mar 9, 2024
@paulcadman paulcadman modified the milestones: 0.6.1, 0.6.2 Mar 25, 2024
@lukaszcz lukaszcz self-assigned this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants