Skip to content

Conversation

@tkf
Copy link
Member

@tkf tkf commented Aug 10, 2020

The following snippets shows a big jump in the compilation latency after eb430cf (#403):

using DataFrames
using Glob
using Pkg: TOML
using Transducers

function asnamedtuple(d)
    kvs = [(Symbol(k) => v) for (k, v) in pairs(d)]
    sort!(kvs; by = first)
    return (; kvs...)
end

demo(depot_path = DEPOT_PATH) =
    depot_path |>
    MapCat() do path
        readdir(glob"registries/*/*/*/Package.toml", path)
    end |>
    Map() do path
        p = TOML.parsefile(path)
        get!(p, "subdir", nothing)
        p["datadir"] = dirname(path)
        depsfile = joinpath(p["datadir"], "Deps.toml")
        if !isfile(depsfile)
            p["deps"] = nothing
            return p
        end
        p["deps"] =
            values(TOML.parsefile(depsfile)) |>
            MapCat(pairs) |>
            MapSplat(tuple) |>
            Map(NamedTuple{(:name, :uuid)}) |>
            Set
        p
    end |>
    Map(asnamedtuple) |>
    x -> copy(DataFrame, x)

@time demo()
Transducers.jl commit w/ Julia 1.6.0-DEV.536 w/ Julia 1.5 w/ Julia 1.4
65db24b (pre #403) 4.6 sec 3.6 sec 5.0 sec
eb430cf (#403) 17 sec 77 sec 24 sec
29d65cb (This PR) 8.7 sec 27 sec 11 sec

Commit Message

Improve compilation latency for non-inferable case (#412)

The tail-call pattern introduced in eb430cf
(#403) for linear indexing arrays seem to invoke a large compiler
latency (see #412 for an example). This patch tries to mitigate the
problem by introducing a different more dynamic code path for
__foldl__ on arrays when the reducing function is not inferrable.

@codecov
Copy link

codecov bot commented Aug 10, 2020

Codecov Report

Merging #412 into master will increase coverage by 1.22%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #412      +/-   ##
==========================================
+ Coverage   89.52%   90.75%   +1.22%     
==========================================
  Files          25       25              
  Lines        1585     1600      +15     
==========================================
+ Hits         1419     1452      +33     
+ Misses        166      148      -18     
Flag Coverage Δ
#unittests 90.75% <75.00%> (+1.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/basics.jl 90.00% <50.00%> (+8.42%) ⬆️
src/processes.jl 92.68% <83.33%> (-0.36%) ⬇️
src/library.jl 93.15% <0.00%> (-0.28%) ⬇️
src/show.jl 89.51% <0.00%> (+0.07%) ⬆️
src/unordered.jl 96.61% <0.00%> (+0.31%) ⬆️
src/progress.jl 89.79% <0.00%> (+1.02%) ⬆️
src/core.jl 85.56% <0.00%> (+1.06%) ⬆️
src/groupby.jl 82.14% <0.00%> (+5.77%) ⬆️
src/reduce.jl 84.55% <0.00%> (+9.14%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f67507...29d65cb. Read the comment docs.

mergify bot pushed a commit that referenced this pull request Aug 10, 2020
The tail-call pattern introduced in eb430cf
(#403) for linear indexing arrays seem to invoke a large compiler
latency (see #412 for an example). This patch tries to mitigate the
problem by reducing the `FOLDL_RECURSION_LIMIT` to 1.  This still
allows *two* recursive calls.  All the benchmarks do not show
noticeable degradation (presumably because recursion deeper than this
is not exercised in the benchmarks).  Note that setting it to 0 (one
recursive call) shows 2x slowdown in `["teerf_filter", "noinit"]`
benchmark.
@tkf tkf closed this Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants