Skip to content

Commit ef7a270

Browse files
improve overall performance & stability
1 parent c09a4de commit ef7a270

8 files changed

Lines changed: 66 additions & 4 deletions

File tree

src/main/java/su/interference/core/DataChunk.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,10 @@ public int getChunkLen () {
466466
return 0;
467467
}
468468

469+
public Object getExistingEntity() {
470+
return this.entity;
471+
}
472+
469473
public Object getEntity () {
470474
if (entity==null) {
471475
try {

src/main/java/su/interference/core/Frame.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameDa
574574
for (Chunk c : data.getChunks()) {
575575
if (c.getHeader().getTran().getTransId() == tran.getTransId()) {
576576
((DataChunk) c).setUndoChunk(null);
577-
// todo ((DataChunk) c).cleanUpIcs();
577+
((DataChunk) c).cleanUpIcs();
578578
r.add(c.getHeader().getPtr());
579579
}
580580
}
@@ -591,7 +591,11 @@ public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameDa
591591
final int ucfile = uc.getDataChunk().getHeader().getRowID().getFileId();
592592
final long frameptr = uc.getDataChunk().getHeader().getRowID().getFramePointer();
593593
if (uc.getTransId() == tran.getTransId() && ucfile == this.file && frameptr == this.pointer) {
594-
data.add(uc.getDataChunk().restore(uc));
594+
final DataChunk rc = uc.getDataChunk().restore(uc);
595+
if (this instanceof IndexFrame && rc.getExistingEntity() != null) {
596+
((IndexChunk) rc.getExistingEntity()).setDataChunk(null);
597+
}
598+
data.add(rc);
595599
}
596600
}
597601
}

src/main/java/su/interference/core/IndexFrame.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ public IndexFrame(byte[] b, int file, long pointer, Map<Long, Long> imap, Map<Lo
127127
this.b = null; //throw bytes to GC
128128
}
129129

130+
public void cleanICEntities() {
131+
for (Chunk c : this.data.getChunks()) {
132+
final Object e = ((DataChunk) c).getExistingEntity();
133+
if (e != null) {
134+
((IndexChunk) e).setDataChunk(null);
135+
}
136+
}
137+
}
138+
130139
public IndexFrame add (DataChunk e, Table t, Session s, LLT llt) throws Exception {
131140
if (this.isFill(e)) {
132141

src/main/java/su/interference/core/SystemCleanUp.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class SystemCleanUp implements Runnable, ManagedProcess {
4545
public static final int DATA_RETRIEVED_PRIORITY = 6;
4646
public static final int INDEX_RETRIEVED_PRIORITY = 9;
4747
private static final int CLEANUP_PROTECTION_THR = 1000;
48-
private static final int IX_CLEANUP_PROTECTION_THR = 20000;
48+
private static final int IX_CLEANUP_PROTECTION_THR = 5000;
4949

5050
public void run () {
5151
Thread.currentThread().setName("interference-cleanup-thread");
@@ -139,4 +139,11 @@ private void cleanUpFrames() {
139139
Metrics.get("systemCleanUp").stop();
140140

141141
}
142+
143+
public static void forceCleanUp() {
144+
for (Object entry : Instance.getInstance().getFramesMap().entrySet()) {
145+
final FrameData f = (FrameData) ((DataChunk) ((Map.Entry) entry).getValue()).getEntity();
146+
f.clearFrame();
147+
}
148+
}
142149
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package su.interference.metrics;
2+
3+
import su.interference.core.SystemCleanUp;
4+
5+
public class Call extends Meter implements CallMBean {
6+
7+
public Call(String name) {
8+
super(name);
9+
}
10+
11+
public void forceCleanUp() {
12+
SystemCleanUp.forceCleanUp();
13+
}
14+
15+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package su.interference.metrics;
2+
3+
public interface CallMBean {
4+
void forceCleanUp();
5+
}

src/main/java/su/interference/metrics/Metrics.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ this software and associated documentation files (the "Software"), to deal in
2424

2525
package su.interference.metrics;
2626

27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
2729
import javax.management.MBeanServer;
2830
import javax.management.ObjectName;
2931
import java.lang.management.ManagementFactory;
30-
import java.util.HashMap;
3132
import java.util.concurrent.ConcurrentHashMap;
3233

3334
/**
@@ -40,15 +41,26 @@ public class Metrics {
4041
public static final int COUNTER = 1;
4142
public static final int HISTOGRAM = 2;
4243
public static final int TIMER = 3;
44+
public static final int CALL = 4;
4345
public static final int METER = 10;
4446
private static final ConcurrentHashMap<String, Meter> metrics = new ConcurrentHashMap<String, Meter>();
4547
private static final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
48+
private final static Logger logger = LoggerFactory.getLogger(Metrics.class);
49+
50+
static {
51+
try {
52+
register(CALL, "systemCalls");
53+
} catch (Exception e) {
54+
logger.error("Exception in metrics static intializer", e);
55+
}
56+
}
4657

4758
public static void register(int type, String name) throws Exception {
4859
if (type == COUNTER) { metrics.put(name, new Counter(name)); }
4960
if (type == HISTOGRAM) { metrics.put(name, new Histogram(name)); }
5061
if (type == TIMER) { metrics.put(name, new Timer(name)); }
5162
if (type == METER) { metrics.put(name, new Meter(name)); }
63+
if (type == CALL) { metrics.put(name, new Call(name)); }
5264

5365
ObjectName obj = new ObjectName("su.interference:type="+name+metrics.get(name).getClass().getSimpleName());
5466
mbs.registerMBean(metrics.get(name), obj);

src/main/java/su/interference/persistent/Transaction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ public synchronized void rollback (Session s, boolean remote) {
355355
frame_.rollbackTransaction(this, ubs, s);
356356
}
357357
}
358+
for (FrameData ub : ubd2) {
359+
final Frame frame_ = ub.getFrame();
360+
if (frame_ instanceof IndexFrame) {
361+
((IndexFrame) frame_).cleanICEntities();
362+
}
363+
}
358364

359365
for (TransFrame tb : tframes) {
360366
boolean hasfb = false;

0 commit comments

Comments
 (0)