linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MM fix & improvement
@ 1999-01-09  7:32 Zlatko Calusic
  1999-01-09  7:43 ` Zlatko Calusic
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Zlatko Calusic @ 1999-01-09  7:32 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux-MM List, Linux Kernel List

[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]

OK, here it goes. Patch is unbelievably small, and improvement is
BIG.

Two things:

1) Til' now, writing to swap files & partitions was clustered 
in 128kb chunks which is too small, especially now when we have swapin 
readahead (default 64kb). Fragmentation of swap file with such a value 
is big, so swapin readahead hit rate is probably small. Thus first
improvement is in increasing on-disk cluster size to much bigger
value. I chose 512, and it works very well, indeed (see below). All
this is completely safe.

2) There was an artificial limit in swapin readahead code, that is
completely unnecessary, and also kills performance a big time. It also 
makes trouble with two thrashing tasks, because swapin readahead
doesn't work very well in such low memory condition. I removed it
alltogether, and swapping quite improved.

If you don't believe, look at benchmarks I made for your eyes only
(swap cache statistics is after both runs):

pre6 + MM cleanup (needed for swap cache hit rate)
 
    hogmem 100 3	-	10.75 MB/sec
2 x hogmem 50 3		-	2.01 + 1.97 MB/sec (disk thrashing)
swap cache		-	add 194431 find 13315/194300 (6.9% hit rate)

pre6 + MM cleanup + patch below

    hogmem 100 3	-	13.27 MB/sec
2 x hogmem 50 3		-	6.15 + 5.77 MB/sec (perfect)
swap cache		-	add 175887 find 76003/237711 (32% hit rate)

Notice how swap cache done it's job much better with changes applied!!!

Both tests were run in single user mode, after reboot, on 64MB
machine. Don't be disappointed if you get smaller numbers, I have two
swap partitions on different disks and transports (IDE + SCSI). :)


[-- Attachment #2: MM Improvement --]
[-- Type: application/octet-stream, Size: 1758 bytes --]

Index: 2206.3/mm/swapfile.c
--- 2206.3/mm/swapfile.c Tue, 01 Dec 1998 11:32:58 +0100 zcalusic (linux-2.1/z/b/20_swapfile.c 1.2 644)
+++ 2206.3(w)/mm/swapfile.c Sat, 09 Jan 1999 08:08:52 +0100 zcalusic (linux-2.1/z/b/20_swapfile.c 1.2 644)
@@ -23,6 +23,7 @@
 
 struct swap_info_struct swap_info[MAX_SWAPFILES];
 
+#define SWAPFILE_CLUSTER 256
 
 static inline int scan_swap_map(struct swap_info_struct *si)
 {
@@ -30,7 +31,7 @@
 	/* 
 	 * We try to cluster swap pages by allocating them
 	 * sequentially in swap.  Once we've allocated
-	 * SWAP_CLUSTER_MAX pages this way, however, we resort to
+	 * SWAPFILE_CLUSTER pages this way, however, we resort to
 	 * first-free allocation, starting a new cluster.  This
 	 * prevents us from scattering swap pages all over the entire
 	 * swap partition, so that we reduce overall disk seek times
@@ -46,7 +47,7 @@
 			goto got_page;
 		}
 	}
-	si->cluster_nr = SWAP_CLUSTER_MAX;
+	si->cluster_nr = SWAPFILE_CLUSTER;
 	for (offset = si->lowest_bit; offset <= si->highest_bit ; offset++) {
 		if (si->swap_map[offset])
 			continue;
Index: 2206.3/mm/page_alloc.c
--- 2206.3/mm/page_alloc.c Sat, 09 Jan 1999 04:07:03 +0100 zcalusic (linux-2.1/z/b/26_page_alloc 1.2.6.1.1.2.4.1.1.2 644)
+++ 2206.3(w)/mm/page_alloc.c Sat, 09 Jan 1999 08:08:52 +0100 zcalusic (linux-2.1/z/b/26_page_alloc 1.2.6.1.1.2.4.1.1.2 644)
@@ -370,9 +370,7 @@
 	offset = (offset >> page_cluster) << page_cluster;
 	
 	for (i = 1 << page_cluster; i > 0; i--) {
-	      if (offset >= swapdev->max
-			      || nr_free_pages - atomic_read(&nr_async_pages) <
-			      (freepages.high + freepages.low)/2)
+	      if (offset >= swapdev->max)
 		      return;
 	      if (!swapdev->swap_map[offset] ||
 		  swapdev->swap_map[offset] == SWAP_MAP_BAD ||

[-- Attachment #3: Type: text/plain, Size: 12 bytes --]


-- 
Zlatko

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1999-01-11  5:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-09  7:32 [PATCH] MM fix & improvement Zlatko Calusic
1999-01-09  7:43 ` Zlatko Calusic
1999-01-09  7:53 ` Linus Torvalds
1999-01-09  8:05   ` Zlatko Calusic
1999-01-11  5:05   ` Dax Kelson
1999-01-09  9:55 ` Stephen C. Tweedie
1999-01-10 14:45 ` David Weinehall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox