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

Optimize value_to_abstract/2 #6

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

Conversation

AndrewDryga
Copy link

@AndrewDryga AndrewDryga commented Aug 18, 2017

Most of value_to_abstract/2 return can be precompiled so that less :erl_syntax work is necessary to build an Erlang abstract term.

This also allowed to remove private :erl_syntax import from this module.

Results on my laptop:

Settings:
  duration:      1.0 s

## FastGlobalBench
[15:49:05] 1/10: agent get
[15:49:06] 2/10: ets get
[15:49:09] 3/10: fastglobal get
[15:49:13] 4/10: fastglobal put (10)
[15:49:17] 5/10: fastglobal put (100)
[15:49:20] 6/10: fastglobal put (5)
[15:49:22] 7/10: fastglobalalt get
[15:49:26] 8/10: fastglobalalt put (10)
[15:49:29] 9/10: fastglobalalt put (100)
[15:49:32] 10/10: fastglobalalt put (5)

Finished in 29.62 seconds

## FastGlobalBench
benchmark name           iterations   average time 
fastglobalalt get          10000000   0.33 µs/op
fastglobal get             10000000   0.37 µs/op
ets get                      200000   8.67 µs/op
agent get                    100000   13.39 µs/op
fastglobal put (5)              500   3796.09 µs/op
fastglobalalt put (5)           500   3899.89 µs/op
fastglobalalt put (10)          500   5811.88 µs/op
fastglobal put (10)             500   6597.18 µs/op
fastglobal put (100)             50   42622.08 µs/op
fastglobalalt put (100)          50   42785.70 µs/op
mix bench --duration 10
Settings:
  duration:      10.0 s

## FastGlobalBench
[16:34:12] 1/10: agent get
[16:34:26] 2/10: ets get
[16:35:13] 3/10: fastglobal get
[16:35:52] 4/10: fastglobal put (10)
[16:36:27] 5/10: fastglobal put (100)
[16:36:53] 6/10: fastglobal put (5)
[16:37:16] 7/10: fastglobalalt get
[16:37:53] 8/10: fastglobalalt put (10)
[16:38:29] 9/10: fastglobalalt put (100)
[16:38:55] 10/10: fastglobalalt put (5)

Finished in 306.32 seconds

## FastGlobalBench
benchmark name           iterations   average time 
fastglobalalt get         100000000   0.33 µs/op
fastglobal get            100000000   0.35 µs/op
ets get                     5000000   7.53 µs/op
agent get                   1000000   12.86 µs/op
fastglobalalt put (5)          5000   3821.10 µs/op
fastglobal put (5)             5000   3847.31 µs/op
fastglobalalt put (10)         5000   5760.78 µs/op
fastglobal put (10)            5000   5829.14 µs/op
fastglobal put (100)            500   41096.46 µs/op
fastglobalalt put (100)         500   42202.88 µs/op

where fastglobalalt is changed module which I've submitted in the PR.

Performance improvement is almost not noticeable, so It's up to you to decide does this PR deserves to be merged it or not :).

Most of `value_to_abstract/2` return can be precompiled so that less `:erl_syntax` work is necessary to build an Erlang abstract term. 

This also allowed to remove private `:erl_syntax` import from this module.
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