1 |
-----BEGIN PGP SIGNED MESSAGE----- |
2 |
Hash: SHA1 |
3 |
|
4 |
Hemmann, Volker Armin wrote: |
5 |
> And for some funny reason, loading something out of swap is much slower than |
6 |
> loading it from the fs.... |
7 |
|
8 |
That seems odd. if you're talking about executables and other MMAP'ed |
9 |
objects the filesystem IS the swap (when apache needs to be swapped out |
10 |
the kernel just deletes it from memory and reloads from disk - unless |
11 |
the executable pages were modified - not sure how dynamic linking is |
12 |
handled in linux, and if that needs to modify code pages). |
13 |
|
14 |
Unless of course your swap is encrypted or something it should be faster |
15 |
than the FS... |
16 |
|
17 |
> |
18 |
> 50mb in swap - and everything is slow. So slow as if every bit is fetched by a |
19 |
> mule caravan. And it does not matter if it is a swap partition or a swap |
20 |
> file. It is slow. |
21 |
> |
22 |
|
23 |
I haven't seen this behavior - I routinely have maybe 500MB swapped out. |
24 |
The difference is that most of this is probably tmpfs data that isn't |
25 |
touched until tmpreaper comes around and deletes it. |
26 |
|
27 |
The critical factor is probably RSS - if you have a zombie process that |
28 |
uses 1GB of RAM and which sleeps for 3 days at a time (with NO activity) |
29 |
then if you swap it out there is probably no impact. On the other hand, |
30 |
if you have 50 processes all running with 2%CPU each and they each have |
31 |
a 100MB RSS and you have 1GB of RAM your system will come to a complete |
32 |
halt. Even if all combined they only need 1.1GB of RAM you'll probably |
33 |
still come to a halt since they'll be constantly churning that 100MB of |
34 |
swap. If 100MB worth of processes sleep suddenly the whole system will |
35 |
wake up. |
36 |
|
37 |
Basically, there is no fix for lots of RUNNING processes other than more |
38 |
RAM (or not running everything at once). But lots of idle processes do |
39 |
just fine with swap. |
40 |
|
41 |
And not having a swap partition doesn't stop swapping. Any time you |
42 |
mmap a file you have virtual memory - no getting around it. And that |
43 |
data will get swapped in and out as needed. And even if none of your |
44 |
software uses mmap the kernel does every time it loads an image. It |
45 |
greatly improves performance (unused code never gets loaded). |
46 |
|
47 |
If I'm wrong on any of this kindly point it out, but this is my |
48 |
understanding of how linux swapping works. |
49 |
-----BEGIN PGP SIGNATURE----- |
50 |
Version: GnuPG v1.4.6 (GNU/Linux) |
51 |
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org |
52 |
|
53 |
iD8DBQFF9whqG4/rWKZmVWkRAr0EAJ440jI6WPQO3dR9ldn6lYVYTb2WkwCfRgFT |
54 |
sPEuMMbiyY4k1MtFn2nHEWI= |
55 |
=dBn2 |
56 |
-----END PGP SIGNATURE----- |