[jboss-dev-forums] [Design of JBossCache] - Re: PojoCache uses a special node factory
ben.wang@jboss.com
do-not-reply at jboss.com
Tue Jan 9 21:55:43 EST 2007
"manik.surtani at jboss.com" wrote : you actually create:
|
| /_JBossInternal_/Bucket0-9/Node1
| /_JBossInternal_/Bucket0-9/Node2
| /_JBossInternal_/Bucket10-19/Node10
| /_JBossInternal_/Bucket10-19/Node11
|
| which will reduce the contention on _JBossInternal_ as a direct parent.
This will certainly help. Like you mentioned, this is problem more to the Cache usage itself. But it still will create contention though, and worse still can cause some lock timeout, say, when "/_JBossInternal_/Bucket0-9/Node1" tries to create another sub-node at "/_JBossInternal_/Bucket10-19/Node10", and meanwhile "/_JBossInternal_/Bucket10-19/Node11" tries to create a sub-node at "/_JBossInternal_/Bucket0-9/Node2" within the same transaction.
I am thinking another solution (in addition to the above option) is to allow user-specified bucket. For example, if you are using the core Cache, and you want to reduce lock contention and have the freedom to organize your fqn, then, the following will have high concurrency,
| // pre-create the node "/a", and "/b" first.
|
| // From thread 1
| loop(i=1:100)
| {
| cache.put("/a/1", k1, o1);
| }
|
|
| // From thread 2
| loop(i=1:100)
| {
| cache.put("/b/1", k1, o1);
| }
|
Granted not all use case can have this leeway to specify fqn like this. But when you can, this solution can perform well. So in similar token, I am thinking to allow an option for PojoCache user to pre-create the sub-tree in "__JBossInternal__". Let's take an example,
| pojoCache.attach("hr/joe", joe);
| pojoCache.attach("eng/ben", ben);
|
| //from thread 1
| loop(i=0:100)
| {
| pojoCache.attach("hr/joe", joe);
| }
|
| //from thread 2
| loop(i=0:100)
| {
| pojoCache.attach("eng/ben", ben);
| }
|
Now, when we map them into "__JBossInternal__", we will map as:
| cache.put("/__JBossInternal__/hr/joe, xxx)
|
and
| cache.put("/__JBossInternal__/eng/ben, xxx)
|
respectively. That is we will add the prefix such as "hr/joe" and "eng/ben" under the internal fqn. In this case, except during the pre-creation stage, there won't be write lock contention. Of course, we pay the penalty of creating extra fqn hierarchy.
Thought?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3999735#3999735
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3999735
More information about the jboss-dev-forums
mailing list