Sha256: dc0964fd58a14fbcc65d145f4fc061c0352b0b4f772f4b01e4adf1efa10edefb

Contents?: true

Size: 1.91 KB

Versions: 36

Compression:

Stored size: 1.91 KB

Contents

= How to profile a Decidim app

The development_app includes a bunch of gems that profile the application. Run the following command in the decidim root's folder:

[source,bash]
----
bundle exec rake development_app
----

and then move into it and boot the server

[source,bash]
----
cd development_app
bundle exec rails s
----

== Bullet

Bullet detects N+1 queries and suggests how to fix them, although it doesn't catch them all. It's currently configured in `config/initializers/bullet.rb` to log in the regular rails log and also in its own `log/bullet.log`. You'll now see entries like the following:

[source,bash]
----
user: xxx
GET /
USE eager loading detected
  Decidim::Comments::Comment => [:author]
  Add to your query: .includes([:author])
Call stack
----

It also warns you when there's an unnecessary eager load.

More details: https://github.com/flyerhzm/bullet

== Rack-mini-profiler

This gem can analyze memory, database, and call stack with flamegraphs. It will show up in development on the top left corner and it gives you all sorts of profiling insights about that page. It'll tell you where the response time was spend on in the call stack.

This gem is further enhanced with the `flamegraph`, `stackprof` and `memory_profiler` gems which provide more detailed analysis. Try out by appending `?pp=flamegraph`, `?pp=profile-gc` or `?pp=analyze-memory` to the URL. You can read more about these options at https://github.com/MiniProfiler/rack-mini-profiler#flamegraphs.

More details: https://github.com/MiniProfiler/rack-mini-profiler

== Profiling best practices

You need to take the insights of these gems with a grain of salt though, if you run this in development. Rails' development settings have nothing to do with a production set up where classes are not reloaded and assets are precompiled and served from a web server. Therefore, you should mimic these settings as much as possible if you want your findings to be realistic.

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
decidim-0.27.9 docs/modules/develop/pages/profiling.adoc
decidim-0.27.8 docs/modules/develop/pages/profiling.adoc
decidim-0.27.7 docs/modules/develop/pages/profiling.adoc
decidim-0.27.6 docs/modules/develop/pages/profiling.adoc
decidim-0.26.10 docs/modules/develop/pages/profiling.adoc
decidim-0.26.9 docs/modules/develop/pages/profiling.adoc
decidim-0.27.5 docs/modules/develop/pages/profiling.adoc
decidim-0.26.8 docs/modules/develop/pages/profiling.adoc
decidim-0.27.4 docs/modules/develop/pages/profiling.adoc
decidim-0.27.3 docs/modules/develop/pages/profiling.adoc
decidim-0.26.7 docs/modules/develop/pages/profiling.adoc
decidim-0.26.5 docs/modules/develop/pages/profiling.adoc
decidim-0.27.2 docs/modules/develop/pages/profiling.adoc
decidim-0.27.1 docs/modules/develop/pages/profiling.adoc
decidim-0.26.4 docs/modules/develop/pages/profiling.adoc
decidim-0.27.0 docs/modules/develop/pages/profiling.adoc
decidim-0.26.3 docs/modules/develop/pages/profiling.adoc
decidim-0.27.0.rc2 docs/modules/develop/pages/profiling.adoc
decidim-0.27.0.rc1 docs/modules/develop/pages/profiling.adoc
decidim-0.26.2 docs/modules/develop/pages/profiling.adoc