From 4ef2f3fbbeb95fc4213a70c4aa6fef4762cf67e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Cournoyer?= Date: Wed, 14 Oct 2020 15:34:53 -0400 Subject: [PATCH 1/2] Add an `instrument` option to disable generation of native block bodies This is to allow section template to be parsed for profiling upfront. See https://github.com/Shopify/storefront-renderer/blob/master/app/liquid/theme_render_context.rb#L265-L269 The name was to imply parse this for profiling (instrument it), but don't profile it. --- lib/liquid/c.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/liquid/c.rb b/lib/liquid/c.rb index 1e28b4ef..972dae2c 100644 --- a/lib/liquid/c.rb +++ b/lib/liquid/c.rb @@ -63,7 +63,10 @@ def new_block_body def disable_liquid_c_nodes # Liquid::Profiler exposes the internal parse tree that we don't want to build when # parsing with liquid-c, so consider liquid-c to be disabled when using it. - @disable_liquid_c_nodes ||= !Liquid::C.enabled || @template_options[:profile] + # Also, some templates are parsed before the profiler is running, on which case we + # provide the `instrument` option enabled the AST to be produced so the profiler can + # use it on future runs. + @disable_liquid_c_nodes ||= !Liquid::C.enabled || @template_options[:profile] || @template_options[:instrument] end end From 4877e34ed6eeedc1f63092101d7fda18be060269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Cournoyer?= Date: Thu, 15 Oct 2020 13:01:05 -0400 Subject: [PATCH 2/2] Rename option to disable_liquid_c_nodes --- lib/liquid/c.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/liquid/c.rb b/lib/liquid/c.rb index 972dae2c..ca19ff59 100644 --- a/lib/liquid/c.rb +++ b/lib/liquid/c.rb @@ -64,9 +64,9 @@ def disable_liquid_c_nodes # Liquid::Profiler exposes the internal parse tree that we don't want to build when # parsing with liquid-c, so consider liquid-c to be disabled when using it. # Also, some templates are parsed before the profiler is running, on which case we - # provide the `instrument` option enabled the AST to be produced so the profiler can - # use it on future runs. - @disable_liquid_c_nodes ||= !Liquid::C.enabled || @template_options[:profile] || @template_options[:instrument] + # provide the `disable_liquid_c_nodes` option to enable the Ruby AST to be produced + # so the profiler can use it on future runs. + @disable_liquid_c_nodes ||= !Liquid::C.enabled || @template_options[:profile] || @template_options[:disable_liquid_c_nodes] end end