shithub: mc

Download patch

ref: 3bbb1de460c9fe264d7ce63b421dd6dd351e2a45
parent: 7ef09f3db883c42d01e3b1d80f0d2da6ceff9913
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Sep 3 23:12:19 EDT 2017

Fix caching.

--- a/lib/std/bytealloc.myr
+++ b/lib/std/bytealloc.myr
@@ -261,6 +261,7 @@
 		s = bkt.cache
 		bkt.cache = s.next
 		bkt.ncache--
+		-> s
 	;;
 
 	/*
@@ -345,10 +346,6 @@
 		s.prev = Zslab
 		bkt.slabs = s
 	elif s.nfree == bkt.nper - 1
-		/*
-		HACK HACK HACK: if we can't unmap, keep an infinite cache per slab size.
-		We should solve this better somehow.
-		*/
 		/* unlink the slab from the list */
 		if s.next != Zslab
 			s.next.prev = s.prev
@@ -359,10 +356,15 @@
 		if bkt.slabs == s
 			bkt.slabs = s.next
 		;;
+		/*
+		HACK HACK HACK: if we can't unmap, keep an infinite cache per slab size.
+		We should solve this better somehow.
+		*/
 		if bkt.ncache < Cachemax || !Canunmap
 			s.next = bkt.cache
 			s.prev = Zslab
 			bkt.cache = s
+			bkt.ncache++
 		else
 			/* we mapped 2*Slabsz so we could align it,
 			 so we need to unmap the same */
--- a/lib/thread/test/mutex.myr
+++ b/lib/thread/test/mutex.myr
@@ -27,7 +27,6 @@
 	for var i = 0; i < 1000; i++
 		thread.mtxlock(&mtx)
 		val++
-		std.put("val: {}\n", val)
 		thread.mtxunlock(&mtx)
 	;;
 	thread.xadd(&done, 1)