Граф коммитов

88289 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada f6bd8f2d39
Win32: [DOC] No extlibs file, no patch is needed 2024-10-28 17:27:40 +09:00
nagachika 70d20ce473 Update bundled gems list 2024-10-28 12:29:59 +09:00
Nobuyoshi Nakada 484ea00d2e [ruby/stringio] An empty string should be converted to empty in any encoding
https://github.com/ruby/stringio/commit/ef03f9368d
2024-10-26 13:20:34 +00:00
Nobuyoshi Nakada f513863c81 [ruby/stringio] Unreachable after an invalid argument exception
https://github.com/ruby/stringio/commit/a2aab4721c
2024-10-26 12:55:45 +00:00
Nobuyoshi Nakada 393c5df008 [ruby/stringio] Remove `SafeStringValue`
In Ruby 2.7 and later, it is the same as `StringValue`.

https://github.com/ruby/stringio/commit/561ea67ea8
2024-10-26 12:55:45 +00:00
git 519f559113 Update default gems list at caa946f2de [ci skip] 2024-10-26 09:45:06 +00:00
Hiroshi SHIBATA caa946f2de Restore ext/json/extconf.rb 2024-10-26 18:44:15 +09:00
Hiroshi SHIBATA 58797b7f74 No longer needed ext/json/extconf.rb 2024-10-26 18:44:15 +09:00
Jean Boussier e136e552b6 [ruby/json] Instantiate Parser with a kwsplat
Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs.
So if json_pure 2.7.4 is loaded with `json <= 2.7.2` (or stdlib)
it blows up.

Ref: https://github.com/ruby/json/issues/650
Fix: https://github.com/ruby/json/issues/651

https://github.com/ruby/json/commit/4d9dc98817
2024-10-26 18:44:15 +09:00
Jean Boussier 8018a3121f [ruby/json] Workaround being loaded alongside a different `json_pure` version
Fix: https://github.com/ruby/json/issues/646

Since both `json` and `json_pure` expose the same files, if the
versions don't match, the native extension may be loaded with Ruby
code that don't match and is incompatible.

By doing the `require json/ext/generator/state` from C we ensure
we're at least loading that.

But this is a dirty workaround for the 2.7.x branch, we should
find a better way to fully isolate the two gems.

https://github.com/ruby/json/commit/dfdd4acf36
2024-10-26 18:44:15 +09:00
Jean Boussier a5bd0c638a [ruby/json] Workaround rubygems $LOAD_PATH bug
Ref: https://github.com/ruby/json/issues/647
Ref: https://github.com/rubygems/rubygems/pull/6490

Older rubygems are executing `extconf.rb` with a broken `$LOAD_PATH`
causing the `json` gem native extension to be loaded with the stdlib
version of the `.rb` files.

This fails with

```
json/common.rb:82:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
```

Since this is just for `extconf.rb` we can probably just accept that
extra argument and ignore it.

The bug was fixed in rubygems 3.4.9 / 2023-03-20

https://github.com/ruby/json/commit/1f5e849fe0
2024-10-26 18:44:15 +09:00
Jean Boussier 3daf16e51f [ruby/json] Cleanup test_helper.rb
https://github.com/ruby/json/commit/49de571dd8
2024-10-26 18:44:15 +09:00
Jean Boussier 7314275548 json_pure: fix ractor compatibility
This actually never worked, because the test was always testing
the ext version from the stdlib, never the pure version nor the
current ext version.
2024-10-26 18:44:15 +09:00
Jean Boussier a3c21756e9 [ruby/json] Use smaller types for JSON_Parser boolean fields
https://github.com/ruby/json/commit/7f079b25be
2024-10-26 18:44:15 +09:00
Jean Boussier b1d417dc7b [ruby/json] Cleaner .encode / .force_encoding
https://github.com/ruby/json/commit/cecf04fdfc
2024-10-26 18:44:15 +09:00
Jean Boussier 1045b9f820 [ruby/json] Modernize heredocs
https://github.com/ruby/json/commit/fb25e94aea
2024-10-26 18:44:15 +09:00
Jean Boussier bfdf02ea72 pretty_generate: don't apply object_nl / array_nl for empty containers
Fix: https://github.com/ruby/json/issues/437

Before:

```json
{
  "foo": {
  },
  "bar": [
  ]
}
```

After:

```json
{
  "foo": {},
  "bar": []
}
```
2024-10-26 18:44:15 +09:00
Jean Boussier 1d4708565f Set Ruby 2.7 as the required version 2024-10-26 18:44:15 +09:00
Jean Boussier 7d37ae6751 [ruby/json] Start 2.8.0 development
https://github.com/ruby/json/commit/937c8d2e65
2024-10-26 18:44:15 +09:00
Jean Boussier 9d3fd50cfe [ruby/json] Release 2.7.3
https://github.com/ruby/json/commit/7a3b482013
2024-10-26 18:44:15 +09:00
Jean Boussier 89d4bbacfb [ruby/json] Release 2.7.3.rc1
https://github.com/ruby/json/commit/a48be35825
2024-10-26 18:44:15 +09:00
Jean Boussier 925131073d Merge json and json-java gemspecs 2024-10-26 18:44:15 +09:00
Jean Boussier fc9f0cb8c5 [ruby/json] JSON.dump / String#to_json: raise on invalid encoding
This regressed since 2.7.2.

https://github.com/ruby/json/commit/35407d6635
2024-10-26 18:44:15 +09:00
Benoit Daloze 2c6e3bc71e Raise the correct exception in fast_serialize_string
* Related to https://github.com/ruby/json/issues/344
2024-10-26 18:44:15 +09:00
Benoit Daloze 1cf1bf9588 [ruby/json] Add lib/json/ext/generator/state.rb to the gemspec
* Otherwise the gem always uses the pure-Ruby backend
  as it's missing that file and rescuing the LoadError.

https://github.com/ruby/json/commit/1e2809b0b0
2024-10-26 18:44:15 +09:00
Jean Boussier 70f554efb4 [ruby/json] raise_parse_error: avoid UB
Fix: https://github.com/ruby/json/pull/625

Declaring the buffer in a sub block cause bugs on some compilers.

https://github.com/ruby/json/commit/90967c9eb0
2024-10-26 18:44:15 +09:00
Jean Boussier 00aa1f9a1d [ruby/json] Encoding benchmark updates
Remove `rapidjson` as it's 2x slower most benchmarks, and on
par on a couple of them, so it's not telling us much here.

Configure `Oj` in compat mode so it generate the same JSON
on the `many to_json` benchmark.

```
== Encoding small nested array (121 bytes)
ruby 3.4.0preview2 (2024-10-07 master https://github.com/ruby/json/commit/32c733f57b) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
        json (reuse)   220.202k i/100ms
                json   162.190k i/100ms
                  oj   222.094k i/100ms
Calculating -------------------------------------
        json (reuse)      2.322M (± 1.3%) i/s  (430.72 ns/i) -     11.671M in   5.027655s
                json      1.707M (± 1.2%) i/s  (585.76 ns/i) -      8.596M in   5.035996s
                  oj      2.248M (± 1.4%) i/s  (444.94 ns/i) -     11.327M in   5.040712s

Comparison:
        json (reuse):  2321686.9 i/s
                  oj:  2247509.6 i/s - 1.03x  slower
                json:  1707179.3 i/s - 1.36x  slower

== Encoding small hash (65 bytes)
ruby 3.4.0preview2 (2024-10-07 master https://github.com/ruby/json/commit/32c733f57b) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
        json (reuse)   446.184k i/100ms
                json   265.594k i/100ms
                  oj   653.226k i/100ms
Calculating -------------------------------------
        json (reuse)      4.980M (± 1.4%) i/s  (200.82 ns/i) -     24.986M in   5.018729s
                json      2.763M (± 1.8%) i/s  (361.94 ns/i) -     13.811M in   5.000434s
                  oj      7.232M (± 1.4%) i/s  (138.28 ns/i) -     36.581M in   5.059377s

Comparison:
        json (reuse):  4979642.4 i/s
                  oj:  7231624.4 i/s - 1.45x  faster
                json:  2762890.1 i/s - 1.80x  slower

== Encoding mixed utf8 (5003001 bytes)
ruby 3.4.0preview2 (2024-10-07 master https://github.com/ruby/json/commit/32c733f57b) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json    34.000 i/100ms
                  oj    36.000 i/100ms
Calculating -------------------------------------
                json    357.772 (± 4.8%) i/s    (2.80 ms/i) -      1.802k in   5.047308s
                  oj    327.521 (± 1.5%) i/s    (3.05 ms/i) -      1.656k in   5.057241s

Comparison:
                json:      357.8 i/s
                  oj:      327.5 i/s - 1.09x  slower

== Encoding mostly utf8 (5001001 bytes)
ruby 3.4.0preview2 (2024-10-07 master https://github.com/ruby/json/commit/32c733f57b) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json    26.000 i/100ms
                  oj    36.000 i/100ms
Calculating -------------------------------------
                json    294.357 (±10.5%) i/s    (3.40 ms/i) -      1.456k in   5.028862s
                  oj    352.826 (± 8.2%) i/s    (2.83 ms/i) -      1.764k in   5.045651s

Comparison:
                json:      294.4 i/s
                  oj:      352.8 i/s - same-ish: difference falls within error

== Encoding twitter.json (466906 bytes)
ruby 3.4.0preview2 (2024-10-07 master https://github.com/ruby/json/commit/32c733f57b) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json   206.000 i/100ms
                  oj   229.000 i/100ms
Calculating -------------------------------------
                json      2.064k (± 9.3%) i/s  (484.55 μs/i) -     10.300k in   5.056409s
                  oj      2.121k (± 8.4%) i/s  (471.47 μs/i) -     10.534k in   5.012315s

Comparison:
                json:     2063.8 i/s
                  oj:     2121.0 i/s - same-ish: difference falls within error

== Encoding citm_catalog.json (500298 bytes)
ruby 3.4.0preview2 (2024-10-07 master https://github.com/ruby/json/commit/32c733f57b) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json   119.000 i/100ms
                  oj   126.000 i/100ms
Calculating -------------------------------------
                json      1.317k (± 2.3%) i/s  (759.18 μs/i) -      6.664k in   5.061781s
                  oj      1.261k (± 2.9%) i/s  (793.11 μs/i) -      6.300k in   5.000714s

Comparison:
                json:     1317.2 i/s
                  oj:     1260.9 i/s - same-ish: difference falls within error

== Encoding canada.json (2090234 bytes)
ruby 3.4.0preview2 (2024-10-07 master https://github.com/ruby/json/commit/32c733f57b) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json     1.000 i/100ms
                  oj     1.000 i/100ms
Calculating -------------------------------------
                json     19.590 (± 0.0%) i/s   (51.05 ms/i) -     98.000 in   5.004485s
                  oj     19.003 (± 0.0%) i/s   (52.62 ms/i) -     95.000 in   5.002276s

Comparison:
                json:       19.6 i/s
                  oj:       19.0 i/s - 1.03x  slower

== Encoding many #to_json calls (2701 bytes)
ruby 3.4.0preview2 (2024-10-07 master https://github.com/ruby/json/commit/32c733f57b) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json     2.556k i/100ms
                  oj     2.332k i/100ms
Calculating -------------------------------------
                json     25.367k (± 1.7%) i/s   (39.42 μs/i) -    127.800k in   5.039438s
                  oj     23.743k (± 1.5%) i/s   (42.12 μs/i) -    118.932k in   5.010303s

Comparison:
                json:    25367.3 i/s
                  oj:    23743.3 i/s - 1.07x  slower

```

https://github.com/ruby/json/commit/5a64fd5b6f
2024-10-26 18:44:15 +09:00
Étienne Barrié 44aef5e852 [ruby/json] Drop compatibility for missing Array#permutation (Ruby <= 1.8.6)
https://github.com/ruby/json/commit/b02091ed44

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-26 18:44:15 +09:00
Étienne Barrié 82f7550f65 Use frozen string literals
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-26 18:44:15 +09:00
Étienne Barrié 5f97468958 [ruby/json] Drop compatibility for missing Time#tv_nsec (Ruby 1.8)
https://github.com/ruby/json/commit/b240bde402

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-26 18:44:15 +09:00
Étienne Barrié 11348c583f Use Encoding constants, String#b
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-26 18:44:15 +09:00
Jean Boussier a052d96103 [ruby/json] Compile with std=c99
https://github.com/ruby/json/commit/d4968d2e48
2024-10-26 18:44:15 +09:00
Jean Boussier cbd933bcf1 [ruby/json] convert_UTF8_to_ASCII_only_JSON: apply the same optimization pass
https://github.com/ruby/json/commit/42edaf7f17
2024-10-26 18:44:15 +09:00
Jean Boussier e52b47680e [ruby/json] Reduce encoding benchmark size
Profiling revealed that we were spending lots of time growing the buffer.
Buffer operations is definitely something we want to optimize, but for
this specific benchmark what we're interested in is UTF-8 scanning performance.

Each iteration of the two scaning benchmark were producing 20MB of JSON,
now they only produce 5MB.

Now:

```
== Encoding mostly utf8 (5001001 bytes)
ruby 3.4.0dev (2024-10-18T19:01:45Z master https://github.com/ruby/json/commit/7be9a333ca) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json    35.000 i/100ms
                  oj    36.000 i/100ms
           rapidjson    10.000 i/100ms
Calculating -------------------------------------
                json    359.161 (± 1.4%) i/s    (2.78 ms/i) -      1.820k in   5.068542s
                  oj    359.699 (± 0.6%) i/s    (2.78 ms/i) -      1.800k in   5.004291s
           rapidjson     99.687 (± 2.0%) i/s   (10.03 ms/i) -    500.000 in   5.017321s

Comparison:
                json:      359.2 i/s
                  oj:      359.7 i/s - same-ish: difference falls within error
           rapidjson:       99.7 i/s - 3.60x  slower
```

https://github.com/ruby/json/commit/1a338532d2
2024-10-26 18:44:15 +09:00
Jean Boussier 97713ac952 [ruby/json] convert_UTF8_to_JSON: repurpose the escape tables into size tables
Since we're looking up the table anyway, we might as well store the
UTF-8 char length in it. For single byte characters that don't need
escaping we store `0`.

This helps on strings with lots of multi-byte characters:

Before:

```
== Encoding mostly utf8 (20004001 bytes)
ruby 3.3.4 (2024-07-09 revision https://github.com/ruby/json/commit/be1089c8ec) +YJIT [arm64-darwin23]
Warming up --------------------------------------
                json     6.000 i/100ms
                  oj    10.000 i/100ms
           rapidjson     2.000 i/100ms
Calculating -------------------------------------
                json     67.978 (± 1.5%) i/s   (14.71 ms/i) -    342.000 in   5.033062s
                  oj    100.876 (± 2.0%) i/s    (9.91 ms/i) -    510.000 in   5.058080s
           rapidjson     26.389 (± 7.6%) i/s   (37.89 ms/i) -    132.000 in   5.027681s

Comparison:
                json:       68.0 i/s
                  oj:      100.9 i/s - 1.48x  faster
           rapidjson:       26.4 i/s - 2.58x  slower
```

After:

```
== Encoding mostly utf8 (20004001 bytes)
ruby 3.3.4 (2024-07-09 revision https://github.com/ruby/json/commit/be1089c8ec) +YJIT [arm64-darwin23]
Warming up --------------------------------------
                json     7.000 i/100ms
                  oj    10.000 i/100ms
           rapidjson     2.000 i/100ms
Calculating -------------------------------------
                json     75.187 (± 2.7%) i/s   (13.30 ms/i) -    378.000 in   5.030111s
                  oj     95.196 (± 2.1%) i/s   (10.50 ms/i) -    480.000 in   5.043565s
           rapidjson     25.969 (± 3.9%) i/s   (38.51 ms/i) -    130.000 in   5.011471s

Comparison:
                json:       75.2 i/s
                  oj:       95.2 i/s - 1.27x  faster
           rapidjson:       26.0 i/s - 2.90x  slower
```

https://github.com/ruby/json/commit/51e2631d1f
2024-10-26 18:44:15 +09:00
Jean Boussier 9f300d0541 [ruby/json] Optimize convert_UTF8_to_JSON for mostly ASCII strings
If we assume that even UTF-8 strings are mostly ASCII, we can implement a
fast path for the ASCII parts.

Before:

```
== Encoding mixed utf8 (20012001 bytes)
ruby 3.4.0dev (2024-10-18T15:12:54Z master https://github.com/ruby/json/commit/d1b5c10957) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json     5.000 i/100ms
                  oj     9.000 i/100ms
           rapidjson     2.000 i/100ms
Calculating -------------------------------------
                json     49.403 (± 2.0%) i/s   (20.24 ms/i) -    250.000 in   5.062647s
                  oj    100.120 (± 2.0%) i/s    (9.99 ms/i) -    504.000 in   5.035349s
           rapidjson     26.404 (± 0.0%) i/s   (37.87 ms/i) -    132.000 in   5.001025s

Comparison:
                json:       49.4 i/s
                  oj:      100.1 i/s - 2.03x  faster
           rapidjson:       26.4 i/s - 1.87x  slower
```

After:

```
== Encoding mixed utf8 (20012001 bytes)
ruby 3.4.0dev (2024-10-18T15:12:54Z master https://github.com/ruby/json/commit/d1b5c10957) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
                json    10.000 i/100ms
                  oj     9.000 i/100ms
           rapidjson     2.000 i/100ms
Calculating -------------------------------------
                json     95.686 (± 2.1%) i/s   (10.45 ms/i) -    480.000 in   5.018575s
                  oj     96.875 (± 2.1%) i/s   (10.32 ms/i) -    486.000 in   5.019097s
           rapidjson     26.260 (± 3.8%) i/s   (38.08 ms/i) -    132.000 in   5.033151s

Comparison:
                json:       95.7 i/s
                  oj:       96.9 i/s - same-ish: difference falls within error
           rapidjson:       26.3 i/s - 3.64x  slower
```

https://github.com/ruby/json/commit/f8166c2d7f
2024-10-26 18:44:15 +09:00
Jean Boussier 07fc21cfad [ruby/json] Ext::Parser avoid costly check on decimal_class when it is nil
Closes: https://github.com/ruby/json/pull/512

https://github.com/ruby/json/commit/d882a45d82

Co-Authored-By: lukeg <luke.gru@gmail.com>
2024-10-26 18:44:15 +09:00
Jean Boussier 18cc663aef [ruby/json] Add test coverage for JSON.load with a Proc
Fix: https://github.com/ruby/json/issues/438

https://github.com/ruby/json/commit/9dd89eaac8
2024-10-26 18:44:15 +09:00
Jean Boussier 9045258c88 [ruby/json] Limit the size of ParserError exception messages
Fix: https://github.com/ruby/json/issues/534

Only include up to 32 bytes of unparseable the source.

https://github.com/ruby/json/commit/f44995cfb6
2024-10-26 18:44:15 +09:00
Jean Boussier 7dfc1f3d66 [ruby/json] parser.c: refactor raise_parse_error
https://github.com/ruby/json/commit/09e1df2643
2024-10-26 18:44:15 +09:00
Jean Boussier 618085f48d [ruby/json] Get rid of the remaining tabs.
https://github.com/ruby/json/commit/1a9af430d2
2024-10-26 18:44:15 +09:00
Jean Boussier e0f8732023 Reduce allocations in `parse` and `load` argument handling
Avoid needless hash allocations and such that degrade performance
significantly on micro-benchmarks.
2024-10-26 18:44:15 +09:00
Jean Boussier 8e7e638221 Add more precise documentation for `object_class` and `array_class`
Fix: https://github.com/ruby/json/issues/419
2024-10-26 18:44:15 +09:00
Jean Boussier aed0114913 [ruby/json] Annotate the encoding benchmark
Note where we currently stand, what the current bottlencks are
and what could or can't be done.

```
== Encoding small nested array (121 bytes)
ruby 3.3.4 (2024-07-09 revision https://github.com/ruby/json/commit/be1089c8ec) [arm64-darwin23]
Warming up --------------------------------------
                json   129.145k i/100ms
        json (reuse)   239.395k i/100ms
                  oj   211.514k i/100ms
           rapidjson   130.660k i/100ms
Calculating -------------------------------------
                json      1.284M (± 0.3%) i/s  (779.11 ns/i) -      6.457M in   5.030954s
        json (reuse)      2.405M (± 0.1%) i/s  (415.77 ns/i) -     12.209M in   5.076202s
                  oj      2.118M (± 0.0%) i/s  (472.11 ns/i) -     10.787M in   5.092795s
           rapidjson      1.325M (± 1.3%) i/s  (754.82 ns/i) -      6.664M in   5.030763s

Comparison:
                json:  1283514.8 i/s
        json (reuse):  2405175.0 i/s - 1.87x  faster
                  oj:  2118132.9 i/s - 1.65x  faster
           rapidjson:  1324820.8 i/s - 1.03x  faster

== Encoding small hash (65 bytes)
ruby 3.3.4 (2024-07-09 revision https://github.com/ruby/json/commit/be1089c8ec) [arm64-darwin23]
Warming up --------------------------------------
                json   177.502k i/100ms
        json (reuse)   485.963k i/100ms
                  oj   656.566k i/100ms
           rapidjson   227.985k i/100ms
Calculating -------------------------------------
                json      1.774M (± 3.1%) i/s  (563.67 ns/i) -      8.875M in   5.007964s
        json (reuse)      4.804M (± 3.0%) i/s  (208.16 ns/i) -     24.298M in   5.062426s
                  oj      6.564M (± 1.9%) i/s  (152.36 ns/i) -     32.828M in   5.003539s
           rapidjson      2.229M (± 2.0%) i/s  (448.59 ns/i) -     11.171M in   5.013299s

Comparison:
                json:  1774084.6 i/s
                  oj:  6563547.8 i/s - 3.70x  faster
        json (reuse):  4804083.0 i/s - 2.71x  faster
           rapidjson:  2229209.5 i/s - 1.26x  faster

== Encoding twitter.json (466906 bytes)
ruby 3.3.4 (2024-07-09 revision https://github.com/ruby/json/commit/be1089c8ec) [arm64-darwin23]
Warming up --------------------------------------
                json   212.000 i/100ms
                  oj   222.000 i/100ms
           rapidjson   109.000 i/100ms
Calculating -------------------------------------
                json      2.135k (± 0.7%) i/s  (468.32 μs/i) -     10.812k in   5.063665s
                  oj      2.219k (± 1.9%) i/s  (450.69 μs/i) -     11.100k in   5.004642s
           rapidjson      1.093k (± 3.8%) i/s  (914.66 μs/i) -      5.559k in   5.090812s

Comparison:
                json:     2135.3 i/s
                  oj:     2218.8 i/s - 1.04x  faster
           rapidjson:     1093.3 i/s - 1.95x  slower

== Encoding citm_catalog.json (500298 bytes)
ruby 3.3.4 (2024-07-09 revision https://github.com/ruby/json/commit/be1089c8ec) [arm64-darwin23]
Warming up --------------------------------------
                json   132.000 i/100ms
                  oj   126.000 i/100ms
           rapidjson    96.000 i/100ms
Calculating -------------------------------------
                json      1.304k (± 2.2%) i/s  (766.96 μs/i) -      6.600k in   5.064483s
                  oj      1.272k (± 0.8%) i/s  (786.14 μs/i) -      6.426k in   5.052044s
           rapidjson    997.370 (± 4.8%) i/s    (1.00 ms/i) -      4.992k in   5.016266s

Comparison:
                json:     1303.9 i/s
                  oj:     1272.0 i/s - same-ish: difference falls within error
           rapidjson:      997.4 i/s - 1.31x  slower

== Encoding canada.json (2090234 bytes)
ruby 3.3.4 (2024-07-09 revision https://github.com/ruby/json/commit/be1089c8ec) [arm64-darwin23]
Warming up --------------------------------------
                json     2.000 i/100ms
                  oj     3.000 i/100ms
           rapidjson     1.000 i/100ms
Calculating -------------------------------------
                json     20.001 (± 0.0%) i/s   (50.00 ms/i) -    102.000 in   5.100950s
                  oj     30.823 (± 0.0%) i/s   (32.44 ms/i) -    156.000 in   5.061333s
           rapidjson     19.446 (± 0.0%) i/s   (51.42 ms/i) -     98.000 in   5.041884s

Comparison:
                json:       20.0 i/s
                  oj:       30.8 i/s - 1.54x  faster
           rapidjson:       19.4 i/s - 1.03x  slower

== Encoding many #to_json calls (2661 bytes)
oj does not match expected output. Skipping
rapidjson unsupported (Invalid object key type: Object)
ruby 3.3.4 (2024-07-09 revision https://github.com/ruby/json/commit/be1089c8ec) [arm64-darwin23]
Warming up --------------------------------------
                json     2.200k i/100ms
Calculating -------------------------------------
                json     22.253k (± 0.2%) i/s   (44.94 μs/i) -    112.200k in   5.041962s
```

https://github.com/ruby/json/commit/77e97b3d4e
2024-10-26 18:44:15 +09:00
David Rodríguez 5fa491b405 Normalize lockfile platforms 2024-10-26 18:44:15 +09:00
NAITOH Jun e61bb75a86 [ruby/strscan] [JRuby] Optimize `scan()`: Remove duplicate `if
(restLen() < patternsize()) return context.nil;` checks in
`!headonly`.
(https://github.com/ruby/strscan/pull/110)

- before: #109

## Why?

d31274f41b/ext/jruby/org/jruby/ext/strscan/RubyStringScanner.java (L371-L373)

This means the following :

`if (str.size() - curr < pattern.size()) return context.nil;`

A similar check is made within `StringSupport#index()` within
`!headonly`.

be7815ec02/core/src/main/java/org/jruby/util/StringSupport.java (L1706-L1720)

```Java
    public static int index(ByteList source, ByteList other, int offset, Encoding enc) {
        int sourceLen = source.realSize();
        int sourceBegin = source.begin();
        int otherLen = other.realSize();

        if (otherLen == 0) return offset;
        if (sourceLen - offset < otherLen) return -1;
```

- source = `strBL`
- other = `patternBL`
- offset = `strBeg + curr`

This means the following :
`if (strBL.realSize() - (strBeg + curr) < patternBL.realSize()) return
-1;`

Both checks are the same.

## Benchmark

It shows String as a pattern is 2.40x faster than Regexp as a pattern.

```
$ benchmark-driver benchmark/check_until.yaml
Warming up --------------------------------------
              regexp     7.613M i/s -      7.593M times in 0.997350s (131.35ns/i)
          regexp_var     7.793M i/s -      7.772M times in 0.997364s (128.32ns/i)
              string    13.222M i/s -     13.199M times in 0.998297s (75.63ns/i)
          string_var    15.283M i/s -     15.216M times in 0.995667s (65.43ns/i)
Calculating -------------------------------------
              regexp    10.003M i/s -     22.840M times in 2.283361s (99.97ns/i)
          regexp_var     9.991M i/s -     23.378M times in 2.340019s (100.09ns/i)
              string    23.454M i/s -     39.666M times in 1.691221s (42.64ns/i)
          string_var    23.998M i/s -     45.848M times in 1.910447s (41.67ns/i)

Comparison:
          string_var:  23998466.3 i/s
              string:  23453777.5 i/s - 1.02x  slower
              regexp:  10002809.4 i/s - 2.40x  slower
          regexp_var:   9990580.1 i/s - 2.40x  slower
```

https://github.com/ruby/strscan/commit/843e931d13
2024-10-26 18:44:15 +09:00
NAITOH Jun e73f35ddaf [ruby/strscan] [CRuby] Optimize `strscan_do_scan()`: Remove
unnecessary use of `rb_enc_get()`
(https://github.com/ruby/strscan/pull/108)

- before: #106

## Why?

In `rb_strseq_index()`, the result of `rb_enc_check()` is used.

-
6c7209cd37/string.c (L4335-L4368)
> enc = rb_enc_check(str, sub);

> return strseq_core(str_ptr, str_ptr_end, str_len, sub_ptr, sub_len,
offset, enc);

-
6c7209cd37/string.c (L4309-L4318)
```C
strseq_core(const char *str_ptr, const char *str_ptr_end, long str_len,
            const char *sub_ptr, long sub_len, long offset, rb_encoding *enc)
{
    const char *search_start = str_ptr;
    long pos, search_len = str_len - offset;

    for (;;) {
        const char *t;
        pos = rb_memsearch(sub_ptr, sub_len, search_start, search_len, enc);
```

## Benchmark

It shows String as a pattern is 1.24x faster than Regexp as a pattern.

```
$ benchmark-driver benchmark/check_until.yaml
Warming up --------------------------------------
              regexp     9.225M i/s -      9.328M times in 1.011068s (108.40ns/i)
          regexp_var     9.327M i/s -      9.413M times in 1.009214s (107.21ns/i)
              string     9.200M i/s -      9.355M times in 1.016840s (108.70ns/i)
          string_var    11.249M i/s -     11.255M times in 1.000578s (88.90ns/i)
Calculating -------------------------------------
              regexp     9.565M i/s -     27.676M times in 2.893476s (104.55ns/i)
          regexp_var    10.111M i/s -     27.982M times in 2.767496s (98.90ns/i)
              string    10.060M i/s -     27.600M times in 2.743465s (99.40ns/i)
          string_var    12.519M i/s -     33.746M times in 2.695615s (79.88ns/i)

Comparison:
          string_var:  12518707.2 i/s
          regexp_var:  10111089.6 i/s - 1.24x  slower
              string:  10060144.4 i/s - 1.24x  slower
              regexp:   9565124.4 i/s - 1.31x  slower
```

https://github.com/ruby/strscan/commit/ff2d7afa19
2024-10-26 18:44:15 +09:00
Nobuyoshi Nakada d6046bccb7 [ruby/strscan] Use C90 as far as supporting 2.6 or earlier
(https://github.com/ruby/strscan/pull/101)

https://github.com/ruby/strscan/commit/d31274f41b
2024-10-26 18:44:15 +09:00
Sutou Kouhei e7f06402dd Bump version 2024-10-26 18:44:15 +09:00
Sutou Kouhei 2ec2051f1f [ruby/fiddle] Don't use mkmf to generate dummy Makefile
(https://github.com/ruby/fiddle/pull/155)

GitHub: fix https://github.com/ruby/fiddle/pull/153

mkmf requires fileutils. JRuby doesn't like it.

https://github.com/ruby/fiddle/commit/df4bd21fc3
2024-10-26 18:44:15 +09:00