liquid-c 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/liquid.yml +24 -2
- data/.gitignore +4 -0
- data/.rubocop.yml +14 -0
- data/Gemfile +14 -5
- data/README.md +29 -5
- data/Rakefile +13 -62
- data/ext/liquid_c/block.c +488 -60
- data/ext/liquid_c/block.h +28 -2
- data/ext/liquid_c/c_buffer.c +42 -0
- data/ext/liquid_c/c_buffer.h +76 -0
- data/ext/liquid_c/context.c +233 -0
- data/ext/liquid_c/context.h +70 -0
- data/ext/liquid_c/document_body.c +89 -0
- data/ext/liquid_c/document_body.h +59 -0
- data/ext/liquid_c/expression.c +116 -0
- data/ext/liquid_c/expression.h +24 -0
- data/ext/liquid_c/extconf.rb +19 -9
- data/ext/liquid_c/intutil.h +22 -0
- data/ext/liquid_c/lexer.c +6 -2
- data/ext/liquid_c/lexer.h +18 -3
- data/ext/liquid_c/liquid.c +76 -6
- data/ext/liquid_c/liquid.h +24 -1
- data/ext/liquid_c/parse_context.c +76 -0
- data/ext/liquid_c/parse_context.h +13 -0
- data/ext/liquid_c/parser.c +141 -65
- data/ext/liquid_c/parser.h +4 -2
- data/ext/liquid_c/raw.c +110 -0
- data/ext/liquid_c/raw.h +6 -0
- data/ext/liquid_c/resource_limits.c +279 -0
- data/ext/liquid_c/resource_limits.h +23 -0
- data/ext/liquid_c/stringutil.h +44 -0
- data/ext/liquid_c/tokenizer.c +149 -35
- data/ext/liquid_c/tokenizer.h +20 -9
- data/ext/liquid_c/usage.c +18 -0
- data/ext/liquid_c/usage.h +9 -0
- data/ext/liquid_c/variable.c +196 -20
- data/ext/liquid_c/variable.h +18 -1
- data/ext/liquid_c/variable_lookup.c +44 -0
- data/ext/liquid_c/variable_lookup.h +8 -0
- data/ext/liquid_c/vm.c +588 -0
- data/ext/liquid_c/vm.h +25 -0
- data/ext/liquid_c/vm_assembler.c +491 -0
- data/ext/liquid_c/vm_assembler.h +240 -0
- data/ext/liquid_c/vm_assembler_pool.c +97 -0
- data/ext/liquid_c/vm_assembler_pool.h +27 -0
- data/lib/liquid/c/compile_ext.rb +44 -0
- data/lib/liquid/c/version.rb +3 -1
- data/lib/liquid/c.rb +225 -46
- data/liquid-c.gemspec +16 -10
- data/performance/c_profile.rb +23 -0
- data/performance.rb +6 -4
- data/rakelib/compile.rake +15 -0
- data/rakelib/integration_test.rake +43 -0
- data/rakelib/performance.rake +43 -0
- data/rakelib/rubocop.rake +6 -0
- data/rakelib/unit_test.rake +14 -0
- data/test/integration_test.rb +11 -0
- data/test/liquid_test_helper.rb +21 -0
- data/test/test_helper.rb +14 -2
- data/test/unit/block_test.rb +130 -0
- data/test/unit/context_test.rb +83 -0
- data/test/unit/expression_test.rb +186 -0
- data/test/unit/gc_stress_test.rb +28 -0
- data/test/unit/raw_test.rb +19 -0
- data/test/unit/resource_limits_test.rb +50 -0
- data/test/unit/tokenizer_test.rb +90 -20
- data/test/unit/variable_test.rb +212 -60
- metadata +59 -11
- data/test/liquid_test.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0b1d438c8d9e73c713f3c66e14cc41a0b5351f33153047d46728a897c1bc576
|
4
|
+
data.tar.gz: 5275881737af08a486e1ebeb672333ffe534e0de20e8d018246013419950f382
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c21caebe56294b8ef4cce7712261c6f7a50ddb3fd72d08ad2463b7b561a8c13b2d0db1c9b3941ee3a8d4f9a816c85764db182b181a1eacf86032b6d27878e974
|
7
|
+
data.tar.gz: 736ebd21fd1cf147ed1f88cc3828a0209027d22cbec79f72f71fde2599523ec40e974b3ad1aa47acfd5724f4c0b1e3508ba74a13efee84e9e9771c39b012ef65
|
@@ -6,8 +6,10 @@ jobs:
|
|
6
6
|
strategy:
|
7
7
|
matrix:
|
8
8
|
entry:
|
9
|
-
- { ruby: 2.
|
10
|
-
- { ruby:
|
9
|
+
- { ruby: '2.5', allowed-failure: false }
|
10
|
+
- { ruby: '2.7', allowed-failure: false }
|
11
|
+
- { ruby: '3.0', allowed-failure: false }
|
12
|
+
- { ruby: ruby-head, allowed-failure: true }
|
11
13
|
name: test (${{ matrix.entry.ruby }})
|
12
14
|
steps:
|
13
15
|
- uses: actions/checkout@v2
|
@@ -21,3 +23,23 @@ jobs:
|
|
21
23
|
restore-keys: ${{ runner.os }}-gems-
|
22
24
|
- run: bundle install --jobs=3 --retry=3 --path=vendor/bundle
|
23
25
|
- run: bundle exec rake
|
26
|
+
continue-on-error: ${{ matrix.entry.allowed-failure }}
|
27
|
+
env:
|
28
|
+
LIQUID_C_PEDANTIC: 'true'
|
29
|
+
- run: bundle exec rubocop
|
30
|
+
|
31
|
+
valgrind:
|
32
|
+
runs-on: ubuntu-latest
|
33
|
+
steps:
|
34
|
+
- uses: actions/checkout@v2
|
35
|
+
- uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: '3.0'
|
38
|
+
- run: sudo apt-get install -y valgrind
|
39
|
+
- uses: actions/cache@v1
|
40
|
+
with:
|
41
|
+
path: vendor/bundle
|
42
|
+
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }}
|
43
|
+
restore-keys: ${{ runner.os }}-gems-
|
44
|
+
- run: bundle install --jobs=3 --retry=3 --path=vendor/bundle
|
45
|
+
- run: bundle exec rake test:valgrind
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
@@ -1,14 +1,23 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
git_source(:github) do |repo_name|
|
5
|
+
"https://github.com/#{repo_name}.git"
|
6
|
+
end
|
2
7
|
|
3
8
|
gemspec
|
4
9
|
|
5
|
-
gem
|
10
|
+
gem "liquid", github: "Shopify/liquid", ref: "master"
|
6
11
|
|
7
12
|
group :test do
|
8
|
-
gem
|
9
|
-
gem
|
13
|
+
gem "rubocop", "~> 1.24.1", require: false
|
14
|
+
gem "rubocop-performance", "~> 1.13.2", require: false
|
15
|
+
gem "rubocop-shopify", "~> 2.4.0", require: false
|
16
|
+
gem "spy", "0.4.1"
|
17
|
+
gem "benchmark-ips"
|
18
|
+
gem "ruby_memcheck"
|
10
19
|
end
|
11
20
|
|
12
21
|
group :development do
|
13
|
-
gem
|
22
|
+
gem "byebug"
|
14
23
|
end
|
data/README.md
CHANGED
@@ -31,14 +31,38 @@ then just use the documented API for the liquid Gem.
|
|
31
31
|
|
32
32
|
To compare Liquid-C's performance with plain Liquid run
|
33
33
|
|
34
|
-
bundle exec rake compare:
|
34
|
+
bundle exec rake compare:lax
|
35
35
|
|
36
36
|
The latest benchmark results are shown below:
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
```
|
39
|
+
$ bundle exec rake compare:lax
|
40
|
+
/home/spin/.rubies/ruby-3.0.2/bin/ruby ./performance.rb bare benchmark lax
|
41
|
+
|
42
|
+
Running benchmark for 10 seconds (with 5 seconds warmup).
|
43
|
+
|
44
|
+
Warming up --------------------------------------
|
45
|
+
parse: 2.000 i/100ms
|
46
|
+
render: 8.000 i/100ms
|
47
|
+
parse & render: 2.000 i/100ms
|
48
|
+
Calculating -------------------------------------
|
49
|
+
parse: 29.527 (± 3.4%) i/s - 296.000 in 10.034520s
|
50
|
+
render: 89.403 (± 6.7%) i/s - 896.000 in 10.072939s
|
51
|
+
parse & render: 20.474 (± 4.9%) i/s - 206.000 in 10.072806s
|
52
|
+
|
53
|
+
/home/spin/.rubies/ruby-3.0.2/bin/ruby ./performance.rb c benchmark lax
|
54
|
+
|
55
|
+
Running benchmark for 10 seconds (with 5 seconds warmup).
|
56
|
+
|
57
|
+
Warming up --------------------------------------
|
58
|
+
parse: 10.000 i/100ms
|
59
|
+
render: 18.000 i/100ms
|
60
|
+
parse & render: 5.000 i/100ms
|
61
|
+
Calculating -------------------------------------
|
62
|
+
parse: 90.672 (± 3.3%) i/s - 910.000 in 10.051124s
|
63
|
+
render: 163.871 (± 4.9%) i/s - 1.638k in 10.018105s
|
64
|
+
parse & render: 50.165 (± 4.0%) i/s - 505.000 in 10.077377s
|
65
|
+
```
|
42
66
|
|
43
67
|
## Developing
|
44
68
|
|
data/Rakefile
CHANGED
@@ -1,69 +1,20 @@
|
|
1
|
-
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rake/extensiontask'
|
5
|
-
require 'benchmark'
|
1
|
+
# frozen_string_literal: true
|
6
2
|
|
7
|
-
|
8
|
-
|
3
|
+
require "rake"
|
4
|
+
require "rake/testtask"
|
5
|
+
require "bundler/gem_tasks"
|
6
|
+
require "rake/extensiontask"
|
7
|
+
require "benchmark"
|
8
|
+
require "ruby_memcheck"
|
9
9
|
|
10
|
-
|
10
|
+
ENV["DEBUG"] ||= "true"
|
11
11
|
|
12
|
-
|
12
|
+
RubyMemcheck.config(binary_name: "liquid_c")
|
13
13
|
|
14
|
-
|
15
|
-
Rake::TestTask.new(:unit => :compile) do |t|
|
16
|
-
t.libs << 'lib' << 'test'
|
17
|
-
t.test_files = FileList['test/unit/**/*_test.rb']
|
18
|
-
end
|
19
|
-
|
20
|
-
desc 'run test suite with default parser'
|
21
|
-
Rake::TestTask.new(:base_liquid => :compile) do |t|
|
22
|
-
t.libs << 'lib'
|
23
|
-
t.test_files = ['test/liquid_test.rb']
|
24
|
-
end
|
25
|
-
|
26
|
-
desc 'runs test suite with both strict and lax parsers'
|
27
|
-
task :liquid do
|
28
|
-
ENV['LIQUID_PARSER_MODE'] = 'lax'
|
29
|
-
Rake::Task['test:base_liquid'].invoke
|
30
|
-
ENV['LIQUID_PARSER_MODE'] = 'strict'
|
31
|
-
Rake::Task['test:base_liquid'].reenable
|
32
|
-
Rake::Task['test:base_liquid'].invoke
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
namespace :benchmark do
|
37
|
-
desc "Run the liquid benchmark with lax parsing"
|
38
|
-
task :run do
|
39
|
-
ruby "./performance.rb c benchmark lax"
|
40
|
-
end
|
14
|
+
task default: [:test, :rubocop]
|
41
15
|
|
42
|
-
|
43
|
-
task :strict do
|
44
|
-
ruby "./performance.rb c benchmark strict"
|
45
|
-
end
|
46
|
-
end
|
16
|
+
task test: ["test:unit", "test:integration:all"]
|
47
17
|
|
48
|
-
|
49
|
-
|
50
|
-
desc "Run the liquid profile/performance coverage"
|
51
|
-
task :run do
|
52
|
-
ruby "./performance.rb c profile lax"
|
53
|
-
end
|
54
|
-
|
55
|
-
desc "Run the liquid profile/performance coverage with strict parsing"
|
56
|
-
task :strict do
|
57
|
-
ruby "./performance.rb c profile strict"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
namespace :compare do
|
62
|
-
%w(lax warn strict).each do |type|
|
63
|
-
desc "Compare Liquid to Liquid-C in #{type} mode"
|
64
|
-
task type.to_sym do
|
65
|
-
ruby "./performance.rb bare benchmark #{type}"
|
66
|
-
ruby "./performance.rb c benchmark #{type}"
|
67
|
-
end
|
68
|
-
end
|
18
|
+
namespace :test do
|
19
|
+
task valgrind: ["test:unit:valgrind", "test:integration:valgrind:all"]
|
69
20
|
end
|