/plushcap/analysis/datadog/datadog-php-exception-profiling

Why care about exception profiling in PHP?

What's this blog post about?

The article discusses the implementation of exception profiling in PHP and its benefits. It highlights how exceptions are used for flow control in hot code paths, leading to hidden costs. The author shares an example where a service was throwing 495,000 exceptions per 14.2 seconds, consuming 23.05% of the total CPU time. This excessive use of exceptions can lead to performance issues and put pressure on memory management systems. The article also explains how exception profiling can surface hidden problems in customer production systems. It demonstrates this with an example where a library used for comparing scalar values in an array_filter() callback throws exceptions when the values differ, leading to unnecessary overhead. The author suggests cleaning up exceptions that do not result in performance issues and removing extraneous exceptions during or after active incidents. The article concludes by explaining how exception profiling was added to dd-trace-php and its benefits for troubleshooting. It also mentions that the Datadog exception profiler collects both caught and uncaught exceptions, unlike many other products.

Company
Datadog

Date published
July 24, 2024

Author(s)
Florian Engelhardt

Word count
1166

Hacker News points
None found.

Language
English


By Matt Makai. 2021-2024.