liquid-c 4.0.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/cla.yml +23 -0
- data/.github/workflows/liquid.yml +36 -11
- data/.gitignore +4 -0
- data/.rubocop.yml +14 -0
- data/Gemfile +15 -5
- data/README.md +32 -8
- data/Rakefile +12 -63
- data/ext/liquid_c/block.c +493 -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 +97 -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 +21 -9
- data/ext/liquid_c/intutil.h +22 -0
- data/ext/liquid_c/lexer.c +39 -3
- 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/liquid_vm.c +618 -0
- data/ext/liquid_c/liquid_vm.h +25 -0
- data/ext/liquid_c/parse_context.c +76 -0
- data/ext/liquid_c/parse_context.h +13 -0
- data/ext/liquid_c/parser.c +153 -65
- data/ext/liquid_c/parser.h +4 -2
- data/ext/liquid_c/raw.c +136 -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_assembler.c +491 -0
- data/ext/liquid_c/vm_assembler.h +240 -0
- data/ext/liquid_c/vm_assembler_pool.c +99 -0
- data/ext/liquid_c/vm_assembler_pool.h +26 -0
- data/lib/liquid/c/compile_ext.rb +44 -0
- data/lib/liquid/c/version.rb +3 -1
- data/lib/liquid/c.rb +226 -48
- 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 +21 -2
- data/test/unit/block_test.rb +137 -0
- data/test/unit/context_test.rb +85 -0
- data/test/unit/expression_test.rb +191 -0
- data/test/unit/gc_stress_test.rb +28 -0
- data/test/unit/raw_test.rb +93 -0
- data/test/unit/resource_limits_test.rb +50 -0
- data/test/unit/tokenizer_test.rb +90 -20
- data/test/unit/variable_test.rb +279 -60
- metadata +60 -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: 8b5a8a5b1b5f7409b378626e889898eeac6996ef2127894d25d2f342183c633c
|
4
|
+
data.tar.gz: 165117bbbcf583f3c9c0223c3232de5e5c42b67a8ed90b3d268864e4732c685d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7c7ed2cd71c5470c4b53671611279e71279cba16f0a6fcd5623935b80373ed941f6b3360264399ec7f8ab1efe39728f0bba1a6fecdd3e704675e7464ab660aa
|
7
|
+
data.tar.gz: 006af34fd3a151cae0387a0d70f18e5f64f98dba95f1e2bf6ea36fe239db3153f301405c349ff25a852977ad38b8873a6d8b2554753f29f37665ef20f7a30fda
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# .github/workflows/cla.yml
|
2
|
+
name: Contributor License Agreement (CLA)
|
3
|
+
|
4
|
+
on:
|
5
|
+
pull_request_target:
|
6
|
+
types: [opened, synchronize]
|
7
|
+
issue_comment:
|
8
|
+
types: [created]
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
cla:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
if: |
|
14
|
+
(github.event.issue.pull_request
|
15
|
+
&& !github.event.issue.pull_request.merged_at
|
16
|
+
&& contains(github.event.comment.body, 'signed')
|
17
|
+
)
|
18
|
+
|| (github.event.pull_request && !github.event.pull_request.merged)
|
19
|
+
steps:
|
20
|
+
- uses: Shopify/shopify-cla-action@v1
|
21
|
+
with:
|
22
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
23
|
+
cla-token: ${{ secrets.CLA_TOKEN }}
|
@@ -5,19 +5,44 @@ jobs:
|
|
5
5
|
runs-on: ubuntu-latest
|
6
6
|
strategy:
|
7
7
|
matrix:
|
8
|
-
|
9
|
-
- { ruby: 2.7 }
|
10
|
-
- { ruby: 3.
|
11
|
-
|
8
|
+
include:
|
9
|
+
- { ruby: '2.7', allowed-failure: false }
|
10
|
+
- { ruby: '3.0', allowed-failure: false }
|
11
|
+
- { ruby: '3.1', allowed-failure: false }
|
12
|
+
- { ruby: '3.2', allowed-failure: false }
|
13
|
+
- { ruby: '3.3', allowed-failure: false }
|
14
|
+
- { ruby: ruby-head, allowed-failure: true }
|
15
|
+
- { ruby: truffleruby-head, allowed-failure: true }
|
16
|
+
name: test (${{ matrix.ruby }})
|
12
17
|
steps:
|
13
18
|
- uses: actions/checkout@v2
|
14
19
|
- uses: ruby/setup-ruby@v1
|
15
20
|
with:
|
16
|
-
ruby-version: ${{ matrix.
|
17
|
-
|
18
|
-
|
19
|
-
path: vendor/bundle
|
20
|
-
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }}
|
21
|
-
restore-keys: ${{ runner.os }}-gems-
|
22
|
-
- run: bundle install --jobs=3 --retry=3 --path=vendor/bundle
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
bundler-cache: true
|
23
|
+
|
23
24
|
- run: bundle exec rake
|
25
|
+
continue-on-error: ${{ matrix.allowed-failure }}
|
26
|
+
env:
|
27
|
+
LIQUID_C_PEDANTIC: 'true'
|
28
|
+
if: matrix.ruby != 'truffleruby-head'
|
29
|
+
|
30
|
+
- run: bundle exec rake test:unit
|
31
|
+
continue-on-error: ${{ matrix.allowed-failure }}
|
32
|
+
env:
|
33
|
+
LIQUID_C_PEDANTIC: 'true'
|
34
|
+
if: matrix.ruby == 'truffleruby-head'
|
35
|
+
|
36
|
+
- run: bundle exec rubocop
|
37
|
+
if: matrix.ruby != 'truffleruby-head'
|
38
|
+
|
39
|
+
valgrind:
|
40
|
+
runs-on: ubuntu-latest
|
41
|
+
steps:
|
42
|
+
- uses: actions/checkout@v2
|
43
|
+
- uses: ruby/setup-ruby@v1
|
44
|
+
with:
|
45
|
+
ruby-version: 3.3
|
46
|
+
bundler-cache: true
|
47
|
+
- run: sudo apt-get install -y valgrind
|
48
|
+
- run: bundle exec rake test:valgrind
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
@@ -1,14 +1,24 @@
|
|
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 "base64", require: false # for older rubocop on Ruby 3.4
|
14
|
+
gem "rubocop", "~> 1.24.1", require: false
|
15
|
+
gem "rubocop-performance", "~> 1.13.2", require: false
|
16
|
+
gem "rubocop-shopify", "~> 2.4.0", require: false
|
17
|
+
gem "spy", "0.4.1"
|
18
|
+
gem "benchmark-ips"
|
19
|
+
gem "ruby_memcheck"
|
10
20
|
end
|
11
21
|
|
12
22
|
group :development do
|
13
|
-
gem
|
23
|
+
gem "byebug"
|
14
24
|
end
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Liquid::C
|
2
|
-
[![Build Status](https://travis-ci.org/Shopify/liquid-c.svg?branch=
|
2
|
+
[![Build Status](https://travis-ci.org/Shopify/liquid-c.svg?branch=main)](https://travis-ci.org/Shopify/liquid-c)
|
3
3
|
|
4
4
|
Partial native implementation of the liquid ruby gem in C.
|
5
5
|
|
@@ -7,8 +7,8 @@ Partial native implementation of the liquid ruby gem in C.
|
|
7
7
|
|
8
8
|
Add these lines to your application's Gemfile:
|
9
9
|
|
10
|
-
gem 'liquid', github: 'Shopify/liquid', branch: '
|
11
|
-
gem 'liquid-c', github: 'Shopify/liquid-c', branch: '
|
10
|
+
gem 'liquid', github: 'Shopify/liquid', branch: 'main'
|
11
|
+
gem 'liquid-c', github: 'Shopify/liquid-c', branch: 'main'
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
@@ -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,18 @@
|
|
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
|
-
task :
|
12
|
+
task default: [:test, :rubocop]
|
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
|
41
|
-
|
42
|
-
desc "Run the liquid benchmark with strict parsing"
|
43
|
-
task :strict do
|
44
|
-
ruby "./performance.rb c benchmark strict"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
namespace :profile do
|
50
|
-
desc "Run the liquid profile/performance coverage"
|
51
|
-
task :run do
|
52
|
-
ruby "./performance.rb c profile lax"
|
53
|
-
end
|
14
|
+
task test: ["test:unit", "test:integration:all"]
|
54
15
|
|
55
|
-
|
56
|
-
task :
|
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
|
16
|
+
namespace :test do
|
17
|
+
task valgrind: ["test:unit:valgrind", "test:integration:valgrind:all"]
|
69
18
|
end
|