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

Use tail-call function-barrier in foldl for array #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tkf
Copy link
Member

@tkf tkf commented Aug 18, 2019

Performance of bench_missing_argmax.jl can be improved by using tail-call function-barrier.

However, it breaks inference of foldl(right, TeeZip(Filter(isodd) |> Map(inc)), xs): https://travis-ci.com/tkf/Transducers.jl/jobs/226136474#L321

This patch probably is not a good idea since TeeZip is pretty important.

Running bench_missing_argmax.jl

runv(cmd) = (println('$', " ", cmd); run(cmd); println())
runv(`git rev-parse HEAD`)
runv(`git rev-parse --abbrev-ref HEAD`)
runv(`git status --short`)

using BenchmarkTools
results = run(include(joinpath(pwd(), "benchmark/bench_missing_argmax.jl")))
show(IOContext(stdout, :compact => false), results)
println()
println("xf vs man")
display(judge(minimum.((results["xf"], results["man"]))...))
println("rf vs man")
display(judge(minimum.((results["rf"], results["man"]))...))

master

f87867e

$ `git rev-parse HEAD`
f87867ef9d15abdfb5a10e4ea6c5f34fd21f610b

$ `git rev-parse --abbrev-ref HEAD`
master

$ `git status --short`

┌ Warning: `Initializer(T -> ...)` is deprecated.  Please use `OnInit(() -> ...)`.
│   caller = argext_init at bench_missing_argmax.jl:28 [inlined]
└ @ Core ~/.julia/dev/Transducers/benchmark/bench_missing_argmax.jl:28
┌ Warning: `Initializer(T -> ...)` is deprecated.  Please use `OnInit(() -> ...)`.
│   caller = argext_init(::Function) at bench_missing_argmax.jl:28
└ @ Main.BenchMissingArgmax ~/.julia/dev/Transducers/benchmark/bench_missing_argmax.jl:28
3-element BenchmarkTools.BenchmarkGroup:
  tags: []
  "xf" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     1.156 μs (0.00% GC)
          median time:      1.289 μs (0.00% GC)
          mean time:        4.194 μs (0.00% GC)
          maximum time:     28.787 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
  "rf" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     1.160 μs (0.00% GC)
          median time:      1.303 μs (0.00% GC)
          mean time:        4.756 μs (10.70% GC)
          maximum time:     28.718 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
  "man" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     1.012 μs (0.00% GC)
          median time:      1.130 μs (0.00% GC)
          mean time:        2.021 μs (0.00% GC)
          maximum time:     8.435 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
xf vs man
BenchmarkTools.TrialJudgement:
  time:   +14.23% => regression (5.00% tolerance)
  memory: +0.00% => invariant (1.00% tolerance)
rf vs man
BenchmarkTools.TrialJudgement:
  time:   +14.62% => regression (5.00% tolerance)
  memory: +0.00% => invariant (1.00% tolerance)

noouttype (#31)

36f8211

+ git checkout noouttype
Switched to branch 'noouttype'
Your branch is up to date with 'origin/noouttype'.
+ julia-dev --startup-file=no --color=yes /home/takafumi/junk/2019/08/18-094411.run-bench_missing_argmax.jl
$ `git rev-parse HEAD`
36f82116729b958a56b3e6828051514a1ee8f4a8

$ `git rev-parse --abbrev-ref HEAD`
noouttype

$ `git status --short`

3-element BenchmarkTools.BenchmarkGroup:
  tags: []
  "xf" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     2.125 μs (0.00% GC)
          median time:      2.529 μs (0.00% GC)
          mean time:        8.633 μs (0.00% GC)
          maximum time:     60.267 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
  "rf" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     2.268 μs (0.00% GC)
          median time:      2.633 μs (0.00% GC)
          mean time:        8.413 μs (5.80% GC)
          maximum time:     51.188 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
  "man" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     1.042 μs (0.00% GC)
          median time:      1.355 μs (0.00% GC)
          mean time:        3.090 μs (19.96% GC)
          maximum time:     9.498 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
xf vs man
BenchmarkTools.TrialJudgement:
  time:   +103.93% => regression (5.00% tolerance)
  memory: +0.00% => invariant (1.00% tolerance)
rf vs man
BenchmarkTools.TrialJudgement:
  time:   +117.66% => regression (5.00% tolerance)
  memory: +0.00% => invariant (1.00% tolerance)

tail-call-function-barrier (this PR)

40a9f5c

$ `git rev-parse HEAD`
40a9f5c1c2cf60d36bbeaaa725f432ce80e84e04

$ `git rev-parse --abbrev-ref HEAD`
tail-call-function-barrier

$ `git status --short`

3-element BenchmarkTools.BenchmarkGroup:
  tags: []
  "xf" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     1.220 μs (0.00% GC)
          median time:      1.362 μs (0.00% GC)
          mean time:        6.334 μs (0.00% GC)
          maximum time:     49.570 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
  "rf" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     1.222 μs (0.00% GC)
          median time:      1.445 μs (0.00% GC)
          mean time:        7.110 μs (0.00% GC)
          maximum time:     56.443 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
  "man" => BenchmarkTools.Trial:
          memory estimate:  32 bytes
          allocs estimate:  1
          --------------
          minimum time:     1.004 μs (0.00% GC)
          median time:      1.105 μs (0.00% GC)
          mean time:        1.986 μs (0.00% GC)
          maximum time:     8.331 ms (0.00% GC)
          --------------
          samples:          10000
          evals/sample:     1
xf vs man
BenchmarkTools.TrialJudgement:
  time:   +21.51% => regression (5.00% tolerance)
  memory: +0.00% => invariant (1.00% tolerance)
rf vs man
BenchmarkTools.TrialJudgement:
  time:   +21.71% => regression (5.00% tolerance)
  memory: +0.00% => invariant (1.00% tolerance)

@tkf tkf force-pushed the tail-call-function-barrier branch from 40a9f5c to bdc921c Compare August 19, 2019 20:12
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.

1 participant