Skip to content

Commit f257277

Browse files
authored
[perf] Fixed PerfWatson in Mono.Debugger.Soft.Connection.disconnected_check (#417)
With another recent PerfWatson fix (824fc62), a lock has been introduced in the disconnected_check method, to mostly control the access of the disconnected property. This caused a new PerfWatson issue, so this change reverts that extra threading control and instead converts the disconnected boolean variable into a volatile variable, so the latest updated value is always guaranteed for multi threading access, without the need of an unnecessary and blocking lock. Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2481686/?view=edit
1 parent 824fc62 commit f257277

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ internal bool IsClosed {
15401540
}
15411541
}
15421542

1543-
bool disconnected;
1543+
volatile bool disconnected;
15441544
VMCrashException crashed;
15451545

15461546
internal ManualResetEvent DisconnectedEvent = new ManualResetEvent (false);
@@ -1575,14 +1575,12 @@ void receiver_thread_main () {
15751575
}
15761576

15771577
void disconnected_check () {
1578-
lock (reply_packets_monitor) {
1579-
if (!disconnected)
1580-
return;
1581-
else if (crashed != null)
1582-
throw crashed;
1583-
else
1584-
throw new VMDisconnectedException ();
1585-
}
1578+
if (!disconnected)
1579+
return;
1580+
else if (crashed != null)
1581+
throw crashed;
1582+
else
1583+
throw new VMDisconnectedException ();
15861584
}
15871585

15881586
bool ReceivePacket () {

0 commit comments

Comments
 (0)