Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
experimental removal of synchronization. This should work for all cases where the size() and isEmpty() method is used only for statistics, which happens at many locations in YaCy. If these methods are used for structual reasons (like accessing the last element in an array) then it may fail or cause other problems. As far as visible, this is not the case.
Michael Peter Christen25a6c050080e
diff --git a/source/net/yacy/kelondro/blob/Heap.java b/source/net/yacy/kelondro/blob/Heap.javaindex db4b4bdb6..d16c252ef 100644--- a/source/net/yacy/kelondro/blob/Heap.java+++ b/source/net/yacy/kelondro/blob/Heap.java@@ -113,7 +113,7 @@ public final class Heap extends HeapModifier implements BLOB {* @return the number of BLOBs in the heap*/@Override- public synchronized int size() {+ public int size() {return super.size() + ((this.buffer == null) ? 0 : this.buffer.size());}diff --git a/source/net/yacy/kelondro/index/RAMIndex.java b/source/net/yacy/kelondro/index/RAMIndex.javaindex 51f979766..7435c8c1a 100644--- a/source/net/yacy/kelondro/index/RAMIndex.java+++ b/source/net/yacy/kelondro/index/RAMIndex.java@@ -325,7 +325,7 @@ public final class RAMIndex implements Index, Iterable<Row.Entry> {}@Override- public final synchronized int size() {+ public final int size() {if (this.index0 != null && this.index1 == null) {return this.index0.size();}@@ -337,7 +337,7 @@ public final class RAMIndex implements Index, Iterable<Row.Entry> {}@Override- public final synchronized boolean isEmpty() {+ public final boolean isEmpty() {if (this.index0 != null && this.index1 == null) {return this.index0.isEmpty();}diff --git a/source/net/yacy/kelondro/index/RAMIndexCluster.java b/source/net/yacy/kelondro/index/RAMIndexCluster.javaindex 3a89793dd..f64b61b10 100644--- a/source/net/yacy/kelondro/index/RAMIndexCluster.java+++ b/source/net/yacy/kelondro/index/RAMIndexCluster.java@@ -337,26 +337,20 @@ public final class RAMIndexCluster implements Index, Iterable<Row.Entry>, Clonea@Overridepublic final int size() {int c = 0;- synchronized (this.cluster) {- for (final RAMIndex i: this.cluster) if (i != null) c += i.size();- }+ for (final RAMIndex i: this.cluster) if (i != null) c += i.size();return c;}@Overridepublic long mem() {long m = 0;- synchronized (this.cluster) {- for (final RAMIndex i: this.cluster) if (i != null) m += i.mem();- }+ for (final RAMIndex i: this.cluster) if (i != null) m += i.mem();return m;}@Overridepublic final boolean isEmpty() {- synchronized (this.cluster) {- for (final RAMIndex i: this.cluster) if (i != null && !i.isEmpty()) return false;- }+ for (final RAMIndex i: this.cluster) if (i != null && !i.isEmpty()) return false;return true;}