Lmbench results for Linux/MIPS 2.1.90
Hi all,
here is another round of lmbench results. Most notably all benchmarks that depend on the overhead of syscall entry have improved remarkably. For comparison I've included some more machines in the table.
The machines:
indy: Indy R5000SC 180MHz, 512mb l2 cache, 96mb memory.
sv002076: Sun Ultra Enterprise E450, 2 x 296MHz Ultra2 CPUs,
1gb memory (two interleaved).
dull: Dell Pentium 200 MMX, 32mb, running Redhat's 2.0.27.
tbird: SNI RM200, R4600 133MHz, no second level cache, 32mb memory.
I'm thinking about not saving the temporary registers on syscall entry; I'm just not shure if this would break the semantics of ptrace(2). Comments?
Btw, it's a shame for Sun than we can beat their numbers on so much weaker hardware.
Ralf
L M B E N C H 1 . 9 S U M M A R Y
------------------------------------
(Alpha software, do not distribute)
Processor, Processes - times in microseconds - smaller is better
----------------------------------------------------------------
Host OS Mhz null null open selct sig sig fork exec sh
call I/O stat clos inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ----- ---- ---- ---- ---- ----
indy IRIX 6.2 180 2.9 10.0 88 110 2.44K 6.2 36 7.0K 19K 32K sv002076 SunOS 5.5.1 196 2.6 4.7 31 34 0.21K 5.6 48 2.2K 12K 23K dull.coba Linux 2.0.27 200 1.1 1.8 29 44 0.08K 2.5 5 0.8K 5K 15K indy.wald Linux 2.1.73 180 4.5 5.4 24 29 0.11K 7.3 19 18.3K 18K 65K indy.wald Linux 2.1.90 180 1.3 2.1 23 29 0.10K 3.6 10 1.7K 18K 60K tbird.wal Linux 2.1.56 133 6.4 9.2 42 56 0.19K 11.7 26 2.1K 26K 83K
Context switching - times in microseconds - smaller is better
-------------------------------------------------------------
Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw
--------- ------------- ----- ------ ------ ------ ------ ------- -------
indy IRIX 6.2 13 20 135 94 301 143 482 sv002076 SunOS 5.5.1 12 16 14 40 23 48 92 dull.coba Linux 2.0.27 5 52 171 64 244 75 325 indy.wald Linux 2.1.73 1 27 238 322 780 indy.wald Linux 2.1.90 2 36 205 55 655 92 717
tbird.wal Linux 2.1.56 14 176 506 177 516 178 513
*Local* Communication latencies in microseconds - smaller is better
-------------------------------------------------------------------
Host OS 2p/0K Pipe AF UDP RPC/ TCP RPC/ TCP
ctxsw UNIX UDP TCP conn
--------- ------------- ----- ----- ---- ----- ----- ----- ----- ----
indy IRIX 6.2 13 62 126 356 718 361 689 1321 sv002076 SunOS 5.5.1 12 48 70 130 118 840 dull.coba Linux 2.0.27 5 19 36 89 212 139 289 1276 indy.wald Linux 2.1.73 1 48 103 105 258 165 412 597 indy.wald Linux 2.1.90 2 15 31 91 251 170 409 581 tbird.wal Linux 2.1.56 14 75 168 351 795 575 1120 1549
File & VM system latencies in microseconds - smaller is better
--------------------------------------------------------------
Host OS 0K File 10K File Mmap Prot Page
Create Delete Create Delete Latency Fault Fault
--------- ------------- ------ ------ ------ ------ ------- ----- -----
indy IRIX 6.2 450 813 1694 2325 3317 23.0K
sv002076 SunOS 5.5.1 2083 826 2777 3030 4066 13 8.2K
dull.coba Linux 2.0.27 59 4 106 9 7582 2 0.1K
indy.wald Linux 2.1.73 112 28 12222 16 0.3K
indy.wald Linux 2.1.90 11000 2 0.3K
tbird.wal Linux 2.1.56 143 34 15026 0 0.3K*Local* Communication bandwidths in MB/s - bigger is better
-----------------------------------------------------------
Host OS Pipe AF TCP File Mmap Bcopy Bcopy Mem Mem
UNIX reread reread (libc) (hand) read write
--------- ------------- ---- ---- ---- ------ ------ ------ ------ ---- -----
indy IRIX 6.2 33 39 26 23 57 26 54 57 43 sv002076 SunOS 5.5.1 99 134 95 146 156 296 139 157 208 dull.coba Linux 2.0.27 53 29 23 41 121 49 51 123 88 indy.wald Linux 2.1.73 57 18 7 28 60 0 0 0 0 indy.wald Linux 2.1.90 65 26 15 27 60 0 0 0 0 tbird.wal Linux 2.1.56 22 16 4 25 77 38 74 77 56
Memory latencies in nanoseconds - smaller is better
(WARNING - may not be correct, check graphs)
---------------------------------------------------
Host OS Mhz L1 $ L2 $ Main mem Guesses --------- ------------- --- ---- ---- -------- ------- indy IRIX 6.2 180 11 197 485 sv002076 SunOS 5.5.1 196 6 33 248 dull.coba Linux 2.0.27 200 10 88 146 indy.wald Linux 2.1.73 180 10 250 480 indy.wald Linux 2.1.90 180 10 190 480 tbird.wal Linux 2.1.56 133 15 274 281 No L2 cache?
Quoted 11 lines · William J. Earl
Quoted 2 lines
I'm thinking about not saving the temporary registers on syscall entry; I'm just not shure if this would break the semantics of ptrace(2).
...
UMIPS-BSD (4.3 BSD on the MIPS M/1000) did not save the temporary
registers onsyscall(). It did, of course, save them on interrupts, so preemption left the registers valid. I don't see why saving the registers on syscall should affectptrace(), since theptrace()caller is acting on another process, which will have saved all its registers if preempted. That change ought to let the R5000 beat the Pentium, despite the Indy's miserable memory latency.
That's implemented now. I'm also pulling another trick. Why the hell should be save all the s-registers during system calls? The MIPS calling sequence guarantees to us that they will not be destroyed. Whoops, another 150us or so. It's what brought us down to 861ns, faster than big bad Pentium from Borg. All that it takes is adding some extra code; sys_fork(), sys_clone() and do_signal expect the s-registers to be in the stackframe, so I save them only in these routines.
I'm thinking about changing the calling sequence of syscalls as well. When we get more than four arguments passed, we have to dig them out of the userstack. While this is fast on Linux we still need time for the safety checks. The t registers which are being clobbered anyway would be sooo nice to pass them.
(Hey people, remember I told ya static linking is evil? That change would fry all your binaries ... still time to relink :-)
Ralf
[email protected] writes:
...
Quoted 7 lines
That's implemented now. I'm also pulling another trick. Why the hell should be save all the s-registers during system calls? The MIPS calling sequence guarantees to us that they will not be destroyed. Whoops, another 150us or so. It's what brought us down to 861ns, faster than big bad Pentium from Borg. All that it takes is adding some extra code;
sys_fork(),sys_clone()anddo_signalexpect the s-registers to be in the stackframe, so I save them only in these routines.
Yes, UMIPS-BSD (but not IRIX or RISC/os) did that too. The 861 ns.
also means that you are not getting any cache misses at all, which is very nice. (Some systems seem to think a system call without a cache miss is a day without sunshine. :-) )
Quoted 8 lines
I'm thinking about changing the calling sequence of syscalls as well. When we get more than four arguments passed, we have to dig them out of the userstack. While this is fast on Linux we still need time for the safety checks. The t registers which are being clobbered anyway would be sooo nice to pass them.
(Hey people, remember I told ya static linking is evil? That change would fry all your binaries ... still time to relink :-)
You could or some suitable higher-order bit into the system call number
to distinguish the two cases (and mask it off in syscall before indexing the system call table). Since you have the system call number in a register, that should be pretty cheap to check.
Instead of changing the calling sequence, perhaps you could
do the fetching in a special assembly subroutine, and have the trap handler notice if $epc is in the routine at the instruction which fetches from the user space. If so, it could change $epc to some recovery address in the assembly routine, which would return the fault indication. (There would probably be multiple load instructions in a fully unrolled routine, but that would just be more locations to accept as valid exception points.) This takes cycles out of the normal path, at the cost of cycles in the trap path (for kernel traps only, and then only for cases which are going to turn into EFAULT anyway).
Quoted 5 lines · William J. Earl
You could or some suitable higher-order bit into the system call number
to distinguish the two cases (and mask it off in syscall before indexing the system call table). Since you have the system call number in a register, that should be pretty cheap to check.
Quoted 10 lines
Instead of changing the calling sequence, perhaps you could
do the fetching in a special assembly subroutine, and have the trap handler notice if $epc is in the routine at the instruction which fetches from the user space. If so, it could change $epc to some recovery address in the assembly routine, which would return the fault indication. (There would probably be multiple load instructions in a fully unrolled routine, but that would just be more locations to accept as valid exception points.) This takes cycles out of the normal path, at the cost of cycles in the trap path (for kernel traps only, and then only for cases which are going to turn into EFAULT anyway).
Nice trick. It's what the entire Linux kernel is already using :-) In Linux 2.0 all pointers to userland had to be verified by a routine named verify_area. That routine was implemented by walking the tables of valid memory mappings. It accounted for upto 20% of the kernel's processing time for certain applications and was not threadsafe for example for the following scenario:
- Thread A makes a syscall which tries to access the userspace. The kernel verifies the pointer and find it to be ok. The kernel then uses the pointer to access userspace and catches a pagefault.
- Due to the pagefault the scheduler now elects another thread B which is sharing it's memory mappings with the process A, similar to sproc(2) created threads under IRIX. Thread B unmaps the area which just has been passed by process A to the kernel
- The scheduler reruns process A again which uses the now invalid pointer to access the userspace. Next scene, ungracefull death of a process:
[...]
printk(KERN_ALERT "Unable to handle kernel paging request at virtual "
"address %08lx, epc == %08lx, ra == %08lx\n",
address, regs->cp0_epc, regs->regs[31]);
die_if_kernel("Oops", regs, writeaccess);
do_exit(SIGKILL);[...]
Implementing things as you suggest not only made things threadsafe, it also eleminated the fraction of CPU time for verify_area almost completly. That's all that is left:
[...]
#define __access_ok(addr,size,mask) \
(((__signed__ long)((mask)&(addr | size | (addr+size)))) >= 0)#define __access_mask (-(long)(get_fs().seg))
#define access_ok(type,addr,size) \__access_ok(((unsigned long)(addr)),(size),__access_mask)
extern inline int verify_area(int type, const void * addr, unsigned long size)
{
return access_ok(type,addr,size) ? 0 : -EFAULT;
}[...]
Linux uses a special ELF section to collect all the fixup routines and data which makes it easy to keep the table of potencially faulting instructions in sorted order. That way the exception handler can search the tables using binary search and still handle the error case pretty fast.
Anyway, there are other more worthwile victims than the syscall handler. The TCP bandwidth via loopback is half of what IRIX does, that's unacceptable :-)
Ralf