-
Notifications
You must be signed in to change notification settings - Fork 683
New Allocator and improved String handling. #874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
36906eb
to
387b6a8
Compare
Wow, nice improvement! |
@dbatyai, the following regression test fails: |
387b6a8
to
e572aaa
Compare
@LaszloLango, Thanks, the issue is fixed. |
e572aaa
to
3fe93ff
Compare
@dbatyai, could you rebase the patch to the current master? |
4026bb1
to
4c28c60
Compare
@LaszloLango, done. |
#endif /* !CONFIG_MEM_HEAP_AREA_SIZE */ | ||
|
||
/** | ||
* Desired limit of heap usage | ||
*/ | ||
#define CONFIG_MEM_HEAP_DESIRED_LIMIT (CONFIG_MEM_HEAP_AREA_SIZE / 32) | ||
#define CONFIG_MEM_HEAP_DESIRED_LIMIT (JERRY_MIN(CONFIG_MEM_HEAP_AREA_SIZE / 32, 8192)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'8192'?
@dbatyai, thanks for the update. Apart from several minor style issues the patch look good to me. :) |
b08f3c1
to
33d552a
Compare
@LaszloLango, I fixed the issues you mentioned. |
@dbatyai, could you check the following test262 test fails:
UPDATE: |
33d552a
to
d1b7ead
Compare
@LaszloLango, I checked the failures. It appears they were caused by an over-indexed array in |
#endif /* !CONFIG_MEM_HEAP_AREA_SIZE */ | ||
|
||
/** | ||
* Max heap usage limit | ||
*/ | ||
#define CONFIG_MEM_HEAP_MAX_LIMIT 8192 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It defines a maximum value for the heap limit. Heap limit is, as the name suggest, a limit of memory usage, and whenever the size of allocated memory since the previous limit would hit the next one, we would run garbage collection. The limit was previously set to HEAP_AREA_SIZE / 32 == 8192
. Because I increased the size of the heap, garbage collection became less frequent, so I added a maximum value. This way it wouldn't affect environments where the heap size is different.
Very nice patch |
LGTM after the ref count is restored to its old value. |
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
Patch is updated. |
This PR is the continuation of the work in #678. It was suggested there to use the recordset implementation to reduce wasted memory. I investigated this approach, but the results were rather dissapointing, as execution became almost two times slower on each test.
So, in order to reduce wasted memory while also gaining the performance benefit of using heap buffers, I experimented with a new allocator that can allocate blocks that are a multiple of 8 bytes.
Here are the results:
Memory usage increased slightly in most cases by a few hundred bytes, because of the removal of recordset, and the rework of the literal storage, but the total memory available also increased by around the same amount, because we no longer have to store bitmaps for memory regions, so this basically evens out.
On the other hand, strings that were previously stored in char_collections now use around 15% less memory in buffers, while also providing significant performance improvement.
It's worth noting, that we also require less intermediate buffers for manipulating strings.
When using --mem-stats, peak memory usage may seem to increase by a larger amount, than stated before, this is the result of garbage collection triggering differently with the new allocation scheme and the increased heap size.
It's also worth noting that the new allocator could also support separated heap regions, which I plan to investigate further, since it could be very useful in some cases. Also, the maximum memory size is now less constrained, although we are still limited to 512kB because of compressed pointers.