From: Wolfgang M. M. <wol...@us...> - 2004-08-16 19:47:31
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18472/src/org/exist/storage Modified Files: DBBroker.java BrokerPool.java NativeBroker.java Log Message: Removed the cache sync events that had been triggered by every database file independantly. Instead, the global BrokerPool will now trigger all sync events (through the SyncDaemon background thread). It distinguishes between minor and major syncs. Major syncs write all caches to disk, minor syncs only write the main document store (dom.dbx + collections.dbx). Minor syncs occur every 2 seconds, major syncs after a configurable period of time. As BrokerPool controls all sync events, it is guaranteed that only one cache is written at the same time. This has a positive effect on indexing performance. Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** NativeBroker.java 15 Aug 2004 20:29:09 -0000 1.99 --- NativeBroker.java 16 Aug 2004 19:47:11 -0000 1.100 *************** *** 75,78 **** --- 75,79 ---- import org.exist.storage.store.NodeIterator; import org.exist.storage.store.StorageAddress; + import org.exist.storage.sync.Sync; import org.exist.util.ByteArrayPool; import org.exist.util.ByteConversion; *************** *** 2336,2340 **** try { flush(); ! sync(); textEngine.close(); domDb.close(); --- 2337,2341 ---- try { flush(); ! sync(Sync.MAJOR_SYNC); textEngine.close(); domDb.close(); *************** *** 2527,2538 **** } ! public void sync() { ! Runtime runtime = Runtime.getRuntime(); ! LOG.debug("Memory: " + (runtime.totalMemory() / 1024) + "K total; " + ! (runtime.freeMemory() / 1024) + "K free"); ! // uncomment this to get statistics on page buffer usage ! elementsDb.printStatistics(); ! collectionsDb.printStatistics(); ! domDb.printStatistics(); try { Lock lock = collectionsDb.getLock(); --- 2528,2532 ---- } ! public void sync(int syncEvent) { try { Lock lock = collectionsDb.getLock(); *************** *** 2556,2561 **** } .run(); ! elementIndex.sync(); ! textEngine.sync(); } catch (DBException dbe) { dbe.printStackTrace(); --- 2550,2566 ---- } .run(); ! if(syncEvent == Sync.MAJOR_SYNC) { ! elementIndex.sync(); ! textEngine.sync(); ! ! Runtime runtime = Runtime.getRuntime(); ! LOG.debug("Memory: " + (runtime.totalMemory() / 1024) + "K total; " + ! (runtime.freeMemory() / 1024) + "K free"); ! ! // uncomment this to get statistics on page buffer usage ! elementsDb.printStatistics(); ! collectionsDb.printStatistics(); ! domDb.printStatistics(); ! } } catch (DBException dbe) { dbe.printStackTrace(); Index: DBBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/DBBroker.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** DBBroker.java 6 Aug 2004 17:36:37 -0000 1.42 --- DBBroker.java 16 Aug 2004 19:47:11 -0000 1.43 *************** *** 546,554 **** public abstract void consistencyCheck(DocumentImpl doc) throws EXistException; ! public void sync() { ! /* ! * do nothing ! */ ! } /** --- 546,550 ---- public abstract void consistencyCheck(DocumentImpl doc) throws EXistException; ! public abstract void sync(int syncEvent); /** Index: BrokerPool.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/BrokerPool.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** BrokerPool.java 10 Aug 2004 20:27:14 -0000 1.28 --- BrokerPool.java 16 Aug 2004 19:47:11 -0000 1.29 *************** *** 175,178 **** --- 175,179 ---- private String instanceId; private boolean syncRequired = false; + private int syncEvent = 0; private boolean initializing = true; *************** *** 232,236 **** syncDaemon = new SyncDaemon(); if (syncPeriod > 0) ! syncDaemon.executePeriodically(syncPeriod, new Sync(this), false); conf = config; xqueryCache = new XQueryPool(); --- 233,237 ---- syncDaemon = new SyncDaemon(); if (syncPeriod > 0) ! syncDaemon.executePeriodically(2000, new Sync(this, syncPeriod), false); conf = config; xqueryCache = new XQueryPool(); *************** *** 401,405 **** pool.push(broker); if (syncRequired && threads.size() == 0) { ! sync(broker); syncRequired = false; } --- 402,406 ---- pool.push(broker); if (syncRequired && threads.size() == 0) { ! sync(broker, syncEvent); syncRequired = false; } *************** *** 415,421 **** * @param broker */ ! public void sync(DBBroker broker) { ! LOG.debug("syncing buffers to disk"); ! broker.sync(); } --- 416,421 ---- * @param broker */ ! public void sync(DBBroker broker, int syncEvent) { ! broker.sync(syncEvent); } *************** *** 468,479 **** } ! public void triggerSync() { synchronized (this) { if (pool.size() == brokers) { DBBroker broker = (DBBroker) pool.peek(); ! sync(broker); syncRequired = false; ! } else syncRequired = true; } } --- 468,483 ---- } ! public void triggerSync(int event) { synchronized (this) { + if(pool.size() == 0) + return; if (pool.size() == brokers) { DBBroker broker = (DBBroker) pool.peek(); ! sync(broker, syncEvent); syncRequired = false; ! } else { ! syncEvent = event; syncRequired = true; + } } } |