Some numbers with forth userspace instead of dis/limbo

37 views
Skip to first unread message

Go Phone

unread,
Jan 28, 2022, 1:17:55 PM1/28/22
to inferno-os
Hello,

Here are some numbers when using a forth user space on native amd64
architecture instead of dis/limbo.

The time file holds one 32-bit number representing the sec-
onds since start of epoch and three 64-bit numbers, repre-
senting nanoseconds since start of epoch, clock ticks, and
clock frequency.

forth userspace on 9ferno (mostly 9front's code but for linear memory
and no syscall gate)
variable M
" #c/time" r/o open-file drop M !
: sread M @ Tib 256 + 128 M @ Tib 128 sysread drop sysread Tib 78 type
cr Tib 256 + 78 type ;

with asm address checking in forth's sysread
/* move this check to a forth equivalent of inferno.c? */
MOVQ TOP, CX
CMPQ CX, $0 /* negative n? */
JLT belowum
ADDQ (PSP), CX /* CX = a+n */
CMPQ CX, UME /* a+n, UME */
JGT aboveume /* a+n > UME */
CMPQ (PSP), UM /* a, UM */
JLT belowum /* a < UM */
335 335282228353 102415023360 305454592
335 335282369153 102415066368 305454592

140,800 nano seconds
43,008 clock ticks

1913 1913974741355 584635821056 305454592
1913 1913974882993 584635864320 305454592

141,638 nano seconds
43,264 clock ticks

no address bounds checking - wild west, no practical use
sread
231 231921559208 70843783168 305454592
231 231921697494 70843825408 305454592

138,286 nano seconds
42,240 clock ticks

with address bounds checking in kread (or, add address checking
wrapper for a forth equivalent of inferno.c)
206 206729249913 63147925760 305454592
206 206729399094 63147971328 305454592

149,181 nano seconds
45,568 clock ticks


from C userspace on 9front:
#include "u.h"
#include "libc.h"

void
main(int, char*)
{
int mfd, nfd, m, n;
char mcontents[128] = "";
char ncontents[128] = "";

mfd = open("#c/time", OREAD);
nfd = open("#c/time", OREAD);
m = read(mfd, mcontents, 128);
n = read(nfd, ncontents, 128);
print("1st run: %s\n", mcontents);
print("2nd run: %s\n", ncontents);
close(mfd);
close(nfd);
}
1st run: 1643331320 1643331320070261160 184059902464 304950735
2rd run: 1643331320 1643331320070423179 184059951872 304950735

162,019 nano seconds
49,408 clock ticks

running the above program multiple times
1st run: 1643369841 1643369841099724677 97730329600 305120243
2nd run: 1643369841 1643369841099890802 97730380208 305120243

166,125 nano seconds
50,608 clock ticks

from rc shell:
cat '#c/time'; cat '#c/time'
1643331484 1643331484744627193 234294552576 304978487
1643331484 1643331484765251558 234300845312 304978487

20,624,365 nano seconds
6,293,736 clock ticks


The rc numbers above are not fair as rc is doing a lot more than just
syscalls. But, adding it in for comparison.

Thanks
Reply all
Reply to author
Forward
0 new messages