After testing a dry-web-roda app with the gem
derailed_benchmarks I found that my app was using more memory than a bigger Rails app.
Actually, this is the first part of the output:
$ bundle exec derailed bundle:mem TOP: 42.4297 MiB dry-web: 13.6484 MiB dry/web/container: 13.6484 MiB dry/monitor: 13.4023 MiB dry/monitor/sql/logger: 12.9414 MiB rouge: 12.9414 MiB
That means, that the app is using 42 MiB, and the
dry-web component is the biggest one, that is using 13.6 MiB, because of
rouge (12.9 MiB).
So, requiring only the needed components of
rouge, by changing in
lib/dry/monitor/sql/logger.rb the line 2:
require 'rouge/util' require 'rouge/token' require 'rouge/theme' require 'rouge/themes/gruvbox' require 'rouge/formatter' require 'rouge/formatters/terminal256' require 'rouge/lexer' require 'rouge/regex_lexer' require 'rouge/lexers/sql'
We can get an improvement. The mem test after that returns:
$ bundle exec derailed bundle:mem TOP: 26.1211 MiB rom: 8.0352 MiB ... dry-web: 1.1211 MiB dry/web/container: 1.1211 MiB dry/monitor: 0.75 MiB dry/monitor/sql/logger: 0.5 MiB
So, the memory used by dry-monitor was reduced from 13.4 MiB to 0.75 Mib. And the impact on the memory usage of a small dry-web-roda app was bigger than that: from 42.4297 MiB to 26.1211 MiB.
I did not analyze how
derailed_benchmarks make its maths. But it’s clear that
rouge has a lot of cool components that are not used by
dry-monitor. Then, Why do not get rid of it?
Please, let me know what you think about this. Thank you.