Merge: Use a Buffer in StringWriter
authorJean Privat <jean@pryen.org>
Thu, 16 Feb 2017 18:05:55 +0000 (13:05 -0500)
committerJean Privat <jean@pryen.org>
Thu, 16 Feb 2017 18:05:55 +0000 (13:05 -0500)
commitf63493dbcdd1df4863615465a4fbd15c7df5b74a
tree3388fa4bc17b9d2088875a9dd9dc900f41f5cbfd
parentefdce07e965f9ca2195c228860593e38beeda98c
parent2044dc24e19aa496cc7d7ac9f82e49af91a53208
Merge: Use a Buffer in StringWriter

This aims to replace the dirty #2367 and might solve the underlying problem in a better way by using a Buffer instead of an Array[String] in StringWriter.

With the following pseudo-oneliner

~~~nit
import json::string_parser
import json
print args.first.to_path.read_all.parse_json.as(not null).serialize_to_json(pretty=true, plain=true).length
~~~

And the file `nit/benchmarks/json/inputs/magic.json` a 54MB json file.

Before:

* User time (seconds): 18.02
* Elapsed (wall clock) time: 13.43
* Maximum resident set size (GB): 6.09

After:

* User time (seconds): 4.26 (-76%)
* Elapsed (wall clock) time: 3.98 (-70%)
* Maximum resident set size (GB): 1.16 (-80%)

Nevertheless, 1GB of ram to process a 54MB file is still huge.

Pull-Request: #2371
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>