Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nondeterministic Corner Case in Receiver-Side Replay #373

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/som/interpreter/actors/ReceivedRootNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import som.interpreter.SomLanguage;
import som.interpreter.actors.EventualMessage.PromiseMessage;
import som.interpreter.actors.SPromise.SResolver;
import som.interpreter.actors.SPromise.STracingPromise;
import som.vm.VmSettings;
import tools.concurrency.KomposTrace;
import tools.concurrency.TracingActors.TracingActor;
Expand Down Expand Up @@ -93,9 +92,7 @@ public final Object execute(final VirtualFrame frame) {

if (VmSettings.RECEIVER_SIDE_TRACING) {
if (msg instanceof PromiseMessage) {
PromiseMessage pmsg = (PromiseMessage) msg;
STracingPromise tprom = (STracingPromise) pmsg.getPromise();
promiseMessageTracer.record(tprom.getResolvingActor());
promiseMessageTracer.record(msg.messageId);
}
messageTracer.record(((TracingActor) msg.getSender()).getId());
}
Expand Down
5 changes: 5 additions & 0 deletions src/som/interpreter/actors/RegisterOnPromiseNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import som.interpreter.actors.SPromise.SReplayPromise;
import som.interpreter.actors.SPromise.STracingPromise;
import som.vm.VmSettings;
import tools.concurrency.TracingActors.TracingActor;
import tools.dym.DynamicMetrics;
import tools.replay.ReplayRecord;
import tools.replay.TraceRecord;
Expand Down Expand Up @@ -72,6 +73,8 @@ public void register(final SPromise promise, final PromiseMessage msg,
((SReplayPromise) promise).registerOnResolvedReplay(msg);
return;
}
} else if (VmSettings.RECEIVER_SIDE_TRACING || VmSettings.RECEIVER_SIDE_REPLAY) {
msg.messageId = ((TracingActor) current).getNextPromiseMsgNumber();
}

if (!promise.isResolvedUnsync()) {
Expand Down Expand Up @@ -154,6 +157,8 @@ public void register(final SPromise promise, final PromiseMessage msg,
((SReplayPromise) promise).registerOnErrorReplay(msg);
return;
}
} else if (VmSettings.RECEIVER_SIDE_TRACING || VmSettings.RECEIVER_SIDE_REPLAY) {
msg.messageId = ((TracingActor) current).getNextPromiseMsgNumber();
}

if (!promise.isErroredUnsync()) {
Expand Down
18 changes: 2 additions & 16 deletions src/som/interpreter/actors/SPromise.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import som.vmobjects.SObjectWithClass;
import tools.concurrency.KomposTrace;
import tools.concurrency.TracingActivityThread;
import tools.concurrency.TracingActors.TracingActor;
import tools.debugger.entities.PassiveEntityType;
import tools.dym.DynamicMetrics;
import tools.replay.PassiveEntityWithEvents;
Expand Down Expand Up @@ -203,9 +202,6 @@ public final synchronized SPromise getChainedPromiseFor(final Actor target,
if (isCompleted()) {
remote.value = value;
remote.resolutionState = resolutionState;
if (VmSettings.RECEIVER_SIDE_TRACING || VmSettings.RECEIVER_SIDE_REPLAY) {
((STracingPromise) remote).resolvingActor = ((STracingPromise) this).resolvingActor;
}
} else {

if (VmSettings.SENDER_SIDE_TRACING) {
Expand Down Expand Up @@ -377,19 +373,12 @@ protected STracingPromise(final Actor owner, final boolean haltOnResolver,
version = 0;
}

protected int version;
protected long resolvingActor;
protected int version;

@Override
public int getNextEventNumber() {
return version;
}

public long getResolvingActor() {
assert VmSettings.RECEIVER_SIDE_TRACING || VmSettings.RECEIVER_SIDE_REPLAY;
assert isCompleted();
return resolvingActor;
}
}

public static class SReplayPromise extends STracingPromise {
Expand Down Expand Up @@ -826,10 +815,7 @@ protected static void resolveAndTriggerListenersUnsynced(final Resolution type,
final RecordOneEvent tracePromiseResolutionEnd2) {
assert !(result instanceof SPromise);

if (VmSettings.RECEIVER_SIDE_TRACING || VmSettings.RECEIVER_SIDE_REPLAY) {
((STracingPromise) p).resolvingActor =
((TracingActor) EventualMessage.getActorCurrentMessageIsExecutionOn()).getId();
} else if (VmSettings.KOMPOS_TRACING) {
if (VmSettings.KOMPOS_TRACING) {
if (type == Resolution.SUCCESSFUL && p.resolutionState != Resolution.CHAINED) {
KomposTrace.promiseResolution(p.getPromiseId(), result);
} else if (type == Resolution.ERRONEOUS) {
Expand Down
15 changes: 12 additions & 3 deletions src/tools/concurrency/TracingActors.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import som.interpreter.actors.Actor;
import som.interpreter.actors.EventualMessage;
import som.interpreter.actors.EventualMessage.PromiseMessage;
import som.interpreter.actors.SPromise.STracingPromise;
import som.vm.VmSettings;
import tools.debugger.WebDebugger;
import tools.replay.PassiveEntityWithEvents;
Expand All @@ -34,6 +33,7 @@ public static class TracingActor extends Actor {
protected SnapshotRecord snapshotRecord;
private int traceBufferId;
protected int version;
private long nextPMsgNumber;

/**
* Flag that indicates if a step-to-next-turn action has been made in the previous message.
Expand Down Expand Up @@ -142,6 +142,15 @@ public static void handleBreakpointsAndStepping(final EventualMessage msg,
public DeserializationBuffer getDeserializationBuffer() {
return null;
}

/**
* Only to be used by the thread executing this actor
*
* @return
*/
public long getNextPromiseMsgNumber() {
return nextPMsgNumber++;
}
}

public static final class ReplayActor extends TracingActor
Expand Down Expand Up @@ -306,7 +315,7 @@ protected boolean replayCanProcess(final MessageRecord expected,

// handle promise messages
if (msg instanceof PromiseMessage
&& (((STracingPromise) ((PromiseMessage) msg).getPromise()).getResolvingActor() != expected.getResolver())) {
&& msg.getMessageId() != expected.getMessageId()) {
return false;
}

Expand Down Expand Up @@ -517,7 +526,7 @@ public long getSender() {
return sender;
}

public long getResolver() {
public long getMessageId() {
return resolver;
}

Expand Down