[ 
https://issues.apache.org/jira/browse/CASSANDRA-20162?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dmitry Konstantinov updated CASSANDRA-20162:
--------------------------------------------
    Description: 
Currently for memtable_allocation_type: offheap_objects we allocate memory to 
calculate dataSize() during a write to a memtable because we use default 
implementation of dataSize() which retrieves an object using value() method.
To avoid such memory allocation we can calculate data size directly for 
NativeCell and NativeClustering

test schema details:
{code:java}
CREATE TABLE memory_tests.test_table_text_0 (part_key text,clust_key 
text,value_0 text,value_1 text,value_2 text,value_3 text,value_4 text,value_5 
text,value_6 text,value_7 text,value_8 text,value_9 text,PRIMARY 
KEY(part_key,clust_key))
{code}
write query:
{code:java}
INSERT INTO memory_tests.test_table_text_0 
(part_key,clust_key,value_0,value_1,value_2,value_3,value_4,value_5,value_6,value_7,value_8,value_9)
 VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
{code}
changed settings:
{code:java}
memtable_allocation_type: offheap_objects

memtable:
  configurations:
    skiplist:
      class_name: SkipListMemtable
    trie:
      class_name: TrieMemtable
    default:
      inherits: trie // changed default to trie
{code}
JFR allocation report:

!jfr_allocation_profile.png|width=570!

!image-2024-12-23-09-53-27-226.png|width=570!

Memtable flushing logic also is affected:

!Cell_valueSize_usage_during_flushing.png|width=570!

  was:
Currently for memtable_allocation_type: offheap_objects we allocate memory to 
calculate dataSize() during a write to a memtable because we use default 
implementation of dataSize() which retrieves an object using value() method.
To avoid such memory allocation we can calculate data size directly for 
NativeCell and NativeClustering

test schema details:
{code:java}
CREATE TABLE memory_tests.test_table_text_0 (part_key text,clust_key 
text,value_0 text,value_1 text,value_2 text,value_3 text,value_4 text,value_5 
text,value_6 text,value_7 text,value_8 text,value_9 text,PRIMARY 
KEY(part_key,clust_key))
{code}
write query:
{code:java}
INSERT INTO memory_tests.test_table_text_0 
(part_key,clust_key,value_0,value_1,value_2,value_3,value_4,value_5,value_6,value_7,value_8,value_9)
 VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
{code}
changed settings:
{code:java}
memtable_allocation_type: offheap_objects

memtable:
  configurations:
    skiplist:
      class_name: SkipListMemtable
    trie:
      class_name: TrieMemtable
    default:
      inherits: trie // changed default to trie
{code}
JFR allocation report:

!jfr_allocation_profile.png|width=570!


!image-2024-12-23-09-53-27-226.png|width=570!

 !Cell_valueSize_usage_during_flushing.png! 


> Avoid memory allocation in NativeCell.valueSize() and 
> NativeClustering.dataSize()
> ---------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-20162
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-20162
>             Project: Apache Cassandra
>          Issue Type: Improvement
>          Components: Local/Memtable
>            Reporter: Dmitry Konstantinov
>            Assignee: Dmitry Konstantinov
>            Priority: Normal
>             Fix For: 5.0.x, 5.1
>
>         Attachments: Cell_valueSize_usage_during_flushing.png, 
> image-2024-12-23-09-53-27-226.png, jfr_allocation_profile.png
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Currently for memtable_allocation_type: offheap_objects we allocate memory to 
> calculate dataSize() during a write to a memtable because we use default 
> implementation of dataSize() which retrieves an object using value() method.
> To avoid such memory allocation we can calculate data size directly for 
> NativeCell and NativeClustering
> test schema details:
> {code:java}
> CREATE TABLE memory_tests.test_table_text_0 (part_key text,clust_key 
> text,value_0 text,value_1 text,value_2 text,value_3 text,value_4 text,value_5 
> text,value_6 text,value_7 text,value_8 text,value_9 text,PRIMARY 
> KEY(part_key,clust_key))
> {code}
> write query:
> {code:java}
> INSERT INTO memory_tests.test_table_text_0 
> (part_key,clust_key,value_0,value_1,value_2,value_3,value_4,value_5,value_6,value_7,value_8,value_9)
>  VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
> {code}
> changed settings:
> {code:java}
> memtable_allocation_type: offheap_objects
> memtable:
>   configurations:
>     skiplist:
>       class_name: SkipListMemtable
>     trie:
>       class_name: TrieMemtable
>     default:
>       inherits: trie // changed default to trie
> {code}
> JFR allocation report:
> !jfr_allocation_profile.png|width=570!
> !image-2024-12-23-09-53-27-226.png|width=570!
> Memtable flushing logic also is affected:
> !Cell_valueSize_usage_during_flushing.png|width=570!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to