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

Add warning when protocols are not consolidated #231

Merged
merged 1 commit into from
Jul 15, 2018
Merged

Add warning when protocols are not consolidated #231

merged 1 commit into from
Jul 15, 2018

Conversation

devonestes
Copy link
Collaborator

This adds a warning when folks try to run benchmarks in environments
without protocol consolidation enabled.

I have no idea how to test this since you can't turn protocol
consolidation off at runtime, though. I did test this locally, and this
is the output I got:

~/sandbox/benchee   Issue-68±  mix run samples/run.exs
Not all of your protocols have been consolidated. In order to achieve the
best possible accuracy for benchmarks, please ensure protocol
consolidation is enabled in your benchmarking environment.

Operating System: macOS"
CPU Information: Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz
Number of Available Cores: 4
Available memory: 8 GB
Elixir 1.6.4
Erlang 20.3

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
parallel: 1
inputs: none specified
Estimated total run time: 28 s


Benchmarking flat_map...
Benchmarking map.flatten...

Name                  ips        average  deviation         median         99th %
flat_map           1.31 K        0.76 ms    ±18.34%        0.73 ms        1.59 ms
map.flatten        0.68 K        1.47 ms    ±31.06%        1.27 ms        3.02 ms

Comparison:
flat_map           1.31 K
map.flatten        0.68 K - 1.92x slower

Memory usage statistics:

Name           Memory usage
flat_map          625.54 KB
map.flatten       781.85 KB - 1.25x memory usage

**All measurements for memory usage were the same**

Resolves #68

Copy link
Member

@PragTob PragTob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a bunch! 👍

Like to have it in System :)

path = :code.lib_dir(:elixir, :ebin)

[path]
|> Protocol.extract_protocols()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how this works :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It takes a list of paths to directories full of BEAM files and tells you which protocols have been defined in those directories. It nicely returns the list of atoms corresponding to the protocol name. Very helpful when combined with :code.lib_dir/2 to get the top level directory for the Elixir BEAM files. I used this as a proxy since if those aren't consolidated, then there's no way any of your other protocols are consolidated. In theory it's still possible for a protocol to have been defined and not consolidated, but that would emit a warning (like if you're defining a protocol in a test body or something).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah that's what I wondered about - I thought this just caught it from elixir itself and not deps/libraries - but you're right, if I understand correctly it should usually be all or nothing in terms of consolidation if I understand it.

Not all of your protocols have been consolidated. In order to achieve the
best possible accuracy for benchmarks, please ensure protocol
consolidation is enabled in your benchmarking environment.
""")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd extract this into its own method, maybe just the puts maybe the whole thing. Takes up so much space that makes it seem like a more important piece then it actually is right now.

Maybe a method like warn_about_performance_degrading_settings or something? not sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me!

This adds a warning when folks try to run benchmarks in environments
without protocol consolidation enabled.

I have no idea how to test this since you can't turn protocol
consolidation off at runtime, though.
@PragTob PragTob merged commit aaf7b8b into master Jul 15, 2018
@PragTob PragTob deleted the Issue-68 branch July 15, 2018 11:29
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.

None yet

2 participants