[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12965628#action_12965628
 ] 

Thomas Koch commented on ZOOKEEPER-324:
---------------------------------------

Just to make the two different caching options perfectly clear.

Assume, we need to hold three different paths in memory:
"/hello/world" (12), "/hello/moon" (11), "/moon/raker" (11)

Option 1: Cache each path as a whole:
Results in three cache entries, one for each path and a total memory consume of 
12+11+11=34 characters.

Option 2: Cache each path part separately:
Results in four cache entries:
"hello", "world", "moon", "raker"
The memory consume for the cache is 3*5 + 4 = 19 characters.

I did not take into account the memory consume for the list structures in 
option 2 neither for the sorted tree map that holds the cache entries.

I could imagine that option 2 would pay out if you have znodes with many 
children.

> do not materialize strings in the server
> ----------------------------------------
>
>                 Key: ZOOKEEPER-324
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-324
>             Project: ZooKeeper
>          Issue Type: Improvement
>          Components: server
>            Reporter: Benjamin Reed
>
> We convert paths and authentication information to strings rather than byte[] 
> even though we could work just as well with byte[] for our needs since we 
> don't really interpret the strings. we are just doing basic pattern matching. 
> the only really string manipulations we do with paths is to look for '/', but 
> we could easily to that with byte[] since we use utf8 encoding for the 
> strings. by not materializing the strings we save time doing the 
> serializations and also space since most (almost all) of our strings are 
> ASCII and thus just one byte.
> we could probably get by without even changing the jute spec if we make the 
> generated classes check for a flag to see whether strings should be treated 
> as byte[] or String.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to