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

Rearrange fields of ecma_property_t to be naturally aligned. #904

Closed
wants to merge 1 commit into from

Conversation

zherczeg
Copy link
Member

Rearrange fields of ecma_property_t to be naturally aligned. Packed attribute and extension keywords are removed. The standard approach reduced the binary size by 2K.

@zherczeg
Copy link
Member Author

                  Benchmark |                 Perf(+ is better)
                 3d-cube.js |   2.620s ->   2.660s :  -1.527%  (+-1.198%) : [-]
     access-binary-trees.js |   1.405s ->   1.370s :  +2.491%  (+-0.626%) : [+]
         access-fannkuch.js |   8.003s ->   7.952s :  +0.645%  (+-0.906%) : [≈]
            access-nbody.js |   3.103s ->   3.062s :  +1.342%  (+-0.824%) : [+]
bitops-3bit-bits-in-byte.js |   1.735s ->   1.745s :  -0.576%  (+-0.737%) : [≈]
     bitops-bits-in-byte.js |   2.663s ->   2.663s :  +0.000%  (+-0.814%) : [≈]
      bitops-bitwise-and.js |   3.647s ->   3.575s :  +1.965%  (+-0.441%) : [+]
   controlflow-recursive.js |   0.890s ->   0.892s :  -0.187%  (+-0.755%) : [≈]
              crypto-aes.js |   4.623s ->   4.612s :  +0.252%  (+-0.324%) : [≈]
              crypto-md5.js |  21.475s ->  20.520s :  +4.447%  (+-0.574%) : [+]
             crypto-sha1.js |   9.740s ->   9.293s :  +4.586%  (+-0.466%) : [+]
       date-format-tofte.js |   2.222s ->   2.152s :  +3.151%  (+-0.768%) : [+]
       date-format-xparb.js |   1.057s ->   1.052s :  +0.473%  (+-1.417%) : [≈]
             math-cordic.js |   3.017s ->   3.005s :  +0.387%  (+-0.535%) : [≈]
       math-partial-sums.js |   1.662s ->   1.657s :  +0.301%  (+-0.651%) : [≈]
      math-spectral-norm.js |   1.483s ->   1.507s :  -1.573%  (+-0.817%) : [-]
            string-fasta.js |   4.555s ->   4.485s :  +1.537%  (+-0.802%) : [+]
            Geometric mean: |                 Speed up: 1.058% (+-0.192%) : [+]

@LaszloLango LaszloLango added enhancement An improvement performance Affects performance binary size Affects binary size labels Feb 19, 2016
}
if (is_writable)
{
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_WRITABLE);
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't prop_p->flags |= (uint8_t) ECMA_PROPERTY_FLAG_xxx; work here and above? (It's a bit more compact.)

Actually, using a local variable to compose the flags and then copy that into prop_p->flags would be even nicer.

Copy link
Member Author

Choose a reason for hiding this comment

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

No :( c99 int conversion issue. I cannot say how much I hate it but only ++ and -- is accepted for types smaller than int. Everything else will be a warning. I even introduced macros for them in the parser.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, too bad. I was not aware of that limitation. OK then.

@zherczeg zherczeg force-pushed the rearrange_ecma_property_t branch 2 times, most recently from 5670f25 to e334809 Compare March 2, 2016 14:24
@zherczeg
Copy link
Member Author

zherczeg commented Mar 3, 2016

On Sunspider benchmark suite the currently used MaxRSS measuring script reported a large memory growth, and I decided to analyse the reason. I created a new valgrind tool called heimdall which reports all page ranges that are accessed by an application. Then I picked bitops-bitwise-and.js which memory footprint growth from 24K to 32K.

Here are the results:

Original:

Page size: 4096 bytes
  Modified pages: 0x3e000 - 0x3f000 [size: 4 Kb]
  Modified pages: 0x13e000 - 0x13f000 [size: 4 Kb]
  Modified pages: 0x17e000 - 0x180000 [size: 8 Kb]
  Modified pages: 0x27f000 - 0x280000 [size: 4 Kb]
  Modified pages: 0x7dbcb000 - 0x7dbcd000 [size: 8 Kb]
Total modified pages: 28 Kb

It turned out that the MaxRSS measuring script underestimated the real memory consumption. This is a known disadvantage of the script, since its precision depends on its sampling frequency.

After the patch:

Page size: 4096 bytes
  Modified pages: 0x3d000 - 0x3e000 [size: 4 Kb]
  Modified pages: 0x13d000 - 0x13f000 [size: 8 Kb]
  Modified pages: 0x17d000 - 0x17f000 [size: 8 Kb]
  Modified pages: 0x27e000 - 0x27f000 [size: 4 Kb]
  Modified pages: 0x7d96b000 - 0x7d96d000 [size: 8 Kb]
Total modified pages: 32 Kb

The growth is visible here as well.

However, the interesting part comes here. We change the page size to 1K (down from 4K) and measured these tests again:

Original:

Page size: 1024 bytes
  Modified pages: 0x3e000 - 0x3e400 [size: 1 Kb]
  Modified pages: 0x13e000 - 0x13e800 [size: 2 Kb]
  Modified pages: 0x17e000 - 0x17f400 [size: 5 Kb]
  Modified pages: 0x27f000 - 0x27f400 [size: 1 Kb]
  Modified pages: 0x7dbb3c00 - 0x7dbb4800 [size: 3 Kb]
Total modified pages: 12 Kb

After the patch:

Page size: 1024 bytes
  Modified pages: 0x3dc00 - 0x3e000 [size: 1 Kb]
  Modified pages: 0x13dc00 - 0x13e400 [size: 2 Kb]
  Modified pages: 0x17dc00 - 0x17f000 [size: 5 Kb]
  Modified pages: 0x27ec00 - 0x27f000 [size: 1 Kb]
  Modified pages: 0x7dbddc00 - 0x7dbde800 [size: 3 Kb]
Total modified pages: 12 Kb

We can notice that the memory consumption decreased to 12K, and that is not changed after the patch. The ranges are the same, although the base address with the patch is a bit lower than the original. So the page alignment increase the 12K memory consumption to 28-32K on Linux. A huge waste! Fortunately this does not affect the microcontrollers, our real targets, so I propose to land this patch.

…ttribute

and __extension__ keywords are removed. The standard approach reduced the binary
size by 2K.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
@zherczeg zherczeg force-pushed the rearrange_ecma_property_t branch from e334809 to cb2ad29 Compare March 3, 2016 12:52
@LaszloLango
Copy link
Contributor

LGTM

@zherczeg
Copy link
Member Author

zherczeg commented Mar 3, 2016

Landed in b8b587f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary size Affects binary size enhancement An improvement performance Affects performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants