Clarification about CSM implementation

View: New views
7 Messages — Rating Filter:   Alert me  

Clarification about CSM implementation

by Sergio Bossa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys,

I'd like to a have a clarification about the ConcurrentStringMap (CSM)
implementation and behavior in a well-partitioned scenario.

Let's say I have a CSM using String objects for both keys and values:
the map may have thousand (maybe million) values, but every L1 node
reads/writes only a subset of all values, thanks to some kind of
partitioning strategy.
Now my questions:
- Are *all* values kept in memory on *every* L1 node, even if each
node reads/writes only a subset of?
- Does the L1 node eventually flush unused values to the L2, or does
it risk to go out of memory?
- Given that String are literal values and seems not to be partially
loaded, would it be different if string values were wrapped into some
kind of holder object?

Thanks,
Cheers,

Sergio B.

--
Sergio Bossa
Software Passionate and Open Source Enthusiast.
Blog : http://sbtourist.blogspot.com
Pro-Netics : http://www.pronetics.it
Sourcesense : http://www.sourcesense.com
_______________________________________________
tc-dev mailing list
tc-dev@...
http://lists.terracotta.org/mailman/listinfo/tc-dev

Re: Clarification about CSM implementation

by Alex Miller-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Answers inline below...

----- Original Message -----
From: "Sergio Bossa" <sergio.bossa@...>
To: "tc-dev" <tc-dev@...>
Sent: Sunday, May 17, 2009 10:47:12 AM GMT -06:00 US/Canada Central
Subject: [tc-dev] Clarification about CSM implementation

Hi guys,

I'd like to a have a clarification about the ConcurrentStringMap (CSM)
implementation and behavior in a well-partitioned scenario.

Let's say I have a CSM using String objects for both keys and values:
the map may have thousand (maybe million) values, but every L1 node
reads/writes only a subset of all values, thanks to some kind of
partitioning strategy.
Now my questions:
- Are *all* values kept in memory on *every* L1 node, even if each
node reads/writes only a subset of?

-> no, all *keys* are in-memory on every node, but just values that have been used on the node.

- Does the L1 node eventually flush unused values to the L2, or does
it risk to go out of memory?

-> yes, the L1 node will flush unused values.  

- Given that String are literal values and seems not to be partially
loaded, would it be different if string values were wrapped into some
kind of holder object?

-> csm works only with string keys as the key value is used to derive the lock name in a 1-1 mapping.  Discussions about other options to reduce memory or loosen this constraint are possible and ongoing.


Thanks,
Cheers,

Sergio B.

--
Sergio Bossa
Software Passionate and Open Source Enthusiast.
Blog : http://sbtourist.blogspot.com
Pro-Netics : http://www.pronetics.it
Sourcesense : http://www.sourcesense.com
_______________________________________________
tc-dev mailing list
tc-dev@...
http://lists.terracotta.org/mailman/listinfo/tc-dev
_______________________________________________
tc-dev mailing list
tc-dev@...
http://lists.terracotta.org/mailman/listinfo/tc-dev

Re: Clarification about CSM implementation

by Sergio Bossa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, May 17, 2009 at 10:52 PM, Alex Miller
<amiller@...> wrote:

> -> no, all *keys* are in-memory on every node, but just values that have been used on the node.
> -> yes, the L1 node will flush unused values.

That's great.
However, the "Clustered Data Structures Guide" is a bit misleading
about this point, in particular for this extract: "A data structure
with values that are all literals (a set which includes Java
primitives) is not partially loaded."

> -> csm works only with string keys as the key value is used to derive the lock name in a 1-1 mapping.  Discussions about other options to reduce memory or
> loosen this constraint are possible and ongoing.

That's ok, I was referring to CSM values, not keys, sorry if that
wasn't clear enough.
However, if CSM "partially loads" its string values, that's perfect
for my use case.

Cheers,

Sergio B.

--
Sergio Bossa
Software Passionate and Open Source Enthusiast.
Blog : http://sbtourist.blogspot.com
Pro-Netics : http://www.pronetics.it
Sourcesense : http://www.sourcesense.com
_______________________________________________
tc-dev mailing list
tc-dev@...
http://lists.terracotta.org/mailman/listinfo/tc-dev

Re: Clarification about CSM implementation

by teck-terracotta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Terracotta literals (which includes String) are never partially loaded no
matter where they occur (keys, values, fields, etc). A CSM<String,String>
will have no partial loading behaviour unfortunately.

> -----Original Message-----
> From: tc-dev-bounces@... [mailto:tc-dev-
> bounces@...] On Behalf Of Sergio Bossa
> Sent: Monday, May 18, 2009 7:13 AM
> To: tc-dev@...
> Subject: Re: [tc-dev] Clarification about CSM implementation
>
> On Sun, May 17, 2009 at 10:52 PM, Alex Miller
> <amiller@...> wrote:
>
> > -> no, all *keys* are in-memory on every node, but just values that
have

> been used on the node.
> > -> yes, the L1 node will flush unused values.
>
> That's great.
> However, the "Clustered Data Structures Guide" is a bit misleading
> about this point, in particular for this extract: "A data structure
> with values that are all literals (a set which includes Java
> primitives) is not partially loaded."
>
> > -> csm works only with string keys as the key value is used to derive
> the lock name in a 1-1 mapping.  Discussions about other options to
reduce

> memory or
> > loosen this constraint are possible and ongoing.
>
> That's ok, I was referring to CSM values, not keys, sorry if that
> wasn't clear enough.
> However, if CSM "partially loads" its string values, that's perfect
> for my use case.
>
> Cheers,
>
> Sergio B.
>
> --
> Sergio Bossa
> Software Passionate and Open Source Enthusiast.
> Blog : http://sbtourist.blogspot.com
> Pro-Netics : http://www.pronetics.it
> Sourcesense : http://www.sourcesense.com
> _______________________________________________
> tc-dev mailing list
> tc-dev@...
> http://lists.terracotta.org/mailman/listinfo/tc-dev
_______________________________________________
tc-dev mailing list
tc-dev@...
http://lists.terracotta.org/mailman/listinfo/tc-dev

Re: Clarification about CSM implementation

by Sergio Bossa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So let me restate: if I have a CSM<String, String> with say 100k  
values, and a given L1 node which uses always the same subset of say  
10k values, will other values be held in the L1 heap even if unused?  
Will they eventually be flushed?

Thanks!

Sergio Bossa
Sent by iPhone

Il giorno 18/mag/09, alle ore 19:27, "Tim Eck"  
<teck@...> ha scritto:

> Terracotta literals (which includes String) are never partially  
> loaded no
> matter where they occur (keys, values, fields, etc). A  
> CSM<String,String>
> will have no partial loading behaviour unfortunately.
>
>> -----Original Message-----
>> From: tc-dev-bounces@... [mailto:tc-dev-
>> bounces@...] On Behalf Of Sergio Bossa
>> Sent: Monday, May 18, 2009 7:13 AM
>> To: tc-dev@...
>> Subject: Re: [tc-dev] Clarification about CSM implementation
>>
>> On Sun, May 17, 2009 at 10:52 PM, Alex Miller
>> <amiller@...> wrote:
>>
>>> -> no, all *keys* are in-memory on every node, but just values that
> have
>> been used on the node.
>>> -> yes, the L1 node will flush unused values.
>>
>> That's great.
>> However, the "Clustered Data Structures Guide" is a bit misleading
>> about this point, in particular for this extract: "A data structure
>> with values that are all literals (a set which includes Java
>> primitives) is not partially loaded."
>>
>>> -> csm works only with string keys as the key value is used to  
>>> derive
>> the lock name in a 1-1 mapping.  Discussions about other options to
> reduce
>> memory or
>>> loosen this constraint are possible and ongoing.
>>
>> That's ok, I was referring to CSM values, not keys, sorry if that
>> wasn't clear enough.
>> However, if CSM "partially loads" its string values, that's perfect
>> for my use case.
>>
>> Cheers,
>>
>> Sergio B.
>>
>> --
>> Sergio Bossa
>> Software Passionate and Open Source Enthusiast.
>> Blog : http://sbtourist.blogspot.com
>> Pro-Netics : http://www.pronetics.it
>> Sourcesense : http://www.sourcesense.com
>> _______________________________________________
>> tc-dev mailing list
>> tc-dev@...
>> http://lists.terracotta.org/mailman/listinfo/tc-dev
> _______________________________________________
> tc-dev mailing list
> tc-dev@...
> http://lists.terracotta.org/mailman/listinfo/tc-dev
_______________________________________________
tc-dev mailing list
tc-dev@...
http://lists.terracotta.org/mailman/listinfo/tc-dev

Re: Clarification about CSM implementation

by teck-terracotta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

All 100k of the String keys and values (total 200k Strings) will be in
memory on any node that faults the CSM instance. The partitioned key usage
will not matter in this case (at least not with respect to heap usage, the
locks will still be perfectly partitioned). Hope this helps.

One way to workaround this would be to use a wrapper object for your
values. Introducing an extra shared object [the wrapper] isn't free by any
means but it is a means to shape heap usage.

> -----Original Message-----
> From: tc-dev-bounces@... [mailto:tc-dev-
> bounces@...] On Behalf Of Sergio Bossa
> Sent: Monday, May 18, 2009 1:54 PM
> To: tc-dev@...
> Cc: <tc-dev@...>
> Subject: Re: [tc-dev] Clarification about CSM implementation
>
> So let me restate: if I have a CSM<String, String> with say 100k
> values, and a given L1 node which uses always the same subset of say
> 10k values, will other values be held in the L1 heap even if unused?
> Will they eventually be flushed?
>
> Thanks!
>
> Sergio Bossa
> Sent by iPhone
>
> Il giorno 18/mag/09, alle ore 19:27, "Tim Eck"
> <teck@...> ha scritto:
>
> > Terracotta literals (which includes String) are never partially
> > loaded no
> > matter where they occur (keys, values, fields, etc). A
> > CSM<String,String>
> > will have no partial loading behaviour unfortunately.
> >
> >> -----Original Message-----
> >> From: tc-dev-bounces@... [mailto:tc-dev-
> >> bounces@...] On Behalf Of Sergio Bossa
> >> Sent: Monday, May 18, 2009 7:13 AM
> >> To: tc-dev@...
> >> Subject: Re: [tc-dev] Clarification about CSM implementation
> >>
> >> On Sun, May 17, 2009 at 10:52 PM, Alex Miller
> >> <amiller@...> wrote:
> >>
> >>> -> no, all *keys* are in-memory on every node, but just values that
> > have
> >> been used on the node.
> >>> -> yes, the L1 node will flush unused values.
> >>
> >> That's great.
> >> However, the "Clustered Data Structures Guide" is a bit misleading
> >> about this point, in particular for this extract: "A data structure
> >> with values that are all literals (a set which includes Java
> >> primitives) is not partially loaded."
> >>
> >>> -> csm works only with string keys as the key value is used to
> >>> derive
> >> the lock name in a 1-1 mapping.  Discussions about other options to
> > reduce
> >> memory or
> >>> loosen this constraint are possible and ongoing.
> >>
> >> That's ok, I was referring to CSM values, not keys, sorry if that
> >> wasn't clear enough.
> >> However, if CSM "partially loads" its string values, that's perfect
> >> for my use case.
> >>
> >> Cheers,
> >>
> >> Sergio B.
> >>
> >> --
> >> Sergio Bossa
> >> Software Passionate and Open Source Enthusiast.
> >> Blog : http://sbtourist.blogspot.com
> >> Pro-Netics : http://www.pronetics.it
> >> Sourcesense : http://www.sourcesense.com
> >> _______________________________________________
> >> tc-dev mailing list
> >> tc-dev@...
> >> http://lists.terracotta.org/mailman/listinfo/tc-dev
> > _______________________________________________
> > tc-dev mailing list
> > tc-dev@...
> > http://lists.terracotta.org/mailman/listinfo/tc-dev
> _______________________________________________
> tc-dev mailing list
> tc-dev@...
> http://lists.terracotta.org/mailman/listinfo/tc-dev
_______________________________________________
tc-dev mailing list
tc-dev@...
http://lists.terracotta.org/mailman/listinfo/tc-dev

Re: Clarification about CSM implementation

by Sergio Bossa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, May 19, 2009 at 6:40 PM, Tim Eck <teck@...> wrote:

> All 100k of the String keys and values (total 200k Strings) will be in
> memory on any node that faults the CSM instance. The partitioned key usage
> will not matter in this case (at least not with respect to heap usage, the
> locks will still be perfectly partitioned). Hope this helps.

Thanks for your clarifications!
Cheers,

Sergio B.

--
Sergio Bossa
Software Passionate and Open Source Enthusiast.
Blog : http://sbtourist.blogspot.com
Pro-Netics : http://www.pronetics.it
Sourcesense : http://www.sourcesense.com
_______________________________________________
tc-dev mailing list
tc-dev@...
http://lists.terracotta.org/mailman/listinfo/tc-dev