summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
| * regenerate parserAaron Patterson2016-06-211-0/+2
| |
| * resize strings after parsingAaron Patterson2016-06-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The parser uses `rb_str_buf_new` to allocate new strings. `rb_str_buf_new` [has a minimum size of 128 and is not an embedded string](https://github.com/ruby/ruby/blob/9949407fd90c1c5bfe332141c75db995a9b867aa/string.c#L1119-L1135). This causes applications that parse JS to allocate extra memory when parsing short strings. For a real-world example, we can use the mime-types gem. The mime-types gem stores all mime types inside a JSON file and parses them when you require the gem. Here is a sample program: ```ruby require 'objspace' require 'mime-types' GC.start GC.start p ObjectSpace.memsize_of_all String ``` The example program loads the mime-types gem and outputs the total space used by all strings. Here are the results of the program before and after this patch: ** Before ** ``` [aaron@TC json (memuse)]$ ruby test.rb 5497494 [aaron@TC json (memuse)]$ ``` ** After ** ``` [aaron@TC json (memuse)]$ ruby -I lib:ext test.rb 3335862 [aaron@TC json (memuse)]$ ``` This change results in a ~40% reduction of memory use for strings in the mime-types gem. Thanks @matthewd for finding the problem, and @nobu for the patch!
* | Merge branch 'master' of github.com:flori/jsonFlorian Frank2016-06-212-0/+4
|\ \ | |/ |/|
| * Merge pull request #260 from tenderlove/memuseFlorian Frank2016-06-112-0/+4
| |\ | | | | | | resize strings after parsing
| | * regenerate parserAaron Patterson2016-06-111-0/+2
| | |
| | * resize strings after parsingAaron Patterson2016-06-111-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The parser uses `rb_str_buf_new` to allocate new strings. `rb_str_buf_new` [has a minimum size of 128 and is not an embedded string](https://github.com/ruby/ruby/blob/9949407fd90c1c5bfe332141c75db995a9b867aa/string.c#L1119-L1135). This causes applications that parse JS to allocate extra memory when parsing short strings. For a real-world example, we can use the mime-types gem. The mime-types gem stores all mime types inside a JSON file and parses them when you require the gem. Here is a sample program: ```ruby require 'objspace' require 'mime-types' GC.start GC.start p ObjectSpace.memsize_of_all String ``` The example program loads the mime-types gem and outputs the total space used by all strings. Here are the results of the program before and after this patch: ** Before ** ``` [aaron@TC json (memuse)]$ ruby test.rb 5497494 [aaron@TC json (memuse)]$ ``` ** After ** ``` [aaron@TC json (memuse)]$ ruby -I lib:ext test.rb 3335862 [aaron@TC json (memuse)]$ ``` This change results in a ~40% reduction of memory use for strings in the mime-types gem. Thanks @matthewd for finding the problem, and @nobu for the patch!
* | Merge more changes from ruby coreFlorian Frank2016-06-215-138/+171
| |
* | Easy diffingFlorian Frank2016-06-211-0/+11
| |
* | Adapt to ruby integer unificationFlorian Frank2016-06-212-3/+43
|/
* Merge pull request #283 from stomar/remove-commentsFlorian Frank2016-06-079-9/+0
|\ | | | | Remove comments from core classes in json/add
| * Remove comments from core classes in json/addMarcus Stollsteimer2016-04-259-9/+0
| |
* | Update rubies to test onFlorian Frank2016-06-071-1/+0
| |
* | Update rubies to test onFlorian Frank2016-06-071-3/+1
| |
* | Allow usage of simplecov with START_SIMPLECOV=1Florian Frank2016-06-072-0/+6
| |
* | Use ~> 2.0 test-unit that runs on 1.8 rubies as wellFlorian Frank2016-06-074-8/+8
| |
* | Move dependencies into gemspec filesFlorian Frank2016-06-074-9/+9
| |
* | Also build against 2.2.3Rebecca Skinner2016-06-071-73/+131
|\ \ | |/
| * Merge pull request #278 from zeroed/masterFlorian Frank2016-04-061-75/+133
| |\ | | | | | | Update README.md with formatting
| | * Update README.md with formattingEdoardo Rossi2016-04-061-75/+133
| |/
* | Move simplecov to test_helper.rbFlorian Frank2016-06-032-14/+2
| |
* | Treat ASCII_8BIT as UTF-8 by defaultFlorian Frank2016-06-037-97/+95
| |
* | Force ASCII 8bit to be UTF-8 and hope for the bestFlorian Frank2016-06-032-85/+93
| |
* | Only support newer Rubies e. g. EncodingFlorian Frank2016-06-034-114/+48
| |
* | Test common interfaceFlorian Frank2016-06-032-15/+27
| |
* | Use better name for this featureFlorian Frank2016-06-024-8/+8
| |
* | Remove quirks modeFlorian Frank2016-06-0219-619/+143
| |
* | Update documentation for RFC 7159 supportFlorian Frank2016-06-021-11/+0
| |
* | Change rfc referenceFlorian Frank2016-06-022-24/+6
| |
* | Support newer rubiesFlorian Frank2016-06-021-9/+1
| |
* | current RFC addedFlorian Frank2016-06-021-0/+899
| |
* | Allow usage of simplecov with START_SIMPLECOV=1Florian Frank2016-06-022-0/+6
| |
* | Declare encodingFlorian Frank2016-06-022-0/+3
|/
* Merge branch 'v1.8'Florian Frank2016-02-252-8/+0
|\
| * Use ~> 2.0 test-unit that runs on 1.8 rubies as wellFlorian Frank2016-02-254-8/+8
| |
| * Only test main 2.2 branchFlorian Frank2016-02-251-3/+0
| |
| * Move dependencies into gemspec filesFlorian Frank2016-02-255-5/+23
| |
* | Merge branch 'master' of github.com:flori/jsonFlorian Frank2016-02-250-0/+0
|\ \
| * \ Merge pull request #257 from sevenseacat/patch-1Florian Frank2015-08-211-0/+1
| |\ \ | | | | | | | | Also build against 2.2.3
| | * | Also build against 2.2.3Rebecca Skinner2015-08-211-0/+1
| |/ /
* | | Use ~> 2.0 test-unit that runs on 1.8 rubies as wellFlorian Frank2016-02-254-0/+21
| | |
* | | Merge branch 'v1.8'Florian Frank2016-02-2525-552/+121
|\ \ \ | | |/ | |/|
| * | Check for existence of #to_json method before callFlorian Frank2016-02-252-3/+11
| | |
| * | Avoid system stack errorFlorian Frank2016-02-251-1/+1
| | |
| * | Remove permutation dependencyFlorian Frank2016-02-254-41/+2
| | |
| * | Be goneā€¦Florian Frank2016-02-251-13/+0
| | |
| * | Attempt to switch jruby into 2.0 modeFlorian Frank2016-02-251-4/+3
| | |
| * | Add 2.3.0 for travis tetingFlorian Frank2016-02-251-0/+1
| | |
| * | Add missing testsFlorian Frank2016-02-251-0/+24
| | |
| * | Call OBJECT_HANDLER for objects without #to_jsonFlorian Frank2016-02-251-5/+8
| | | | | | | | | as a last-ditch effort.
| * | Correct CHANGESFlorian Frank2015-11-061-1/+2
| | |