kseg
Plenty of guides that show how to profile a specific function, but I can’t figure out how to profile an application (run with --no-halt, if that chances anything). Any pointers?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
aseigo
What are you trying to measure? What are you hoping to be able to identify?
There are so many potential things “profile an application” can mean, and even more possible reasons to do those things .. so it is a bit hard (at least for me ..) to answer this usefully without understanding a bit more about what you need to accomplish …
svilen
If you have a Phoenix web app, using something like AppSignal (or Scout) could be a good starting point. I’m personally using AppSignal and if you follow the basic setup, you get data on DB queries, Phoenix Controllers and Views out of the box.
kseg
I’m looking to profile both cpu and memory. The exact details vary based on the tools. I see tools like ExProf which seem to do what I want (for CPU anyways), but all the examples seem to be testing a single function. It might be trivial, but I’m not sure what that function to wrap the profile macro around for an app. From what I can tell, an application’s exposed entry point is the start function, but that exits as soon as the app is started.
For example, if this was Go, I’d stick:
At the start of my application, and I’d get a useful profile file. Doing memory would be equally simple.
FWIW, I think “profiling an elixir app” is pretty specific. If you google “profiling a go app” or “profiling a java app” the top hits are germane and helpful. I’m not trying to split hair, I appreciate the help, but, so far ,to me, this seems like an area where either the tooling is lacking or the documentation. “The Road to 2 Million Websocket Connections in Phoenix” illustrated this well, it explains the steps that were taken to improve things (like converting a bag to a duplicate_bag), but not how those steps were identified as an bottleneck.
aseigo
I think there’s also a bit of a culture difference: if you instead search for “elixir metrics” you’ll find quite a number of resources for this. “elixir profiling” not nearly as much. This probably reflects some aspects of the culture around, and cultural heritage that have gone into, Elixir. Aaaanyways …
Here’s a decent tool that looks like it may provide what you are after: Exometer, an Elixir wrapper for it (which I haven’t yet tried myself … so ymmv?), and there are a good number of blog entries out there that talk about these tools as used from Elixir.
There are several other instrumentation-based libraries for gathering and tracking metrics for Elixir out there. That includes a couple of 3rd party services which will host the resulting data and who have nice native Elixir libs. But there are also fully self-hosted solutions that a “elixir metrics” on google will discover
Some random thoughts circling my head about the whole “profiling has a common meaning in other languages / environments”: … wearing my C/C++ (or most other languages I use) hat, yeah I would agree with that. “Profiling” has a fairly static meaning in those contexts.
Elixir’s, or rather the BEAM’s, inherent preemptive code execution (aka processes) and async message passing make a number of traditional profiling techniques and ideas (like “watch how much CPU my app uses pls”) not as clear cut. e.g. in most other platforms I’ve worked with the idea of “hey, can you tell me how many concurrent code paths there are?” is relatively exotic; even in heavily multi-threaded applications I’ve written in C++, I haven’t experienced anywhere near the usual level of dynamic behavior that a typical Elixir application ends up exhibiting which makes tracking / counting / monitoring processes “a thing” that is actually interesting. The preemption can also have interesting effects in more basic measurement techniques in real-world environs, though that can be controlled for in testing environs, but then that lends itself to synthetic micro-benchmarking .. which can be useful, but not always what is needed to demonstrate shipability as artifacts like message bottlenecks will only show up under load.
kseg
Think I figured it out.
Right at the top of my application’s
startfunction, I added:the
procs: allmakes it profile all processes. I stop the trace after 10 second. This generated a 1.5GBfprof.tracefile (so, beware!) The calls to profile/analyze generates a very verboseprof.analysisfile (37MB). This file can be explored, but it’s noisy.I used GitHub - isacssouza/erlgrind: Convert fprof to callgring output · GitHub to convert the file to a callgrind format which then lets you use those sets of tools (like http://kcachegrind.sourceforge.net/html/Home.html).
aseigo
Yep, fprof is quite comprehensive; ships with Erlang, so is quit well supported (and been around the block a few times) but .. as you found .. it produces some pretty gnarly output. I wasn’t actually aware of erlgrind, though, that’s awesome
Definitely will have to use that next time …
p.s. kcachegrind ftw.. have used and loved that app for .. gosh .. i don’t know how many years now.