Skip to content
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

Add realloc function to jmem #2998

Merged
merged 1 commit into from
Aug 6, 2019
Merged

Conversation

dbatyai
Copy link
Member

@dbatyai dbatyai commented Aug 1, 2019

This patch extends jmem functionality by adding a realloc function.
This opens up other paths of optimization which can result in smaller
peak memory usage and faster execution times, due to not having to
duplicate memory when we need to extend blocks.

Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LaszloLango
Copy link
Contributor

This was previously proposed by @mmatyas in #2619

  1. Please refer his name as well.
  2. It did not have any gain back then. Why do you think this patch is an improvement? Any measurements or future plans with it?

@dbatyai
Copy link
Member Author

dbatyai commented Aug 4, 2019

@LaszloLango, the pull request was opened by mmatyas, but the patch was supplied by me.

I don't really know where do you get the assumption that it didn't have any gain back then, but it doesn't matter. There are several builtins that are bottlenecked by ecma_concat_strings: String.replace, Array.join, JSON.stringify just to name a few. These produce exponentially worse runtimes with larger inputs, due to how ecma_concat_strings copies the string data.

Coincidentally, these are also the builtins methods that are not very well tested by sunspider, or at least by the few tests we were running at the time, so these issues don't show up, but they are there. If we take a look at the v8 benchmarks, we see the same trend, among other things, but I'd rather not get into the details.

Going a bit further, there are engine internals that could be improved, for example ecma_collections, and regexp bytecode reallocation. There are also plans for optimizing Arrays.

Overall, I believe this to be sufficient to justify this change.

@LaszloLango
Copy link
Contributor

@dbatyai thanks for clarifying this for me. I don't know when I will have time to review it in details, but I don't want to block this PR. If any reviewer gives a second approval then it could be merged.

@rerobika rerobika added the memory management Related to memory management or garbage collection label Aug 6, 2019
Copy link
Contributor

@galpeter galpeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

This patch extends jmem functionality by adding a realloc function.
This opens up other paths of optimization which can result in smaller
peak memory usage and faster execution times, due to not having to
duplicate memory when we need to extend blocks.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]
@rerobika rerobika merged commit 566e814 into jerryscript-project:master Aug 6, 2019
@dbatyai dbatyai deleted the realloc branch August 27, 2019 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
memory management Related to memory management or garbage collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants