From 0f7b913b07a2769ebf1ed5e8748fdda3ff077f7f Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Thu, 12 Feb 2015 18:19:38 +0000 Subject: [PATCH] LUCENE-6069: Lucene Core now gets compiled with Java 8 "compact1" profile, all other modules with "compact2". git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1659347 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 + lucene/common-build.xml | 3 +- lucene/core/build.xml | 2 + .../lucene/util/StressRamUsageEstimator.java | 74 ++----------------- .../TestSpanQueryParserSimpleSample.java | 3 +- solr/common-build.xml | 1 + 6 files changed, 14 insertions(+), 72 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index f0acfbfe478..92901d284b7 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -10,6 +10,9 @@ System Requirements * LUCENE-5950: Move to Java 8 as minimum Java version. (Ryan Ernst, Uwe Schindler) +* LUCENE-6069: Lucene Core now gets compiled with Java 8 "compact1" profile, + all other modules with "compact2". (Robert Muir, Uwe Schindler) + New Features * LUCENE-5735: NumberRangePrefixTreeStrategy now includes interval/range faceting diff --git a/lucene/common-build.xml b/lucene/common-build.xml index 4e2d44fb52b..cdf059eb433 100644 --- a/lucene/common-build.xml +++ b/lucene/common-build.xml @@ -165,6 +165,7 @@ + @@ -1861,8 +1862,8 @@ ${ant.project.name}.test.dependencies=${test.classpath.list} - + diff --git a/lucene/core/build.xml b/lucene/core/build.xml index 10ef2056407..19e571e2d68 100644 --- a/lucene/core/build.xml +++ b/lucene/core/build.xml @@ -35,6 +35,8 @@ org/apache/lucene/index/TestIndexWriterOnJRECrash.class "/> + + diff --git a/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java b/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java index 95e98060fd8..87ee1487e92 100644 --- a/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java +++ b/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java @@ -17,17 +17,7 @@ package org.apache.lucene.util; * limitations under the License. */ -import java.lang.management.GarbageCollectorMXBean; -import java.lang.management.ManagementFactory; -import java.lang.management.MemoryMXBean; -import java.lang.management.MemoryUsage; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.Random; - -import org.junit.Ignore; /** * Estimates how {@link RamUsageEstimator} estimates physical memory consumption @@ -47,45 +37,19 @@ public class StressRamUsageEstimator extends LuceneTestCase { } } - // This shows an easy stack overflow because we're counting recursively. - @Ignore - public void testChainedEstimation() { - MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); - - Random rnd = random(); - Entry first = new Entry(); - try { - while (true) { - // Check the current memory consumption and provide the estimate. - long jvmUsed = memoryMXBean.getHeapMemoryUsage().getUsed(); - long estimated = RamUsageTester.sizeOf(first); - System.out.println(String.format(Locale.ROOT, "%10d, %10d", - jvmUsed, estimated)); - - // Make a batch of objects. - for (int i = 0; i < 5000; i++) { - first.createNext(new byte[rnd.nextInt(1024)]); - } - } - } catch (OutOfMemoryError e) { - // Release and quit. - } - } - volatile Object guard; // This shows an easy stack overflow because we're counting recursively. public void testLargeSetOfByteArrays() { - MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); - causeGc(); - long before = memoryMXBean.getHeapMemoryUsage().getUsed(); + System.gc(); + long before = Runtime.getRuntime().totalMemory(); Object [] all = new Object [1000000]; for (int i = 0; i < all.length; i++) { all[i] = new byte[random().nextInt(3)]; } - causeGc(); - long after = memoryMXBean.getHeapMemoryUsage().getUsed(); + System.gc(); + long after = Runtime.getRuntime().totalMemory(); System.out.println("mx: " + RamUsageEstimator.humanReadableUnits(after - before)); System.out.println("rue: " + RamUsageEstimator.humanReadableUnits(shallowSizeOf(all))); @@ -112,24 +76,16 @@ public class StressRamUsageEstimator extends LuceneTestCase { } public void testSimpleByteArrays() { - MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); - Object [][] all = new Object [0][]; try { while (true) { // Check the current memory consumption and provide the estimate. - causeGc(); - MemoryUsage mu = memoryMXBean.getHeapMemoryUsage(); + System.gc(); long estimated = shallowSizeOf(all); if (estimated > 50 * RamUsageEstimator.ONE_MB) { break; } - System.out.println(String.format(Locale.ROOT, "%10s\t%10s\t%10s", - RamUsageEstimator.humanReadableUnits(mu.getUsed()), - RamUsageEstimator.humanReadableUnits(mu.getMax()), - RamUsageEstimator.humanReadableUnits(estimated))); - // Make another batch of objects. Object[] seg = new Object[10000]; all = Arrays.copyOf(all, all.length + 1); @@ -142,24 +98,4 @@ public class StressRamUsageEstimator extends LuceneTestCase { // Release and quit. } } - - /** - * Very hacky, very crude, but (sometimes) works. - * Don't look, it will burn your eyes out. - */ - private void causeGc() { - List garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans(); - List ccounts = new ArrayList<>(); - for (GarbageCollectorMXBean g : garbageCollectorMXBeans) { - ccounts.add(g.getCollectionCount()); - } - List ccounts2 = new ArrayList<>(); - do { - System.gc(); - ccounts.clear(); - for (GarbageCollectorMXBean g : garbageCollectorMXBeans) { - ccounts2.add(g.getCollectionCount()); - } - } while (ccounts2.equals(ccounts)); - } } diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/spans/TestSpanQueryParserSimpleSample.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/spans/TestSpanQueryParserSimpleSample.java index 4d64b2bc501..11a784ace2f 100644 --- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/spans/TestSpanQueryParserSimpleSample.java +++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/spans/TestSpanQueryParserSimpleSample.java @@ -17,14 +17,13 @@ package org.apache.lucene.queryparser.flexible.spans; * limitations under the License. */ -import javax.management.Query; - import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; import org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorPipeline; import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser; +import org.apache.lucene.search.Query; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.util.LuceneTestCase; diff --git a/solr/common-build.xml b/solr/common-build.xml index f5b5fd5a9a5..abe8fed401b 100644 --- a/solr/common-build.xml +++ b/solr/common-build.xml @@ -29,6 +29,7 @@ +