Sha256: 6398739504a022a2c3f84c31fb73f2eb8074f6470eb0a689a8d3b1bd9f563dce

Contents?: true

Size: 1.92 KB

Versions: 13

Compression:

Stored size: 1.92 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 does not catch them all. It is currently configured in `config/initializers/bullet.rb` to log in the regular rails log and also in its own `log/bullet.log`. You will 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 is 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 will 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

13 entries across 13 versions & 1 rubygems

Version Path
decidim-0.29.1 docs/modules/develop/pages/profiling.adoc
decidim-0.28.4 docs/modules/develop/pages/profiling.adoc
decidim-0.29.0 docs/modules/develop/pages/profiling.adoc
decidim-0.28.3 docs/modules/develop/pages/profiling.adoc
decidim-0.29.0.rc4 docs/modules/develop/pages/profiling.adoc
decidim-0.29.0.rc3 docs/modules/develop/pages/profiling.adoc
decidim-0.29.0.rc2 docs/modules/develop/pages/profiling.adoc
decidim-0.29.0.rc1 docs/modules/develop/pages/profiling.adoc
decidim-0.28.2 docs/modules/develop/pages/profiling.adoc
decidim-0.28.1 docs/modules/develop/pages/profiling.adoc
decidim-0.28.0 docs/modules/develop/pages/profiling.adoc
decidim-0.28.0.rc5 docs/modules/develop/pages/profiling.adoc
decidim-0.28.0.rc4 docs/modules/develop/pages/profiling.adoc