dominicletz

dominicletz

Creator of Elixir Desktop

Profiler - Sampling Profiler for Shell Debugging

Hi there,

this is a tool I’ve been using myself quite a bit recently for online debugging and performance analysis. It’s a simple remote shell Sampling Profiler module.

Here you can get it:


https://hexdocs.pm/profiler/Profiler.html

It’s focused on shell usage so all commands print to stdout. Usage is simple after including it in your project. E.g. here it’s used to profiler the Elixir compiler and shows use how much time is % spend in function calls:

iex(diode@leno)3> pid = spawn(fn() -> for _ <- 1..100000, do: Elixir.Code.compile_file("lib/debounce.ex") end)
#PID<0.731.0>
iex(diode@leno)4> Profiler.profile(pid)
  96% {:erl_eval, :expr, 5, [file: 'erl_eval.erl', line: 411]}
     96% {:erl_eval, :expr_list, 6, [file: 'erl_eval.erl', line: 888]}
        96% {:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 680]}
           96% {Enum, :reduce_range_inc, 4, [file: 'lib/enum.ex', line: 3371]}
              96% {:erl_eval, :expr, 5, [file: 'erl_eval.erl', line: 232]}
                 96% {:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 680]}
                    78% {Code, :compile_file, 2, [file: 'lib/code.ex', line: 1157]}
                       74% {:elixir_compiler, :quoted, 3, [file: 'src/elixir_compiler.erl', line: 18]}
                          74% {:elixir_lexical, :run, 3, [file: 'src/elixir_lexical.erl', line: 14]}
                             74% {:elixir_compiler, :eval_forms, 3, [file: 'src/elixir_compiler.erl', line: 46]}
                                73% {:elixir, :eval_forms, 3, [file: 'src/elixir.erl', line: 263]}
                                   73% {:elixir, :recur_eval, 3, [file: 'src/elixir.erl', line: 278]}
                                      73% {:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 680]}
                                         42% {:elixir_module, :compile, 5, [file: 'src/elixir_module.erl', line: 107]}
                                            42% {:elixir_module, :eval_form, 6, [file: 'src/elixir_module.erl', line: 333]}
                                               31% {:elixir_compiler, :compile, 3, [file: 'src/elixir_compiler.erl', line: 58]}
                                                  31% {:elixir_erl_compiler, :spawn, 2, [file: 'src/elixir_erl_compiler.erl', line: 20]}
                                               10% {:elixir_compiler, :compile, 3, [file: 'src/elixir_compiler.erl', line: 60]}
                                         21% {:elixir_module, :compile, 5, [file: 'src/elixir_module.erl', line: 140]}
                                            21% {:elixir_erl_compiler, :spawn, 2, [file: 'src/elixir_erl_compiler.erl', line: 20]}
                                          7% {:elixir_module, :compile, 5, [file: 'src/elixir_module.erl', line: 142]}
                                             7% {:code_server, :call, 1, [file: 'code_server.erl', line: 139]}
                    18% {Code, :verify_loaded, 1, [file: 'lib/code.ex', line: 1394]}
                       17% {Module.ParallelChecker, :collect_results, 2, [file: 'lib/module/parallel_checker.ex', line: 31]}
:ok

By default it takes 10000 samples, one every millisecond and then analyzes the stack traces. Since the sampling is time based it’s especially useful when reduction count based profiling leads you to a red herring.

Have fun!

Where Next?

Popular in Announcing Top

danschultzer
In short Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependen...
New
ostinelli
Let’s write a database! Well not really, but I think it’s a little sad that there doesn’t seem to be a simple in-memory distributed KV da...
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
Flo0807
Hello everyone! I am excited to share our heart project Backpex with you. After building several Phoenix applications, we realized that...
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
hpopp
After just over two years in development, this latest version of Pigeon is what I finally consider done in regards to my original vision ...
New
Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Th...
New
Qqwy
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects. Core ideas Type- and function specifications are const...
336 14302 100
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
144 10140 141
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31107 143
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement