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 a couple benchmark implementations #283

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Apr 14, 2021

on master

julia> run(BaseBenchmarks.SUITE[["shootout", "binary_trees"]])
BenchmarkTools.Trial: 
  memory estimate:  13.96 MiB
  allocs estimate:  783717
  --------------
  minimum time:     13.063 ms (0.00% GC)
  median time:      14.136 ms (0.00% GC)
  mean time:        14.747 ms (4.12% GC)
  maximum time:     27.875 ms (0.00% GC)
  --------------
  samples:          340
  evals/sample:     1

julia> run(BaseBenchmarks.SUITE[["shootout", "regex_dna"]])
BenchmarkTools.Trial: 
  memory estimate:  1.69 MiB
  allocs estimate:  211
  --------------
  minimum time:     3.762 ms (0.00% GC)
  median time:      4.582 ms (0.00% GC)
  mean time:        4.772 ms (3.45% GC)
  maximum time:     10.446 ms (52.77% GC)
  --------------
  samples:          1048
  evals/sample:     1

julia> run(BaseBenchmarks.SUITE[["problem", "json", "parse_json"]])
BenchmarkTools.Trial: 
  memory estimate:  342.91 KiB
  allocs estimate:  13741
  --------------
  minimum time:     510.597 μs (0.00% GC)
  median time:      560.140 μs (0.00% GC)
  mean time:        599.678 μs (2.75% GC)
  maximum time:     3.195 ms (81.09% GC)
  --------------
  samples:          8318
  evals/sample:     1

on PR

julia> BaseBenchmarks.run(BaseBenchmarks.SUITE[["shootout", "binary_trees"]])
BenchmarkTools.Trial: 
  memory estimate:  8.02 MiB
  allocs estimate:  262842
  --------------
  minimum time:     2.939 ms (0.00% GC)
  median time:      3.312 ms (0.00% GC)
  mean time:        3.667 ms (8.86% GC)
  maximum time:     7.807 ms (38.13% GC)
  --------------
  samples:          1364
  evals/sample:     1

julia> run(BaseBenchmarks.SUITE[["shootout", "regex_dna"]])
BenchmarkTools.Trial: 
  memory estimate:  588.95 KiB
  allocs estimate:  298
  --------------
  minimum time:     3.176 ms (0.00% GC)
  median time:      3.651 ms (0.00% GC)
  mean time:        3.776 ms (1.29% GC)
  maximum time:     28.847 ms (0.00% GC)
  --------------
  samples:          1324
  evals/sample:     1

# Additionally with https://github.com/JuliaLang/julia/pull/40484
#julia> BaseBenchmarks.run(BaseBenchmarks.SUITE[["shootout", "regex_dna"]])
#BenchmarkTools.Trial: 
#  memory estimate:  582.50 KiB
#  allocs estimate:  174
#  --------------
#  minimum time:     2.719 ms (0.00% GC)
#  median time:      3.160 ms (0.00% GC)
#  mean time:        3.268 ms (1.66% GC)
#  maximum time:     8.119 ms (60.51% GC)
#  --------------
#  samples:          1530
#  evals/sample:     1

julia> run(BaseBenchmarks.SUITE[["problem", "json", "parse_json"]])
BenchmarkTools.Trial: 
  memory estimate:  159.77 KiB
  allocs estimate:  7659
  --------------
  minimum time:     335.786 μs (0.00% GC)
  median time:      367.212 μs (0.00% GC)
  mean time:        404.287 μs (1.23% GC)
  maximum time:     151.886 ms (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     1

With no node mutation, it is unclear why this is mutable (which costs
some extra loads), though the recursion forces this to the heap
regardless. But singleton struct Empty needs to be non-mutable now for
correctness
The multi-replace method is being added in JuliaLang/julia#40484
Allocating strings with json character-by-character with ""+c+c+… is bad
style, and this was not handling \u correctly either. We could make
strcat a separate micro-benchmark, but it is not a particularly
interesting test case currently.
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