summaryrefslogtreecommitdiff
path: root/ext/json
AgeCommit message (Collapse)Author
2 daysSync ruby/jsonJean Boussier
Fix: https://github.com/ruby/json/issues/796 Notes: Merged: https://github.com/ruby/ruby/pull/13227
3 days[ruby/json] Remove explicit include of extconf.hJean Boussier
https://github.com/ruby/json/commit/6b059900de .
3 days[ruby/json] Fix --with-static-linked-ext buildsJean Boussier
https://github.com/ruby/json/commit/d7d60cccb0
3 days[ruby/json] Fix i686 buildsJean Boussier
We should test compilation with `-msse2` because we need to test with whatever arguments Ruby will be compiled with. https://github.com/ruby/json/commit/0a871365db
3 days[ruby/json] SIMD: Match control char and double quote in one passJean Boussier
`c < 32 || c == 34` is equivalent to `c ^ 2 < 33`. Found in: https://lemire.me/blog/2025/04/13/detect-control-characters-quotes-and-backslashes-efficiently-using-swar/ The gain seem mostly present on micro-benchmark, and even there aren't very consistent, but it's never slower. ``` == Encoding long string (124001 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 5.295k i/100ms Calculating ------------------------------------- after 55.796k (± 3.4%) i/s (17.92 μs/i) - 280.635k in 5.035690s Comparison: before: 49840.7 i/s after: 55795.8 i/s - 1.12x faster ``` https://github.com/ruby/json/commit/034c5debd8
3 daysUpdate ext/json/generator/dependJean Boussier
3 days[ruby/json] Introduce ARM Neon and SSE2 SIMD.Scott Myron
(https://github.com/ruby/json/pull/743) See the pull request for the long development history: https://github.com/ruby/json/pull/743 ``` == Encoding activitypub.json (52595 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 2.913k i/100ms Calculating ------------------------------------- after 29.377k (± 2.0%) i/s (34.04 μs/i) - 148.563k in 5.059169s Comparison: before: 23314.1 i/s after: 29377.3 i/s - 1.26x faster == Encoding citm_catalog.json (500298 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 152.000 i/100ms Calculating ------------------------------------- after 1.569k (± 0.8%) i/s (637.49 μs/i) - 7.904k in 5.039001s Comparison: before: 1485.6 i/s after: 1568.7 i/s - 1.06x faster == Encoding twitter.json (466906 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 309.000 i/100ms Calculating ------------------------------------- after 3.115k (± 3.1%) i/s (321.01 μs/i) - 15.759k in 5.063776s Comparison: before: 2508.3 i/s after: 3115.2 i/s - 1.24x faster ``` https://github.com/ruby/json/commit/49003523da
3 days[ruby/json] Use RB_TYPE_PJean Boussier
https://github.com/ruby/json/commit/b14250f1da
3 days[ruby/json] Handle non-string keys returning immediate values via `to_s`Jean Boussier
We can't directly call `RBASIC_CLASS` as the return value of `to_s` may be an immediate. https://github.com/ruby/json/commit/12dc394d11
3 days[ruby/json] Release 2.11.3Jean Boussier
https://github.com/ruby/json/commit/3e025f76d7
3 days[ruby/json] Stop caching the generator state pointerJean Boussier
Fix: https://github.com/ruby/json/issues/790 If we end up calling something that spills the state on the heap, the pointer we received is outdated and may be out of sync. https://github.com/ruby/json/commit/2ffa4ea46b
8 days[ruby/json] Release 2.11.2Jean Boussier
https://github.com/ruby/json/commit/c985e8c6ea
8 days[ruby/json] Bring back JSON::PRETTY_STATE_PROTOTYPE with a deprecationJean Boussier
Fix: https://github.com/ruby/json/issues/788 `multi_json` rely on it, even though it was never documented as public API. Bringing it back as a method so it can emit a deprecation warning. https://github.com/ruby/json/commit/123121bba2
8 days[ruby/json] Release 2.11.1Jean Boussier
https://github.com/ruby/json/commit/84443e881d
8 days[ruby/json] Bring back the numerous deprecated aliasJean Boussier
This time with explicit deprecation warnings. https://github.com/ruby/json/commit/0dee9bdad9
8 days[ruby/json] Release 2.11.0Jean Boussier
https://github.com/ruby/json/commit/a6949f8656
11 days[ruby/json] Get rid of unused CircularDatastructure classJean Boussier
https://github.com/ruby/json/commit/92beca8032
2025-04-15[ruby/json] Cleanup Kernel#JSONJean Boussier
https://github.com/ruby/json/commit/573ebdca89
2025-04-15[ruby/json] Deprecate Kernel#j and Kernel#jjJean Boussier
https://github.com/ruby/json/commit/27155b6500
2025-04-15[ruby/json] Get rid of JSONError.wrapJean Boussier
https://github.com/ruby/json/commit/3e7e661ef5
2025-04-15[ruby/json] Don't create custom NaN and Infinity objects.Jean Boussier
https://github.com/ruby/json/commit/ff8e18392d
2025-04-09[ruby/json] Cleanup jeaiii-ltoa to not need pragmasJean Boussier
https://github.com/ruby/json/commit/97f2924d0a
2025-04-09[ruby/json] Suppress -Wunknown-pragmas warningsNobuyoshi Nakada
https://github.com/ruby/json/commit/97f47d1cfd
2025-03-28[ruby/json] Move `create_addtions` logic in Ruby.Jean Boussier
By leveraging the `on_load` callback we can move all this logic out of the parser. Which mean we no longer have to duplicate that logic in both parser and that we'll later be able to extract it entirely from the gem. https://github.com/ruby/json/commit/f411ddf1ce Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] JSON.load invoke the proc callback directly from the parser.Jean Boussier
And substitute the return value like `Marshal.load` doesm which I can only assume was the intent. This also open the door to re-implement all the `create_addition` logic in `json/common.rb`. https://github.com/ruby/json/commit/73d2137fd3 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Remove more dead codeJean Boussier
https://github.com/ruby/json/commit/eda239ad34 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Remove `Class#json_creatable?` monkey patch.Jean Boussier
https://github.com/ruby/json/commit/1ca7efed1f Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Get rid of JSON::NOT_SETJean Boussier
https://github.com/ruby/json/commit/760d922265 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Remove outdated JSON.iconvJean Boussier
https://github.com/ruby/json/commit/3de8702354 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Cleanup JSON.pretty_generateJean Boussier
https://github.com/ruby/json/commit/01c47a0555 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Deprecate `JSON.fast_generate`Jean Boussier
https://github.com/ruby/json/commit/6508455d82 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-27Get rid of SAFE_STATE_PROTOTYPEJean Boussier
It was only used by JRuby and TruffleRuby to call `SAFE_STATE_PROTOTYPE.dup` instead of `State.new` which isn't an worthy optimization. Notes: Merged: https://github.com/ruby/ruby/pull/12994
2025-03-27Refactor jeaiii-ltoa.hJean Boussier
Some relatively minor change to make the library more in line with the gem. Some renaming, etc. Notes: Merged: https://github.com/ruby/ruby/pull/12994
2025-03-27Update ext/json/generator/dependHiroshi SHIBATA
2025-03-27Removed trailing spacesHiroshi SHIBATA
2025-03-27Faster integer formattingeno
This commit provides an alternative implementation for a long → decimal conversion. The main difference is that it uses an algorithm pulled from https://github.com/jeaiii/itoa. The source there is C++, it was converted by hand to C for inclusion with this gem. jeaiii's algorithm is covered by the MIT License, see source code. On addition this version now also generates the string directly into the fbuffer, foregoing the need to run a separate memory copy. As a result, I see a speedup of 32% on Apple Silicon M1 for an integer set of benchmarks.
2025-03-27[ruby/json] Remove unused `FAST_STATE_PROTOTYPE` and `PRETTY_STATE_PROTOTYPE`Jean Boussier
https://github.com/ruby/json/commit/18e5c3c67c
2025-03-27[ruby/json] Remove `unparse` and `restore` aliases.Jean Boussier
These were deprecated 16 years ago. https://github.com/ruby/json/commit/a88d825a91
2025-03-27[ruby/json] Deprecate all `*_default_options`Jean Boussier
Globally changing the behavior of the library is a bad idea, as many different libraries may rely on `json` and may not expect it and likely never tested that a different default config works for them. If you need to change the behavior of JSON, it's best to do it only locally, and not globally. In addition the new `JSON::Coder` interface is much more suited for that. Another reason for the deprecation is that it's impossible to make `JSON.load` and `JSON.dump` Ractor-safe with such API. https://github.com/ruby/json/commit/172762c6e4
2025-03-24Update ext/json/generator/dependHiroshi SHIBATA
2025-03-24Removed trailing spaceHiroshi SHIBATA
2025-03-24Reorganize `fpconv` vendoringJean Boussier
Make it a single file and declare the dependency.
2025-03-24[ruby/json] Extends license descriptioneno
https://github.com/ruby/json/commit/cce3d1f6c1
2025-03-24[ruby/json] Adjust fpconv to add ".0" to integerseno
Adds a test case fix https://github.com/ruby/json/commit/fa5bdf87cb
2025-03-24[ruby/json] Faster float formattingeno
This commit provides an alternative implementation for a float → decimal conversion. It integrates a C implementation of Fabian Loitsch's Grisu-algorithm [[pdf]](http://florian.loitsch.com/publications/dtoa-pldi2010.pdf), extracted from https://github.com/night-shift/fpconv. The relevant files are added in this PR, they are, as is all of https://github.com/night-shift/fpconv, available under a MIT License. As a result, I see a speedup of 900% on Apple Silicon M1 for a float set of benchmarks. floats don't have a single correct string representation: a float like `1000.0` can be represented as "1000", "1e3", "1000.0" (and more). The Grisu algorithm converts floating point numbers to an optimal decimal string representation without loss of precision. As a result, a float that is exactly an integer (like `Float(10)`) will be converted by that algorithm into `"10"`. While technically correct – the JSON format treats floats and integers identically –, this differs from the current behaviour of the `"json"` gem. To address this, the integration checks for that case, and explicitely adds a ".0" suffix in those cases. This is sufficient to meet all existing tests; there is, however, a chance that the current implementation and this implementation occasionally encode floats differently. ``` == Encoding floats (4179311 bytes) ruby 3.4.1 (2024-12-25 revision https://github.com/ruby/json/commit/48d4efcb85) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- json (local) 4.000 i/100ms Calculating ------------------------------------- json (local) 46.046 (± 2.2%) i/s (21.72 ms/i) - 232.000 in 5.039611s Normalize to 2090234 byte == Encoding floats (4179242 bytes) ruby 3.4.1 (2024-12-25 revision https://github.com/ruby/json/commit/48d4efcb85) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- json (2.10.2) 1.000 i/100ms Calculating ------------------------------------- json (2.10.2) 4.614 (± 0.0%) i/s (216.74 ms/i) - 24.000 in 5.201871s ``` These benchmarks are run via a script ([link](https://gist.github.com/radiospiel/04019402726a28b31616df3d0c17bd1c)) which is based on the gem's `benchmark/encoder.rb` file. There are probably better ways to run benchmarks :) My version allows to combine multiple test cases into a single one. The `dumps` benchmark, which covers the JSON files in `benchmark/data/*.json` – with the exception of `canada.json` – , reported a minor speedup within statistical uncertainty. https://github.com/ruby/json/commit/7d77415108
2025-03-13[ruby/json] Release 2.10.2Jean Boussier
https://github.com/ruby/json/commit/350c1fd154
2025-03-13[ruby/json] Fix potential out of bound read in `json_string_unescape`.Jean Boussier
https://github.com/ruby/json/commit/cf242d89a0
2025-03-12[ruby/json] Raise a ParserError on all incomplete unicode escape sequence.Jean Boussier
This was the behavior until `2.10.0` unadvertently changed it. `"\u1"` would raise, but `"\u1zzz"` wouldn't. https://github.com/ruby/json/commit/7d0637b9e6
2025-03-06[ruby/json] Fix JSON::GeneratorError#detailed_message with Ruby < 3.2Rahim Packir Saibo
https://github.com/ruby/json/commit/2e015ff839
2025-02-27[ruby/json] Ensure parser error snippets are valid UTF-8Jean Boussier
Fix: https://github.com/ruby/json/issues/755 Error messages now include a snippet of the document that doesn't parse to help locate the issue, however the way it was done wasn't UTF-8 aware, and it could result in exception messages with truncated characters. It would be nice to go a bit farther and actually support codepoints, but it's a lot of complexity to do it in C, perhaps if we move that logic to Ruby given it's not a performance sensitive codepath. https://github.com/ruby/json/commit/e144793b72