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

Debugging performance with Phoenix LiveDashboard #891

Open
ivanminutillo opened this issue Mar 2, 2024 · 5 comments
Open

Debugging performance with Phoenix LiveDashboard #891

ivanminutillo opened this issue Mar 2, 2024 · 5 comments
Labels
New Issue Please apply this label to any new issues :) Performance Work that improves the performance of bonfire

Comments

@ivanminutillo
Copy link
Contributor

ivanminutillo commented Mar 2, 2024

Following some interesting insights about potential performance issues found using LiveDashboard tools, esp. Orion and Flame on.
The functions are recorded during the loading of the Home feed

Bonfire.Common.Extend.maybe_extension_loaded!/1
Execution is pretty fast (99% under 9ms), but (If I understand the graph correctly) it is been called in a range of 160 - 260 times x second across a period of 55 secs (15:21:10 - 15:22:05)

Performance Graph:
image
Profiler:
image
zooming out :
Screenshot 2024-03-02 alle 15 41 47

My guess is that even if the time execution is very fast, the amount of time the function is called for such a consistent period of time may cause the instance to consistently slow down? Looking at the profiler graph, in first instance I tought that impressive repetition that is shown in the flame graph was caused by a recursive loop somewhere, but maybe it's just a consequence of how modular is bonfire and how modules from different extensions are linked together in a complex view such as the Feed view.

I'm not that good with the BEAM to say tough if this can likely be an issue or not? Feedback are very welcome :)

@ivanminutillo ivanminutillo added the New Issue Please apply this label to any new issues :) label Mar 2, 2024
@ivanminutillo ivanminutillo added this to the 0.9.12 - Optimisations milestone Mar 2, 2024
@ivanminutillo ivanminutillo added the Performance Work that improves the performance of bonfire label Mar 2, 2024
@mayel
Copy link
Member

mayel commented Mar 4, 2024

Just had a quick look, maybe_extension_loaded! is called whenever you do Config.get or Settings.get so the amount of times isn't necessarily alarming, though always good to double check, and probably the functions can be reduced/optimised a bit when we know how often they're used...

@ivanminutillo
Copy link
Contributor Author

yeah maybe for foundational extensions (such as ui_social / ui_reactions / boundaries / etc) we can assume they're enabled? or we can cache the list of extensions loaded? because they are not likely to change that often and they are updated only via settings so updating the cache should be trivial enough?

@mayel
Copy link
Member

mayel commented Mar 6, 2024

we can assume they're enabled

I'd not do that, would loose flexibility and the ability to swap them out

we can cache the list of extensions loaded

seems to assume that elixir/erlang is not already caching or that they're slow, which we just need to measure

@ivanminutillo
Copy link
Contributor Author

Adding the list of potential N+1 (from logs and honeycomb)

  • bonfire_data_activity_pub_peered (possibly triggered by is_local?)
  • pointers_pointer (possibly triggered by Boundaries.can?)

@mayel
Copy link
Member

mayel commented Apr 9, 2024

added some extra measuring of memory use and execution time during runtime...

mayel added a commit to bonfire-networks/bonfire_spark that referenced this issue Apr 9, 2024
mayel added a commit to bonfire-networks/bonfire_common that referenced this issue Apr 9, 2024
mayel added a commit to bonfire-networks/bonfire_ui_common that referenced this issue Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Issue Please apply this label to any new issues :) Performance Work that improves the performance of bonfire
Projects
None yet
Development

No branches or pull requests

2 participants