[ 
https://issues.apache.org/jira/browse/OAK-5092?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15676724#comment-15676724
 ] 

Alex Parvulescu edited comment on OAK-5092 at 11/24/16 5:13 PM:
----------------------------------------------------------------

[~mduerig], attached v2 of the patch with some benchmarks included to capture 
size estimation, and the possibility to run on different platforms and compare 
results!

Anyone can run the benchmark with:
{code}
mvn clean test -Dtest=CacheWeightsTest -DCacheWeightsTest=true 
-Dtest.opts.memory=-Xmx2G
{code}
and the results are captured in 
{code}
cat 
target/surefire-reports/org.apache.jackrabbit.oak.segment.CacheWeightsTest-output.txt
{code}

this is what i have on my machine, I'm wondering if we should include {{java 
version}} and {{os info}} as a part of the test output so it's easier to track 
down.
I added a modest {{*warn*}} message in the case where the estimation is {{10%}} 
off from the heap measurement, just as a pointer into numbers we might need to 
look at.

{noformat}
:: Object[x1000000] Test
heap delta is       19438360, 19 bytes per item (4569624 -> 24007984)
estimated weight is 12000000, 12 bytes per item
*warn* estimated weight is over 10% smaller than heap based weight

:: String[x10000|256] Test
heap delta is       5308200, 530 bytes per item (3700584 -> 9008784)
estimated weight is 5600000, 560 bytes per item

:: RecordId[x1000000] Test
heap delta is       83864528, 83 bytes per item (3835296 -> 87699824)
estimated weight is 88000000, 88 bytes per item

:: RecordId[x1000000|GCInfo] Test
heap delta is       285215280, 285 bytes per item (3345832 -> 288561112)
estimated weight is 296000000, 296 bytes per item

:: SegmentId[x1000000] Test
heap delta is       59581704, 59 bytes per item (4561400 -> 64143104)
estimated weight is 60000000, 60 bytes per item

:: SegmentId[x1000000|GCInfo] Test
heap delta is       260000112, 260 bytes per item (3365528 -> 263365640)
estimated weight is 268000000, 268 bytes per item

:: Segment[x10000|5120] Test
heap delta is       53028776, 5302 bytes per item (3700168 -> 56728944)
estimated weight is 53240000, 5324 bytes per item

:: NodeCache[x1000000|PriorityCache<String, RecordId>] Test
heap delta is       425077464, 425 bytes per item (3366568 -> 428444032)
estimated weight is 503142144, 503 bytes per item
*warn* estimated weight is over 10% bigger than heap based weight

:: SegmentCache[x100MB|5120|Cache<SegmentId, Segment>] Test
heap delta is       53725480, 5372 bytes per item (3755992 -> 57481472)
estimated weight is 54920000, 5492 bytes per item

:: StringCache[x1000000|RecordCache<String, RecordId>] Test
heap delta is       560581848, 560 bytes per item (3449056 -> 564030904)
estimated weight is 567999999, 567 bytes per item
{noformat}

For background, one thing that is very different from platform to platform is 
the object header size (32b vs 64b). I chose to go with fixed {{12 bytes}}, but 
this is open for discussion if it makes sense to do light sampling and tweak 
based on jvm stats (In this case 12 seems the upper bound so a good fit in my 
view).



was (Author: alex.parvulescu):
[~mduerig], attached v2 of the patch with some benchmarks included to capture 
size estimation, and the possibility to run on different platforms and compare 
results!

Anyone can run the benchmark with:
{code}
mv clean test -Dtest=CacheWeightsTest -DCacheWeightsTest=true 
-Dtest.opts.memory=-Xmx2G
{code}
and the results are captured in 
{code}
cat 
target/surefire-reports/org.apache.jackrabbit.oak.segment.CacheWeightsTest-output.txt
{code}

this is what i have on my machine, I'm wondering if we should include {{java 
version}} and {{os info}} as a part of the test output so it's easier to track 
down.
I added a modest {{*warn*}} message in the case where the estimation is {{10%}} 
off from the heap measurement, just as a pointer into numbers we might need to 
look at.

{noformat}
:: Object[x1000000] Test
heap delta is       19438360, 19 bytes per item (4569624 -> 24007984)
estimated weight is 12000000, 12 bytes per item
*warn* estimated weight is over 10% smaller than heap based weight

:: String[x10000|256] Test
heap delta is       5308200, 530 bytes per item (3700584 -> 9008784)
estimated weight is 5600000, 560 bytes per item

:: RecordId[x1000000] Test
heap delta is       83864528, 83 bytes per item (3835296 -> 87699824)
estimated weight is 88000000, 88 bytes per item

:: RecordId[x1000000|GCInfo] Test
heap delta is       285215280, 285 bytes per item (3345832 -> 288561112)
estimated weight is 296000000, 296 bytes per item

:: SegmentId[x1000000] Test
heap delta is       59581704, 59 bytes per item (4561400 -> 64143104)
estimated weight is 60000000, 60 bytes per item

:: SegmentId[x1000000|GCInfo] Test
heap delta is       260000112, 260 bytes per item (3365528 -> 263365640)
estimated weight is 268000000, 268 bytes per item

:: Segment[x10000|5120] Test
heap delta is       53028776, 5302 bytes per item (3700168 -> 56728944)
estimated weight is 53240000, 5324 bytes per item

:: NodeCache[x1000000|PriorityCache<String, RecordId>] Test
heap delta is       425077464, 425 bytes per item (3366568 -> 428444032)
estimated weight is 503142144, 503 bytes per item
*warn* estimated weight is over 10% bigger than heap based weight

:: SegmentCache[x100MB|5120|Cache<SegmentId, Segment>] Test
heap delta is       53725480, 5372 bytes per item (3755992 -> 57481472)
estimated weight is 54920000, 5492 bytes per item

:: StringCache[x1000000|RecordCache<String, RecordId>] Test
heap delta is       560581848, 560 bytes per item (3449056 -> 564030904)
estimated weight is 567999999, 567 bytes per item
{noformat}

For background, one thing that is very different from platform to platform is 
the object header size (32b vs 64b). I chose to go with fixed {{12 bytes}}, but 
this is open for discussion if it makes sense to do light sampling and tweak 
based on jvm stats (In this case 12 seems the upper bound so a good fit in my 
view).


> Add support for weighing the cache entries in caches
> ----------------------------------------------------
>
>                 Key: OAK-5092
>                 URL: https://issues.apache.org/jira/browse/OAK-5092
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: segment-tar
>            Reporter: Alex Parvulescu
>            Assignee: Alex Parvulescu
>            Priority: Minor
>             Fix For: 1.6, 1.5.15
>
>         Attachments: OAK-5092-v2.patch, OAK-5092.patch
>
>
> Some of the current caches in {{segment-tar}} don't have support for 
> evaluation of current weight. I'd like to look into the {{PriorityCache}} and 
> {{RecordCache}} we use and possibly add something. this is based on initial 
> patch from OAK-4966.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to