Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PROF-10112] Also simplify actionview templates with three underscores
**What does this PR do?** This PR is a small fix on top of #3759. In that PR, we added code to detect method names dynamically generated by Rails actionview templates, slicing the parts of the method name that have random ids. E.g. `_app_views_layouts_explore_html_haml__2304485752546535910_211320` became `_app_views_layouts_explore_html_haml`. When looking at one of our example applications, I realized that I was seeing methods that ended with both `__number_number` as well as `___number_number` (three vs two underscores), e.g.: * `_app_views_articles_index_html_erb___2022809201779434309_12900` * `_app_views_articles_index_html_erb__3816154855874711207_12920` On closer inspection of the actionview template naming code in https://github.com/rails/rails/blob/4fa56814f18fd3da49c83931fa773caa727d8096/actionview/lib/action_view/template.rb#L389: ```ruby def method_name # :nodoc: @method_name ||= begin m = +"_#{identifier_method_name}__#{@identifier.hash}_#{__id__}" m.tr!("-", "_") m end end ``` ... I realized that when `@identifier.hash` was a negative number, it would be printed including the - sign, which would be replaced by the `tr` into another `_`. (It's somewhat weird that they didn't just go with `hash.abs` but yeah... >_>). Thus, there was a 50-50 chance that methods end up with three underscores, which would make them not merge together in the flamegraph. This PR fixes this. **Motivation:** Make sure that these dynamically-generated methods merge together properly in a flamegraph. **Additional Notes:** N/A **How to test the change?** This change includes test coverage.
- Loading branch information