RE: Is JCS slow ?

2004-01-21 Thread Spaggiari, Jean-Marc
I have found !

In LRUMemoryCache.java, in the verifyCache() method, for an unknown reson,
isDebugEnabled() is returning true. So, each time i call get() this method
is call and is verifying every element in the cache ... By modifying
verifyCache (if (true) return;) I have improved the speed as fast as the
hashtable.

Does anyone know what can enabled the debug mode ? Or if it is possible to
force the debug mode to false ?

Thanks.

JMS.

-Original Message-
From: Spaggiari, Jean-Marc [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 20, 2004 6:51 PM
To: '[EMAIL PROTECTED]'
Subject: Re: Is JCS slow ?


Running the same test as standalone in a main :

Avant le test
Tue Jan 20 18:47:30 EST 2004
Tue Jan 20 18:47:30 EST 2004
Tue Jan 20 18:47:30 EST 2004
Apres le test

:((( Now it's sure, it come from JBoss, but why and where ? :(


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is JCS slow ?

2004-01-21 Thread James Taylor
In your l4j config you probable want something like:

  category name=org.apache.jcs
priority value=info/
  /category
So that the jcs category will only log at info level (and 
isDebugEnabled will return false)

On Jan 21, 2004, at 12:58 PM, Spaggiari, Jean-Marc wrote:

I have found !

In LRUMemoryCache.java, in the verifyCache() method, for an unknown 
reson,
isDebugEnabled() is returning true. So, each time i call get() this 
method
is call and is verifying every element in the cache ... By modifying
verifyCache (if (true) return;) I have improved the speed as fast as 
the
hashtable.

Does anyone know what can enabled the debug mode ? Or if it is 
possible to
force the debug mode to false ?

Thanks.

JMS.

-Original Message-
From: Spaggiari, Jean-Marc [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 20, 2004 6:51 PM
To: '[EMAIL PROTECTED]'
Subject: Re: Is JCS slow ?
Running the same test as standalone in a main :

Avant le test
Tue Jan 20 18:47:30 EST 2004
Tue Jan 20 18:47:30 EST 2004
Tue Jan 20 18:47:30 EST 2004
Apres le test
:((( Now it's sure, it come from JBoss, but why and where ? :(

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: 
[EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: 
[EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Is JCS slow ?

2004-01-20 Thread Aaron Smuts
No, no one has ever asked if JCS is slow.  Something is definitely
wrong.  The cache is not significantly slower than a hashtable.  Can you
give more details about your configuration (i.e. the cache.ccf file) and
what you are caching.  

 -Original Message-
 From: Spaggiari, Jean-Marc [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, January 20, 2004 1:18 PM
 To: '[EMAIL PROTECTED]'
 Subject: Is JCS slow ?
 
 Hi all.
 
 Sorry if it's a question that you have always see, but i'm not able to
 look
 at the archives ...
 
 I'm using JCS in an application where i need to look 1600 time on the
 cache
 in a loop.
 
 The cache is empty at this time.
 
 For loop take about 160 seconds.
 
 Using hashtable instead of JCS take about 1s ...
 
 Where is my mistake ? Because I think I have do a mistake. It's not
 posible
 that JCS was 160 time slower than a Hashable ...
 
 An running JCS in a servlet on JBoss. Is it posible it come from here
?
 
 Thanks for your help.
 
 JMS.
 
 -
 To unsubscribe, e-mail:
[EMAIL PROTECTED]
 For additional commands, e-mail:
[EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Is JCS slow ?

2004-01-20 Thread Spaggiari, Jean-Marc
but DC is not used in my cache.cff file ... It's only here for remind, but I
have jxs.default= with nothing else ...

I'm applying the Aaron suggestion ... Wait a minute for the result ...

-Original Message-
From: James Taylor [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 20, 2004 4:02 PM
To: Turbine JCS Users List
Subject: Re: Is JCS slow ?


It looks like your memory caches are bounded at 1000 items (MaxObjects  
= 1000). Thus if you put 1600 items in the cache, and then look for any  
of the first 600 items, the cache will need to read them from disk,  
which takes time.

On Jan 20, 2004, at 3:14 PM, Spaggiari, Jean-Marc wrote:

 I am caching String (key) for Vector (value) ...

 But I found somethings. Y have a disk cache. By disable it, I can  
 improved
 my speed when cache is empty. But if I fill cache with 1600 items, it  
 take
 about 1 min for looking for 100 items inside :(

 Here is my cache.cff file, the code follow ...

 I'm trying with Hashtable, but I really don't like it :(

 # DEFAULT CACHE REGION

 jcs.default=
 jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribu 
 tes
 jcs.default.cacheattributes.MaxObjects=1000
 jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memor 
 y.lru
 .LRUMemoryCache

 # System CACHE REGION
 jcs.system.groupIdCache=
 jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.Composite 
 Cache
 Attributes
 jcs.system.groupIdCache.cacheattributes.MaxObjects=1
 jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs. 
 engin
 e.memory.lru.LRUMemoryCache

 # PRE-DEFINED CACHE REGIONS

 jcs.region.testCache1=
 jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCa 
 cheAt
 tributes
 jcs.region.testCache1.cacheattributes.MaxObjects=1000
 jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.en 
 gine.
 memory.lru.LRUMemoryCache
 jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
 jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
 jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=60

 jcs.region.HandlerDonnees=
 jcs.region.HandlerDonnees.cacheattributes=org.apache.jcs.engine.Composi 
 teCac
 heAttributes
 jcs.region.HandlerDonnees.cacheattributes.MaxObjects=1000
 jcs.region.HandlerDonnees.cacheattributes.MemoryCacheName=org.apache.jc 
 s.eng
 ine.memory.lru.LRUMemoryCache
 jcs.region.HandlerDonnees.cacheattributes.MaxMemoryIdleTimeSeconds=3600
 jcs.region.HandlerDonnees.cacheattributes.ShrinkerIntervalSeconds=60


 # AVAILABLE AUXILIARY CACHES
 jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCache 
 Facto
 ry
 jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.Index 
 edDis
 kCacheAttributes
 jcs.auxiliary.DC.attributes.DiskPath=/tmp



 Initialisation in constructor ... (Handler is different than  
 HandlerDonnees)

 private Handler()
 {
 try
 {
 //cache = JCS.getInstance(Handler);
 hashCache = new Hashtable ();
 }
 catch (Exception e)
 {
 // Handle cache region initialization failure
 e.printStackTrace();
 }
 }


 Reading the cache :

  Vector enCache = new Vector ();
  Vector aTraiter = new Vector ();
  try
  {
  System.out.println (new Date ());
  for (int indexMot = 0; indexMot  mots.size(); indexMot++)
  {
  if (indexMot % 100 == 0)
  System.out.println (indexMot +  =  + new  
 Date
 ());
  String mot = (String) mots.elementAt(indexMot);
  Vector liste = (Vector) hashCache.get(mot + suffix);
  if (liste == null)
  aTraiter.addElement (mot);
  else
  enCache.addElement (mot);
  }
  System.out.println (new Date ());
  }
  catch (Exception e)
  {
  e.printStackTrace();
  }


 Writing in cache :


try
{
hashCache.put(motATraiter + suffix,
 result.elementAt(indexATraiter));
}
catch (Exception e)
{
e.printStackTrace();
}


 -Original Message-
 From: Aaron Smuts [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, January 20, 2004 3:07 PM
 To: 'Turbine JCS Users List'
 Subject: RE: Is JCS slow ?


 No, no one has ever asked if JCS is slow.  Something is definitely
 wrong.  The cache is not significantly slower than a hashtable.  Can  
 you
 give more details about your configuration (i.e. the cache.ccf file)  
 and
 what you are caching.

 -Original Message-
 From: Spaggiari, Jean-Marc [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, January 20, 2004 1:18 PM
 To: '[EMAIL PROTECTED]'
 Subject: Is JCS slow ?

 Hi all

RE: Is JCS slow ?

2004-01-20 Thread Spaggiari, Jean-Marc
I have no message in log.

I going 2 time in this method. First time the cache is empty and i'm comming
with 1600 element, wich was stored un the cache, and the second time with
5500 elements. It's the second time the slowest one (1m/100 elements).

I have the tmp file with (about 4Mo).

Here is my new cache.cff

# DEFAULT CACHE REGION

jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru
.LRUMemoryCache

# System CACHE REGION
jcs.system.groupIdCache=
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCache
Attributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=1
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engin
e.memory.lru.LRUMemoryCache

# PRE-DEFINED CACHE REGIONS

jcs.region.HandlerDonnees=
jcs.region.HandlerDonnees.cacheattributes=org.apache.jcs.engine.CompositeCac
heAttributes
jcs.region.HandlerDonnees.cacheattributes.MaxObjects=1000
jcs.region.HandlerDonnees.cacheattributes.MemoryCacheName=org.apache.jcs.eng
ine.memory.lru.LRUMemoryCache
jcs.region.HandlerDonnees.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.HandlerDonnees.cacheattributes.ShrinkerIntervalSeconds=60

jcs.region.Handler=
jcs.region.Handler.cacheattributes=org.apache.jcs.engine.CompositeCacheAttri
butes
jcs.region.Handler.cacheattributes.MaxObjects=1
jcs.region.Handler.cacheattributes.UseMemoryShrinker=false
jcs.region.Handler.cacheattributes.MemoryCacheName=org.apache.jcs.engine.mem
ory.lru.LRUMemoryCache
jcs.region.Handler.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.Handler.cacheattributes.ShrinkerIntervalSeconds=60

Here is my new code :

private Handler()
{
try
{
cache = JCS.getInstance(Handler);
//hashCache = new Hashtable ();
}
catch (Exception e)
{
// Handle cache region initialization failure
e.printStackTrace();
}
}




Reading .

Vector enCache = new Vector ();
Vector aTraiter = new Vector ();
try
{
System.out.println (System.currentTimeMillis());
for (int indexMot = 0; indexMot  mots.size(); indexMot++)
{
if (indexMot % 100 == 0)
System.out.println (indexMot +  =  +
System.currentTimeMillis());
String mot = (String) mots.elementAt(indexMot);
ArrayList liste = (ArrayList) cache.get(mot + suffix);
if (liste == null)
aTraiter.addElement (mot);
else
enCache.addElement (mot);
}
System.out.println (System.currentTimeMillis());
}
catch (Exception e)
{
e.printStackTrace();
}



Writting ...

try
{
// On ajout un caractere à la fin car le cache n'aime pas
// certains caracteres spéciaux à la fin... La, on est sur.
cache.put(motATraiter + suffix, result.elementAt(indexATraiter));
}
catch (Exception e)
{
e.printStackTrace();
}


And the output ...

0 = 1074632894084
100 = 1074632911838
200 = 1074632928444
300 = 1074632944970
400 = 1074632961469

(around 16s per 100 elements ... less than 1s with hashtable)

But I have 8 line in log for each element read : 

2004-01-20 16:10:43,702 DEBUG [org.apache.jcs.engine.control.CompositeCache]
Handler - Miss
2004-01-20 16:10:43,702 DEBUG [org.apache.jcs.engine.control.CompositeCache]
get: key = Clinically, localOnly = false
2004-01-20 16:10:43,702 DEBUG
[org.apache.jcs.engine.memory.lru.LRUMemoryCache] getting item from cache
Handler for key Clinically_
2004-01-20 16:10:43,702 DEBUG
[org.apache.jcs.engine.memory.lru.LRUMemoryCache] Handler: LRUMemoryCache
miss for Clinically_
2004-01-20 16:10:43,702 DEBUG
[org.apache.jcs.engine.memory.lru.LRUMemoryCache] verifycache[Handler]:
mapContains 1635 elements, linked list contains 1635 elements
2004-01-20 16:10:43,702 DEBUG
[org.apache.jcs.engine.memory.lru.LRUMemoryCache] verifycache: checking
linked list by key
2004-01-20 16:10:43,703 DEBUG
[org.apache.jcs.engine.memory.lru.LRUMemoryCache] verifycache: checking
linked list by value
2004-01-20 16:10:43,784 DEBUG
[org.apache.jcs.engine.memory.lru.LRUMemoryCache] verifycache: checking via
keysets!
2004-01-20 16:10:43,872 DEBUG [org.apache.jcs.engine.control.CompositeCache]
Handler - Miss

Maybe it's comming from here ? How can I disable the log ? Is it maybe JBoss
who activate this ?

-Original Message-
From: Aaron Smuts [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 20, 2004 3:43 PM
To: 'Turbine JCS Users List'
Subject: RE: Is JCS slow ?


I'm not sure what is going on.  Are you getting any errors in the logs?

Your test will be off if you call the slow Date(), over and over again
in System.out.println (new

Re: Is JCS slow ?

2004-01-20 Thread James Taylor
But I have 8 line in log for each element read :
Maybe it's comming from here ? How can I disable the log ? Is it maybe 
JBoss
who activate this ?
Oh my yes, 8 lines of output per element will slow things down plenty. 
You need to turn the log4j log level for the jcs classes up to INFO or 
WARN. Yes, JBoss is probably initializing log4j, I unfortunately don't 
know where it keeps the config though. 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Is JCS slow ?

2004-01-20 Thread Spaggiari, Jean-Marc
Running the same test as standalone in a main :

Avant le test
Tue Jan 20 18:47:30 EST 2004
Tue Jan 20 18:47:30 EST 2004
Tue Jan 20 18:47:30 EST 2004
Apres le test

:((( Now it's sure, it come from JBoss, but why and where ? :(


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]