Description
Describe the bug
When upgrading from v14 to v24 we noticed that the performance for GreaterFilter, LessFilter and LikeFilters among others was more than 100+ times worse. I reproduced this in a local test. It seems like the ChainedCollection is the problem.
To Reproduce
Attached a test that demonstrates the problem:
`
import com.oracle.coherence.common.collections.NullableSortedMap;
import com.tangosol.util.Binary;
import com.tangosol.util.ChainedCollection;
import com.tangosol.util.SubSet;
import org.junit.Assert;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.util.*;
public class TestCoherence {
@Test
public void testCoherenceRetainAll() {
SubSet<Binary> setKeys = new SubSet<>(createSet());
SubSet<Binary> setKeys2 = new SubSet<>(setKeys);
NullableSortedMap<Integer, Set<Binary>> mapTail = new NullableSortedMap<>();
for (int i = 0; i < 43000; i++) {
mapTail.put(i, Collections.singleton(createBinary(i)));
}
//New Style:
long start = System.currentTimeMillis();
List<Set<?>> listGT = new ArrayList<>(mapTail.size());
for (Object o : mapTail.values()) {
Set set = (Set) o;
listGT.add(ensureSafeSet(set));
}
setKeys.retainAll(new ChainedCollection<>(listGT.toArray(Set[]::new)));
long newStyle = System.currentTimeMillis() - start;
start = System.currentTimeMillis();
NullableSortedMap<Integer, Set<Binary>> mapGE = new NullableSortedMap<>(mapTail);
//Old style:
Set setGT = new HashSet();
for (Iterator iterGE = mapGE.values().iterator(); iterGE.hasNext(); ) {
Set set = (Set) iterGE.next();
setGT.addAll(ensureSafeSet(set));
}
setKeys2.retainAll(setGT);
long oldStyle = System.currentTimeMillis() - start;
System.out.println("Time: new style(v24):" + newStyle + " ms, old style(v14):" + oldStyle + " ms");
Assert.assertEquals(setKeys, setKeys2);
}
private Set<Binary> createSet() {
Set<Binary> s = new HashSet<>();
for (int i = 0; i < 30000; i++) {
s.add(createBinary(i + 15000));
}
return s;
}
protected static Set ensureSafeSet(Set set) {
return set == null ? Collections.emptySet() : set;
}
private Binary createBinary(int i) {
String s = "randomkey_no_test_gldfkjglkdfgjdflkgjdflkgjlkdfjglkdfjglkdfjglkdf" + i;
return new Binary(s.getBytes(StandardCharsets.UTF_8));
}
}
`
Expected behaviour
At least the same performance as before
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- Coherence CE 24.
- Java version Coretto 21
- OS: windows
- OS Version w11
Additional context
Add any other context about the problem here.