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)
commit07a9dcae5763e6f6c6d5b06f4c57f817259756b0
treee72c23f4b10cab88e4c4f57c21e02a64ba5132c2
parentd5b444a7e8309fee33423ec6bb6f580052b9d286
parent90e17cda85af56019c715f1b444f15cf1a2c78e7
Merge: Lighter strings

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>