Skip to content

Poor performance during normalization #769

Open
@vmchale

Description

@vmchale

Running dhall on pkg-set.dhall takes quite long, around 23 seconds.

Here is the .prof file:

	Sat Dec 29 22:56 2018 Time and Allocation Profiling Report  (Final)

	   dhall-profile +RTS -h -p -RTS

	total time  =       22.54 secs   (22541 ticks @ 1000 us, 1 processor)
	total alloc = 40,573,140,648 bytes  (excludes profiling overheads)

COST CENTRE               MODULE                                             SRC                                                                         %time %alloc

renderIO                  Data.Text.Prettyprint.Doc.Render.Terminal.Internal src/Data/Text/Prettyprint/Doc/Render/Terminal/Internal.hs:(171,1)-(210,58)   22.3   14.6
normalizeWithM            Dhall.Core                                         src/Dhall/Core.hs:(1571,1)-(1952,29)                                         21.6   25.6
normalizeWith             Dhall.Core                                         src/Dhall/Core.hs:1568:1-52                                                   8.3   24.9
toList                    Dhall.Map                                          src/Dhall/Map.hs:485:1-55                                                     5.4    2.7
shift                     Dhall.Core                                         src/Dhall/Core.hs:(801,1)-(973,29)                                            5.3    5.9
denote                    Dhall.Core                                         src/Dhall/Core.hs:(1484,1)-(1550,39)                                          5.0    3.5
styleToRawText            Data.Text.Prettyprint.Doc.Render.Terminal.Internal src/Data/Text/Prettyprint/Doc/Render/Terminal/Internal.hs:(278,1)-(304,29)    4.2    3.8
unorderedTraverseWithKey_ Dhall.Map                                          src/Dhall/Map.hs:476:1-80                                                     3.6    0.5
csi                       System.Console.ANSI.Codes                          src/System/Console/ANSI/Codes.hs:75:1-75                                      3.4    5.4
prettyCharacterSet        Dhall.Pretty.Internal                              src/Dhall/Pretty/Internal.hs:(321,1)-(886,61)                                 2.7    1.1
layoutWadlerLeijen        Data.Text.Prettyprint.Doc.Internal                 src/Data/Text/Prettyprint/Doc/Internal.hs:(1693,1)-(1752,60)                  2.7    2.8
sort                      Dhall.Map                                          src/Dhall/Map.hs:(178,1)-(180,24)                                             1.9    1.2
uncons                    Dhall.Map                                          src/Dhall/Map.hs:(308,1)-(309,78)                                             1.6    0.3
changesUponFlattening     Data.Text.Prettyprint.Doc.Internal                 src/Data/Text/Prettyprint/Doc/Internal.hs:(535,1)-(573,21)                    1.3    1.1
setSGRCode                System.Console.ANSI.Codes                          src/System/Console/ANSI/Codes.hs:197:1-52                                     1.3    1.2
subst                     Dhall.Core                                         src/Dhall/Core.hs:(980,1)-(1143,29)                                           1.2    1.1

As you can see, normalizeWithM takes quite a lot of time. I am not quite sure why - I haven't inserted profiling pragmas - but the performance is not where it should be.

I suspect this is because lookups/etc. during normalization are performed using values of type Text; if identifiers were interned then the dhall library would likely have more sensible performance.

Thanks again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceAll the slow and inefficient things

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions