[CDO] First pass through resource contents slow? [message #1749264] |
Sun, 04 December 2016 23:12 |
Reinhold Usolf Messages: 18 Registered: December 2016 |
Junior Member |
|
|
Hi,
I have a project here that uses CDO (latest 4.5 release) with a MySQL database as storage. All components (client, server, storage) run on the same host. The client does the following actions more or less periodically:
1. Open transaction
2. Find a particular resource (always the same)
3. Pass through the contents of the resource several times (checking various things)
4. Add a new object to its contents
5. Commit
I have noticed that the first pass in a transaction through the contents of a CDOResource is very slow. For a resource with 5000 objects this loop takes nearly 1 second:
for(EObject o : resource.getContents()) {
... some simple stuff inside the loop, for example checking the type of each "o"...
}
Subsequent passes (i.e. for-loops) through the contents only take a few milliseconds, as long as they happen in the same transaction.
Is this the expected behavior? I don't see any database read-accesses during the various passes, not even across transactions, which means the data is cached in memory, correct?
As you can probably see, I am completely new to CDO. Please don't hesitate to shout for more information
Thanks,
ru
|
|
|
|
|
|
Re: [CDO] First pass through resource contents slow? [message #1749399 is a reply to message #1749398] |
Tue, 06 December 2016 09:34 |
Reinhold Usolf Messages: 18 Registered: December 2016 |
Junior Member |
|
|
Thanks, very helpful! For me, the session was the equivalent to a JDBC connection and the transaction was just something that you opened in the moment when you needed it.
I was probably confused by the fact that CDOTransaction extends CDOView and the wiki says "Views, in contrast to sessions, are considered light weight entities in CDO, such that you can open and close them as often as you want."
Maybe the wiki should mention the caching issue?
Edit: Actually, in hindsight, I have to say that the wiki is very misleading on this point.
[Updated on: Tue, 06 December 2016 09:38] Report message to a moderator
|
|
|
|
|
|
Re: [CDO] First pass through resource contents slow? [message #1749474 is a reply to message #1749407] |
Wed, 07 December 2016 07:48 |
|
It's not really bad, but performance depends on so many things. I'll try to explain:
A CDOObject is a thin wrapper that contains only a few internal data values, i.e., CDOID, CDOView, CDOState, and a reference to the "real" data, a so-called CDORevision. The more expensive CDORevision is softly cached in the CDOSession. Recreating the CDOObject is cheap if the needed CDORevision is still cached. Cache-warming can help to speed up first iterations, and extra strong references can help to keep CDORevisions in the cache for future iterations.
It's hard for me to tell where your specific bottleneck really is, but maybe the following articles about CDO internals help you to better understand:
How Scalable are my Models?
Concurrent Access to Models
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Powered by
FUDForum. Page generated in 0.04472 seconds