You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2019/12/18 13:43:04 UTC
[uima-uimaj] branch master updated: no jira - enable suport for
tuning hash map
This is an automated email from the ASF dual-hosted git repository.
schor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
The following commit(s) were added to refs/heads/master by this push:
new 1fb3393 no jira - enable suport for tuning hash map
1fb3393 is described below
commit 1fb339310e7a11cae5398f0cb8a2ec2eb636905e
Author: Marshall Schor <ms...@schor.com>
AuthorDate: Wed Dec 18 08:42:53 2019 -0500
no jira - enable suport for tuning hash map
---
.../uima/internal/util/Common_hash_support.java | 23 ++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/uimaj-core/src/main/java/org/apache/uima/internal/util/Common_hash_support.java b/uimaj-core/src/main/java/org/apache/uima/internal/util/Common_hash_support.java
index 38ddd75..e81b0c0 100644
--- a/uimaj-core/src/main/java/org/apache/uima/internal/util/Common_hash_support.java
+++ b/uimaj-core/src/main/java/org/apache/uima/internal/util/Common_hash_support.java
@@ -21,7 +21,6 @@ package org.apache.uima.internal.util;
import java.util.Arrays;
import java.util.function.IntConsumer;
import java.util.function.IntPredicate;
-import java.util.function.IntSupplier;
/**
* A common superclass for hash maps and hash sets
@@ -32,6 +31,9 @@ public abstract class Common_hash_support {
// set to true to collect statistics for tuning
// you have to also put a call to showHistogram() at the end of the run
protected static final boolean TUNE = false;
+ private static Common_hash_support tune_instance;
+
+
protected static final int MIN_SIZE = 10; // 10 / .66 =15.15
protected static final int MIN_CAPACITY = 16;
@@ -65,6 +67,7 @@ public abstract class Common_hash_support {
this.loadFactor = factor;
this.initialCapacity = tableSpace(initialSizeBeforeExpanding, factor);
if (TUNE) {
+ tune_instance = this;
histogram = new int[200];
Arrays.fill(histogram, 0);
maxProbe = 0;
@@ -418,11 +421,11 @@ public abstract class Common_hash_support {
protected abstract void copy_to_new_table(int new_capacity, int old_capacity, CommonCopyOld2New r);
protected void resetHistogram() {
- if (TUNE) {
- histogram = new int[200];
- Arrays.fill(histogram, 0);
- maxProbe = 0;
- }
+// if (TUNE) {
+// histogram = new int[200];
+// Arrays.fill(histogram, 0);
+// maxProbe = 0;
+// }
}
private void updateHistogram(int nbrProbes) {
@@ -457,6 +460,14 @@ public abstract class Common_hash_support {
}
}
+ static {
+ if (TUNE) {
+ Runtime.getRuntime().addShutdownHook(new Thread(null, () -> {
+ tune_instance.showHistogram();
+ }));
+ }
+ }
+
// test case use
int getCapacity() {
return keys_length();