Merge: Lighter strings
authorJean Privat <jean@pryen.org>
Wed, 29 Jun 2016 13:57:48 +0000 (09:57 -0400)
committerJean Privat <jean@pryen.org>
Wed, 29 Jun 2016 13:57:48 +0000 (09:57 -0400)
This is an attempt to make text variants substantially lighter by adding cost to certain rare operations.
With this PR:

* `to_cstring` is not cached anymore, this induces more freedom on the FFI-side of things since the copy will be done on site, therefore the `char*` is now mutable on this side.
* `chars` and `bytes` are not attributes anymore, since they are only seldom used, they brought too much of a weight to the string envelope to justify such a spatial overhead
* the `is_dirty` flag was also removed from `FlatBuffer` since it no longer served any purpose
* the `flat_cache_last_pos` attribute is also removed from `Concat` and replaced by a direct access to the length of the underlying cached flat string

The sum of these removals make the envelope of a string lighter, from 104 bytes to 56 bytes.
This proves effective to reduce spatial use and (theoretically) reduces the pressure put on the garbage collector as well as improve caching (64 bytes per line, now a string envelope should fit in completely !).

As an example, passing the JSON parser on a 100 Mio string gives a memory use of:

* Before: 945 Mio
* After: 810 Mio

Pull-Request: #2183
Reviewed-by: Jean Privat <jean@pryen.org>


Trivial merge