Skip to content

Add 32 bit compressed pointer support. #1271

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

Merged
merged 1 commit into from
Sep 1, 2016

Conversation

zherczeg
Copy link
Member

This is a WIP patch, which will not be landed before the 1.0 release.

This patch extends compressed pointers to be 32 bit long when "--cpointer_32_bit on" is passed. After custom allocators will be added to Jerry, this will allow to use the full 32 bit address space on 32 bit systems at the cost of increased memory size. I will do some measurements to estimate this trade-of with the current allocator.

@LaszloLango LaszloLango added memory management Related to memory management or garbage collection development Feature implementation labels Aug 17, 2016
@zherczeg zherczeg force-pushed the cpointer_32 branch 2 times, most recently from 910da8c to 5600c4c Compare August 22, 2016 06:50
@zherczeg
Copy link
Member Author

Around 20% memory increase (9% RSS increase), a little perf gain (2%) and a small binary size reduction (200 byte).

Benchmark Heap (bytes) RSS (bytes) Perf (sec)
3d-cube.js 16376 -> 24568 : -50.024% 57344 -> 65536 : -14.286% 0.944 -> 0.929 : +1.550%
3d-raytrace.js 161152 -> 197488 : -22.548% 217088 -> 212992 : +1.887% 1.116 -> 1.157 : -3.704%
access-binary-trees.js 32760 -> 49136 : -49.988% 53248 -> 69632 : -30.769% 0.592 -> 0.549 : +7.289%
access-fannkuch.js 7608 -> 8184 : -7.571% 24576 -> 24576 : 0.000% 2.363 -> 2.330 : +1.409%
access-nbody.js 6688 -> 8176 : -22.249% 28672 -> 28672 : 0.000% 1.077 -> 1.058 : +1.752%
bitops-3bit-bits-in-byte.js 928 -> 1072 : -15.517% 16384 -> 20480 : -25.000% 0.591 -> 0.579 : +1.951%
bitops-bits-in-byte.js 880 -> 1032 : -17.273% 16384 -> 20480 : -25.000% 0.858 -> 0.853 : +0.591%
bitops-bitwise-and.js 568 -> 664 : -16.901% 16384 -> 16384 : 0.000% 0.934 -> 0.883 : +5.476%
bitops-nsieve-bits.js 138568 -> 175248 : -26.471% 155648 -> 192512 : -23.684% 1.788 -> 1.774 : +0.764%
controlflow-recursive.js 912 -> 1048 : -14.912% 94208 -> 98304 : -4.348% 0.399 -> 0.388 : +2.775%
crypto-aes.js 49176 -> 57376 : -16.675% 94208 -> 102400 : -8.696% 1.113 -> 1.096 : +1.502%
crypto-md5.js 139256 -> 172024 : -23.531% 163840 -> 208896 : -27.500% 0.738 -> 0.751 : -1.886%
crypto-sha1.js 90104 -> 106488 : -18.183% 110592 -> 126976 : -14.815% 0.705 -> 0.704 : +0.008%
date-format-tofte.js 16376 -> 16376 : 0.000% 40960 -> 40960 : 0.000% 0.864 -> 0.841 : +2.626%
date-format-xparb.js 16384 -> 24576 : -50.000% 49152 -> 53248 : -8.333% 0.470 -> 0.440 : +6.270%
math-cordic.js 2128 -> 2640 : -24.060% 20480 -> 20480 : 0.000% 1.345 -> 1.302 : +3.180%
math-partial-sums.js 1432 -> 1776 : -24.022% 16384 -> 20480 : -25.000% 0.708 -> 0.695 : +1.804%
math-spectral-norm.js 8184 -> 8176 : +0.098% 24576 -> 24576 : 0.000% 0.599 -> 0.581 : +3.107%
string-base64.js 92032 -> 93472 : -1.565% 143360 -> 139264 : +2.857% 2.054 -> 1.991 : +3.047%
string-fasta.js 16320 -> 16368 : -0.294% 32768 -> 32768 : 0.000% 1.402 -> 1.338 : +4.586%
Geometric mean: -19.174% -9.542% +2.237%

Binary sizes (bytes)
314e74f:156952
5600c4c:156724

@LaszloLango
Copy link
Contributor

Enable cpointer_32_bit by default (this will be removed after testing).

IMHO, we should add a new travis job and test this feature on every new commit.

@zherczeg
Copy link
Member Author

As you can see travis is failing, since you need a 32 bit system (travis is 64 bit by default). I dont have any idea how to test it.

jmem_cpointer_t next_property_cp; /**< next cpointer */
#endif /* JERRY_CPOINTER_32_BIT */
} ecma_property_header_t;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain this change? Why did you move the next cpointer on 32 bit?

Copy link
Member Author

@zherczeg zherczeg Aug 31, 2016

Choose a reason for hiding this comment

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

Because ECMA_PROPERTY_VALUE_PTR expects that the type fields are packed in a 4 byte word, which is followed by maximum of four value words. For 16 bit cpointers the next pointer can be squeezed in the last two bytes of the first word. This is not possible with 32 bit cpointers, where that 16 bit is unused.

@LaszloLango
Copy link
Contributor

The code looks good, but docs/04.INTERNALS.md should be updated.

@zherczeg
Copy link
Member Author

zherczeg commented Sep 1, 2016

Description added, patch updated.

@LaszloLango
Copy link
Contributor

LGTM

@@ -39,8 +39,6 @@
*/
#ifndef CONFIG_MEM_HEAP_AREA_SIZE
# define CONFIG_MEM_HEAP_AREA_SIZE (512 * 1024)
#elif CONFIG_MEM_HEAP_AREA_SIZE > (512 * 1024)
# error "Currently, maximum 512 kilobytes heap size is supported"
Copy link
Member

Choose a reason for hiding this comment

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

Removing this may be a bad idea, I think it would be better to add && !JERRY_CPOINTER_32_BIT to the condition instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Another assertion is added instead of it.

@dbatyai
Copy link
Member

dbatyai commented Sep 1, 2016

LGTM otherwise.

two_pow_mem_heap_offset_should_not_be_less_than_mem_heap_size);
#ifndef JERRY_CPOINTER_32_BIT
JERRY_STATIC_ASSERT (((UINT16_MAX + 1) << JMEM_ALIGNMENT_LOG) >= JMEM_HEAP_SIZE,
maximum_heap_size_for_16_bit_compressed_pointers_is_512K);
Copy link
Member Author

Choose a reason for hiding this comment

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

Here.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. Okay.

@dbatyai
Copy link
Member

dbatyai commented Sep 1, 2016

LGTM

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Feature implementation memory management Related to memory management or garbage collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants