What is using swap?
I am trying to figure out why a machine with lots of unused RAM
is using so much swap.
I have a V240 running Solaris 10. Its running a large Oracle db.
The 4th line of /opt/sfw/bin/top shows:
Memory: 8192M real, 4907M free, 2143M swap in use, 18G swap free
Running '/opt/sfw/bin/df -t ufs -t nfs -t tmpfs -h', I see,
FilesystemSize Used Avail Use% Mounted on
/dev/md/dsk/d09.7G 8.0G 1.6G 84% /
swap19G 1.1M19G1% /etc/svc/volatile
/dev/md/dsk/d47.7G 3.8G 4.0G 49% /usr
swap19G 3.8M19G1% /tmp
swap19G56K19G1% /var/run
/dev/md/dsk/d5404G 198G 203G 50% /data
/dev/md/dsk/d7 43G 7.4G35G 18% /export/home
axp1:D3:[BANNER]#/vms_filenames
4.0G 3.7G 322M 93% /data/interfaces
Knowing that using swap degrades performance, can anyone tell me
if this is normal? How to identify what processes are swapped?
# 1
> I am trying to figure out why a machine with lots of
> unused RAM
> is using so much swap.
>
> I have a V240 running Solaris 10. Its running a
> large Oracle db.
> The 4th line of /opt/sfw/bin/top shows:
>
> Memory: 8192M real, 4907M free, 2143M swap in
> use, 18G swap free
Okay, so only 2G.
> Running '/opt/sfw/bin/df -t ufs -t nfs -t tmpfs -h',
> I see,
df gives information about filesystems. It's a poor tool for information about paging space.
Instead, try 'swap -s' and 'swap -l'. Lets see how much is initialized and how much is simply reserved.
> Knowing that using swap degrades performance, can
> anyone tell me
> if this is normal? How to identify what processes
> are swapped?
"swapping" (or more likely "paging") can degrade peformance. But simply allocating swap space (something that Oracle is fond of doing) is not something that will affect performance.
As long as you're not low on RAM, the system should not be paging out in-use RAM pages. That's the event that causes disruption.
Identifying paging processes isn't simple (especially when you're running things like oracle that have very complex memory usage).
You can use 'ps' and look at the RES and SIZE columns. If RES is much lower than SIZE it *can* point to memory being evicted. However it is possible for some pages to be in use and simply never swapped in in the first place. It would be unusual for that to be a significant amount though.
--
Darren
# 3
> Darren Dunham Replied:
>> I am trying to figure out why a machine with lots of
>> unused RAM is using so much swap.
>>
>> I have a V240 running Solaris 10. Its running a
>> large Oracle db.
>> The 4th line of /opt/sfw/bin/top shows:
>>
>> Memory: 8192M real, 4907M free, 2143M swap in
>> use, 18G swap free
>
> Okay, so only 2G.
>
>> Running '/opt/sfw/bin/df -t ufs -t nfs -t tmpfs -h',
>
> df gives information about filesystems. It's a poor tool for
> information about paging space.
I was thinking that perhaps some large job ran, consumed all
of RAM plus 2GB of swap. And, after things died down and
memory was reclaimed that some unused /tmp files may be out
there. I guess that could not have been the case?
> Instead, try 'swap -s' and 'swap -l'. Lets see how much is
> initialized and how much is simply reserved.
# swap -l
swapfile dev swaplo blocksfree
/dev/dsk/c1t0d0s132,116 16780208 16780208
/dev/dsk/c1t1d0s132,916 16780208 16780208
# swap -s
total: 1939352k bytes allocated + 233752k reserved =
2173104k used, 19534872k available
All I see is reserved. This means its not actually used?
So, when top says "2143M swap in use", it is incorrect?
>
>> Knowing that using swap degrades performance, can
>> anyone tell me
>> if this is normal? How to identify what processes
>> are swapped?
>
> "swapping" (or more likely "paging") can degrade peformance. But
> simply allocating swap space (something that Oracle is fond of
> doing) is not something that will affect performance.
>
> As long as you're not low on RAM, the system should not be paging
> out in-use RAM pages. That's the event that causes disruption.
>
> Identifying paging processes isn't simple (especially when you're
> running things like oracle that have very complex memory usage).
>
> You can use 'ps' and look at the RES and SIZE columns. If RES is
> much lower than SIZE it *can* point to memory being evicted.
> However it is possible for some pages to be in use and simply never
> swapped in in the first place. It would be unusual for that to be a
> significant amount though.
Here is the output of top when sorted by size:
PID USERNAME THR PRI NICE SIZERES STATETIMECPU COMMAND
903 root27 590 136M57M sleep46:24 0.03% java
11585 root11 54021M15M sleep24:25 3.22% bpbkar
11584 root1 22014M 3624K cpu/1 114:35 13.69% bpfilter
379 root16 59012M 8200K sleep0:46 0.00% fmd
9 root15 590 9840K 8888K sleep1:49 0.00% svc.configd
13542 root1 590 9760K 4464K sleep0:03 0.00% smbd
I don't see anything approaching 2GB. Is top a poor tool, as well?
From the DTrace ToolKit,
# dtrace -s swapinfo.d
RAM _Total 8192 MB
RAMUnusable53 MB
RAMKernel692 MB
RAMLocked 1618 MB
RAM Used 1308 MB
RAM Free 4519 MB
Disk _Total 16386 MB
Disk Resv 2160 MB
DiskAvail 14226 MB
Swap _Total 21197 MB
Swap Resv 2160 MB
SwapAvail 19036 MB
Swap(Minfree) 1017 MB
Does this mean no swap space is actually in use?
I cannot seem to locate a source to explain the concept of swap
reservation. What problem does it solve? Does it apply to space
the kernel allocates (like the process's stacks)? ie, can a
process really guarantee it will never run out of memory
resources?
Thank you!
# 4
> I was thinking that perhaps some large job ran,
> consumed all
> of RAM plus 2GB of swap. And, after things died down
> and
> memory was reclaimed that some unused /tmp files may
> be out
> there. I guess that could not have been the case?
It could be, but seems unlikely.
> > Instead, try 'swap -s' and 'swap -l'. Lets see how
> much is
> > initialized and how much is simply reserved.
>
> > # swap -l
> swapfile dev swaplo blocksfree
> /dev/dsk/c1t0d0s132,116 16780208 16780208
> /dev/dsk/c1t1d0s132,916 16780208 16780208
>
Great, so there is zero memory pressure in effect at this time. All of your paging space is uninitialized (but that doesn't mean that it's not counted against).
Uninitialized swap space isn't written to, so there is no performance impact. Performance problems happen when we're busy writing to the disk instead of doing other work.
> # swap -s
> total: 1939352k bytes allocated + 233752k reserved =
>2173104k used, 19534872k available
> l I see is reserved. This means its not actually
> used?
Sort of, yes. The system must have free space in the Virtual Memory space if a process needs memory. But if it doesn't initialize the space, then it "counts" it that the paging space is in use.
Chances are that the space will never be used, so no I/O will happen and the RAM is free for other pages that will use it. If the reservation was made from RAM in the first place, then less is available for other processes.
> So, when top says "2143M swap in use", it is
> incorrect?
No, but I think you're thinking of "swap" differently from the utilities.
"swap" in most solaris utilities tends to mean "virtual memory", not "some space on disk". See the details of "swap -s". You are using ~2143MB of VM, but most of that is real allocation (in RAM), only 200 some MB of it is reservation against paging space.
--
Darren