gitlab-org--gitlab-foss/app/helpers
Stan Hu b02458ef52 Fix slow performance with compiling HAML templates
In Rails 5, including `ActionView::Context` can have a significant and
hidden performance penalty because this module also includes
`ActionView::CompiledTemplates`. This means that any module that
includes ActionView::Context becomes a descendant of
`CompiledTemplates`.

When a partial is rendered for the first time, it runs
`ActionView::CompiledTemplates#module_eval`, which will evaluate a
string that defines a new method for that partial. For example, the
source of partial might be this string:

```
def _app_views_project_show_html_haml___12345(local_assigns, output)
  "hello world"
end
```

When this string is evaluated, the Ruby interpreter will define the
method and clear the global method cache for all descendants of
`ActionView::CompiledTemplates`. Previous to this change, we
inadvertently made a number of modules fall into this category:

* GroupChildEntity
* NoteUserEntity
* Notify
* MergeRequestUserEntity
* AnalyticsCommitEntity
* CommitEntity
* UserEntity
* Kaminari::Helpers::Paginator
* CurrentUserEntity
* ActionView::Base
* ActionDispatch::DebugExceptions::DebugView
* MarkupHelper
* MergeRequestPresenter

After this change:

* Kaminari::Helpers::Paginator
* ActionView::Base
* ActionDispatch::DebugExceptions::DebugView

Each time a partial is rendered for the first time, all methods for
those modules will have to be redefined. This can exact a significant
performance penalty.

How bad is this penalty? Using the following benchmark script, we can
use DTrace to sample the Ruby interpreter:

```
Benchmark.bm do |x|
  x.report do
    1000.times do
      ActionView::CompiledTemplates.module_eval("def testme\nend")
    end
  end
end
```

This revealed a 11x jump in the time spent in `core#define_method`
alone.

Rails 6 fixes this behavior by moving the `include CompiledTemplates`
into ActionView::Base so that including `ActionView::Context` doesn't
quietly affect other modules in this way.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/11198
2019-04-29 05:33:50 -07:00
..
projects List Sentry Errors in GitLab - Frontend 2019-01-11 22:52:26 +00:00
accounts_helper.rb
active_sessions_helper.rb
appearances_helper.rb Show header and footer system messages in email 2019-02-27 22:07:50 +02:00
application_helper.rb Port EE System Header And Footer feature to CE 2019-02-21 17:55:51 +02:00
application_settings_helper.rb Move Contribution Analytics related spec in spec/features/groups/group_page_with_external_authorization_service_spec to EE 2019-04-09 15:38:58 +00:00
auth_helper.rb Move out link\unlink ability checks to a policy 2019-03-19 15:38:16 +03:00
auto_devops_helper.rb Enable/disable Auto DevOps at Group level 2019-03-12 10:15:33 +00:00
avatars_helper.rb
award_emoji_helper.rb
blame_helper.rb
blob_helper.rb Externalize strings in helpers 2019-04-04 17:05:25 +00:00
boards_helper.rb [CE] Support multiple assignees for merge requests 2019-04-08 18:40:00 -03:00
branches_helper.rb
breadcrumbs_helper.rb
broadcast_messages_helper.rb Add auto direction to support rtl languages 2019-04-25 11:40:34 +00:00
builds_helper.rb Externalize strings in helpers 2019-04-04 17:05:25 +00:00
button_helper.rb Externalize strings in helpers 2019-04-04 17:05:25 +00:00
calendar_helper.rb
ci_status_helper.rb Rename CI related selectors 2019-04-16 12:57:07 +03:00
ci_variables_helper.rb Add control for variable value masking 2019-03-29 12:49:59 -06:00
clusters_helper.rb Correct path to cluster health partial 2019-04-10 12:19:58 +00:00
commits_helper.rb Another Static Linting Fix 2019-01-05 00:42:18 +01:00
compare_helper.rb
components_helper.rb
conversational_development_index_helper.rb
cookies_helper.rb
count_helper.rb Merge branch 'fix-misspellings-app-comments' into 'master' 2019-02-26 12:25:01 +01:00
dashboard_helper.rb
defer_script_tag_helper.rb
deploy_tokens_helper.rb
diff_helper.rb Fixing image lfs bug and also displaying text lfs 2018-12-27 16:51:07 +01:00
dropdowns_helper.rb
emails_helper.rb Show header and footer system messages in email 2019-02-27 22:07:50 +02:00
emoji_helper.rb
environment_helper.rb
environments_helper.rb Move permission check of manual actions of deployments 2019-02-08 12:53:35 +00:00
events_helper.rb
explore_helper.rb
favicon_helper.rb
form_helper.rb [CE] Support multiple assignees for merge requests 2019-04-08 18:40:00 -03:00
git_helper.rb
gitlab_routing_helper.rb
graph_helper.rb
groups_helper.rb Fix group transfer selection possibilities 2019-04-02 06:49:11 +00:00
hooks_helper.rb
icons_helper.rb
ide_helper.rb
import_helper.rb Improve the GitHub and Gitea import feature table interface 2019-02-13 00:17:52 +00:00
instance_configuration_helper.rb
issuables_helper.rb [CE] Support multiple assignees for merge requests 2019-04-08 18:40:00 -03:00
issues_helper.rb
javascript_helper.rb
kerberos_spnego_helper.rb
labels_helper.rb Merge branch '10504-single-codebase-ce' into 'master' 2019-04-24 11:48:46 +00:00
lazy_image_tag_helper.rb
markup_helper.rb Fix slow performance with compiling HAML templates 2019-04-29 05:33:50 -07:00
mattermost_helper.rb
members_helper.rb Add subresources removal to member destroy service 2019-01-31 16:52:50 +01:00
merge_requests_helper.rb Adds the Rubocop ReturnNil cop 2019-03-06 17:51:56 +02:00
milestones_helper.rb Externalize strings detected by rubocop-i18n 2019-04-15 12:25:48 +00:00
milestones_routing_helper.rb
mirror_helper.rb
namespaces_helper.rb Add part of needed code 2019-04-05 18:49:46 +00:00
nav_helper.rb
notes_helper.rb Adds the Rubocop ReturnNil cop 2019-03-06 17:51:56 +02:00
notifications_helper.rb Improvements to Project overview UI 2019-04-19 13:02:35 +00:00
numbers_helper.rb
page_layout_helper.rb
pagination_helper.rb
performance_bar_helper.rb
pipeline_schedules_helper.rb
preferences_helper.rb Add Saturday to first day of the week 2019-03-04 07:52:15 +03:30
profiles_helper.rb Resolve "Empty states for profile page" 2019-02-06 09:11:39 +00:00
projects_helper.rb Revert "Revert "Merge branch '24704-download-repository-path' into 'master'"" 2019-04-16 15:16:23 +01:00
repository_languages_helper.rb
rss_helper.rb
runners_helper.rb Take contacted_at value from the DB when it is about to be displayed in the Web interface with sorting enabled. 2019-01-04 13:24:42 +07:00
safe_params_helper.rb
search_helper.rb Externalize strings in helpers 2019-04-04 17:05:25 +00:00
selects_helper.rb
services_helper.rb
sidekiq_helper.rb
snippets_helper.rb Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq 2019-01-01 22:52:05 +01:00
sorting_helper.rb Add last activity to user administration 2019-02-05 17:56:51 +02:00
storage_helper.rb
submodule_helper.rb
system_note_helper.rb
tab_helper.rb
tags_helper.rb
time_helper.rb
todos_helper.rb
tree_helper.rb Externalize strings in helpers 2019-04-04 17:05:25 +00:00
triggers_helper.rb
user_callouts_helper.rb Prep backend for /billings gold trial callouts 2019-03-01 21:25:38 +00:00
users_helper.rb Add last activity to user administration 2019-02-05 17:56:51 +02:00
version_check_helper.rb
visibility_level_helper.rb Externalize strings in helpers 2019-04-04 17:05:25 +00:00
webpack_helper.rb
wiki_helper.rb Allow to sort wiki pages by date and title 2019-04-04 16:28:56 +00:00
workhorse_helper.rb Download a folder from repository 2019-04-02 22:07:16 +08:00