jeramyRR
Why does elixir purge logging statements at compile time? I know you have to indicate what level you’d like to purge in the config, but doesn’t this take away the ability to temporarily increase logging in production if something goes wrong?
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
The obligatory hello world thread!
Who are you and where are you from? :stuck_out_tongue:
New
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project.
My initial shotgu...
New
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
Is there a word for the ~> symbol used in Version strings?
Do you also just call it a Squiggle Arrow™ ?!
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
NobbZ
Well, calls to logger cost you some cycles.
"#{inspect foo}"everywhere, so that has to be done, regardless if it will be logged or not.if level <= wanted_levelwhich need to be doneAll this costs your process valuable reductions, which it can’t spend with its primary task.
Therefore unpurged but filtered logger calls are a bad thing.
But you are right. Usually I do only purge
debug, and keep the rest while only actively logging:warnand:error.jeramyRR
This seems like a serious oversight in the VM design if it can’t handle logging without stripping calls from the bytecode first.
NobbZ
Sorry, but I do not understand this statement.
If it were stripping things, you weren’t able to get them back at runtime, and then we are back at compile time purging.
aseigo
It can, and does so just fine. However, when doing the filtering at runtime instead of compiletime, there is some expense still spent in log message that are never shown. So if you want every last bit of performance, you can strip out the debug levels you really don’t want (e.g. debug in production builds).
If you have stripped them, and you want them back in a running system, you can always build an upgrade release and hot-load it to get your debug statements back.
Logger does do as much as it can to help even when not stripped at compile time, though. If you are not showing debug statements, then the Logger.debug macro does not evaluate the parameters (e.g. strings with interpolations) …
aseigo
Are you sure about that? From the docs;
NobbZ
At least it was like I’ve described it in earlier versions. As far as I remember there has even been the advise to wrap expensive to calculate arguments into an anonymous function, to make it “lazy”. Perhaps I missed the lazy by default change?
aseigo
That is still true for
Logger.bare_log/3, as noted in the docs, but not the case anymore for the other macros.jeramyRR
Is this something that could be circumvented by implementing a Logger in Rust and calling it through Elixir if Elixirs native logging performance became inhibitive, or would the call down to native be just as expensive?
aseigo
Cycles are cycles. And when you have a million connections being handled by your application, those cycles add up. I’ve seen the same thing with C/C++ code bases, including ones where methods that were slow were improved by conditionally compiling out logging output that was disabled at runtime with configuration.
The fact that you can reclaim those cycles by compiling the calls right out does not equal “calls to Logger are horribly slow”. I honestly don’t know how slow they are (I don’t have numbers on that), but you could always take Benchee and wrap it around a large number of Logger calls which do not hit the backend and find out.
As for the cost of native calls: they are quite cheap: Latency of Native Functions for Erlang and Elixir · potatosalad
sneako
I’m pretty sure that was a new feature of 1.7. if you look at the docs for 1.6 here Logger – Logger v1.6.0, you’ll find: " The Logger macros also accept messages as strings, but keep in mind that strings are always evaluated regardless of log-level. As such, it is recommended to use a function whenever the message is expensive to compute." As stated by @NobbZ