Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,868
    • Issues 4,868
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19420
Closed
Open
Created Feb 23, 2021 by vdukhovni@trac-vdukhovniDeveloper

Optimisation puzzle with list of list folds and mconcat

As observed in !4890 (comment 326560) optimisation of some list of list folds is inconsistent across superficially similar forms. Specifically:

print $ foldl' (+) 0 $ mconcat $ map (\i -> [0..i]) [0..n]

performs noticeably better (half the allocations and a just over half the runtime of:

print $ foldl' (+) 0 $ foldr (++) [] $ map (\i -> [0..i]) [0..n]

@simonpj notes differences in the rules that fired in the two cases: !4890 (comment 326990)

Some more comments on this subtopic in:

  • !4890 (comment 327155)
  • !4890 (comment 327595)
  • !4890 (comment 328669)
  • !4890 (comment 328688)

This topic is a tangent from the original concerns of !4890 (closed) and so is best explored and tracked separately.

Edited Feb 23, 2021 by vdukhovni
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking