[mono/mono] cc7b7992: Reduce contention and unnecessary checks at each lookup, part of xambug #14644.

"Paolo Molaro ([email protected])" <[email protected]> Tue, 5 Nov 2013 16:40:04 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <0000014229229e8d-9a5b6404-f32f-4bca-b020-113734c2b47c-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/cf8c83129deb...cc7b7992ff44

   Commit: cc7b7992ff4435b177d08072c52956238167d939
   Author: Paolo Molaro <[email protected]> (illupus)
     Date: 2013-11-05 16:37:08 GMT
      URL: https://github.com/mono/mono/commit/cc7b7992ff4435b177d08072c52956238167d939

Reduce contention and unnecessary checks at each lookup, part of xambug #14644.

Changed paths:
  M mcs/class/System/System.Net/ServicePointManager.cs

Modified: mcs/class/System/System.Net/ServicePointManager.cs
===================================================================
@@ -326,7 +326,8 @@ public static ServicePoint FindServicePoint (Uri address, IWebProxy proxy)
 			if (address == null)
 				throw new ArgumentNullException ("address");
 
-			RecycleServicePoints ();
+			if ((servicePoints.Count % 4) == 0)
+				RecycleServicePoints ();
 
 			var origAddress = new Uri (address.Scheme + "://" + address.Authority);
 			
@@ -346,8 +347,8 @@ public static ServicePoint FindServicePoint (Uri address, IWebProxy proxy)
 			address = new Uri (address.Scheme + "://" + address.Authority);
 			
 			ServicePoint sp = null;
+			SPKey key = new SPKey (origAddress, usesProxy ? address : null, useConnect);
 			lock (servicePoints) {
-				SPKey key = new SPKey (origAddress, usesProxy ? address : null, useConnect);
 				sp = servicePoints [key] as ServicePoint;
 				if (sp != null)
 					return sp;


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches