Top is designed for Linux. The free concept in the FreeBSD VM is completely different from the rest of the OS, and using top to view the available memory is meaningless for FreeBSD. The right way is to look at Vmstat.
# Vmstat
procs Memory page disk faults CPU
R B W AVM fre Flt re pi po fr SR ad0 in sy CS US sy ID
0 2 1 270512 20316 0 0 0 approx 5 1223 1589 98 593 1 1 99
It is best to use the Vmstat t [n] command, such as Vmstat 5 10, to indicate N (10) samples in T (5) seconds. If you use only vmstat, you cannot reflect the real system situation.
Procs:
r--> Number of processes running
b--> number of processes waiting for IO (waiting for i/o,paging, etc.)
W--> can enter a process that runs the queue but is replaced
Memoy (virtual memory in kilobytes, including virtual kernel and real memory, running or last 20 seconds of running processes is considered active)
Avm--> Active Virtual Memory
Free--> of idle Memory
Pages (statistical error pages and active pages, averaging every 5 seconds, giving values in seconds)
Flt--> Total Error pages
Re--> Recycled Pages
Pi--> number of pages entered
Po--> Number of page out
fr--> Number of free pages
sr--> pages scanned by the clock algorithm per second
Disk Displays the disks per second (the first two letters of the disk name plus a number, the default is only two disks, if there are many, you can add-N to increase the number or the command line to fill the disk names. )
Fault display of interrupts per second
In--> Device Interrupt
Sy--> System Interrupt
CS-->CPU Exchange (context switch)
CPU indicates usage status of CPU
Cs--> time used by the user process
Sy--> time used by the system process
ID-->CPU Idle Time
If R is often greater than 4 and the ID is often less than 40, it indicates that the CPU is heavily loaded.
If the Pi,po is not equal to 0 for a long time, it indicates insufficient memory.
If disk is often not equal to 0, and the queue in B is greater than 3, the IO performance is poor.
Here is a vmstat example of a busy batch inserting MySQL data (approximately 500,000 data per 20 seconds):
procs Memory page disks faults CPU
R B W AVM fre Flt re pi po fr SR da0 da1 in sy CS US sy ID
1 0 23302M 803M 845 0 0 0 0 0 0 0 124 499 6 0 94
1 0 23302M 796M 837 0 0 0 2 0 1 0 158 505 6 0 94
1 0 23302M 790M 833 0 0 0 6 0 159 0 143 910 6 0 94
1 0 ( 23302M) 784M 868 0 0 0 0 8 0 156 550 6 0 94
2 0 23456M 709M 8317 2 0 0 2383 0 up 0 295 5504 1930 8 1 91
1 0 21975M 1281M 18909 3 0 0 94840 0 620 0 1893 64333 7822 ten 4 87
1 0 21975M 1281M 415 0 0 0 342 0 1 0 611 566 6 0 94
1 0 22093M 978M 43503 0 0 0 5140 0 2187 0 4225 582 16279 6 2 92
Loops are inserted in the back, and as the table grows larger, system calls and context switches become more frequent:
procs Memory page disks faults CPU
R B W AVM fre Flt re pi po fr SR da0 da1 in sy CS US sy ID
1 0 23233M 536M 28219 0 0 0 352 51252 869 0 1864 14542 11015 2 3 95
1 0 23349M 834M 12457 0 0 0 4 51247 2078 0 3945 179 14926 6 2 92
2 0 27343M 3130M 9295 0 0 0 2708 0 2 0 73 6988 1377 7 1 92
.... The middle is normal, because the insertion time is relatively long
1 0 28788M 2934M 25760 0 0 0 5860 0 620 8 5529 42712 12924 2 86
0 0 25963M 3081M 4379 0 0 0 24049 0 3445 11274 97350 31798 2 7 91
0 0 33689M 1801M 388 0 0 0 4492 0 4403 8780 135421 35502 2 5 93
Not familiar with MySQL internals, but obviously, as the table grows larger and slower, table insertions become more and more slow as system calls and context switches become more frequent, wasting a lot of CPU time.
To the MySQL table has more than 60 million data, each insert 500,000 records, has taken time to take 100s, the entire MySQL database becomes very busy, some tens of thousands of data insertion also slowly can not be processed in time.
The following is an example of a vmstat copy of a 4G file to a remote NFS:
procs memory page disks faults CPU
R B W AVM Fre Flt re Pi Po FR sr da0 da1 in SY CS US sy ID
2 0 19731M 2400M 24415 0 0 0 70077 0 14 0 591 3915 1770 1 0 0 16352M 3594M 443 0 0 0 154948 0 2471 0 5067 17602 19448 1 2
0 0 + 16352M 359 4M 0 0 0 0 0 0 772 0 1590 134 6577 0 0
0 0 16352M 3594M 0 0 0 0 0 0 856 0 1750 164 7135 0 0
0 0 16361M 3594M 1112 0 0 0 1030 0 0 815 1248 3620 0 0
0 0 16361M 3594M 0 0 0 0 0 0 0 0 488 0 0 +
0 0 + 16352M 3594M 329 0 0 0 352 0 2186 0 4275 595 15809 0 2 98
0 0 16352M 3594M 0 0 0 0 0 0 270 0 532 134 318 6 0 0
0 0 16352M 3594M 0 0 0 0 0 0 185 0 368 164 2062 0 0
Finally stabilized, the vmstat example of good condition:
procs Memory page disks faults CPU
R B W AVM fre Flt re pi po fr SR da0 da1 in sy CS US sy ID
0 0 16292M 3564M 0 0 0 0 0 0 0 0 142 472 0 0 100
FreeBSD Vmstat Detailed (with example)