ref: b72abe8762978bd6162a104e75985628891c3872
parent: 311e5280279f8d56983df2abae50d545a24ff290
author: Ori Bernstein <[email protected]>
date: Wed Aug 9 00:17:00 EDT 2023
cmd: use increased iounit add IOUNIT to libc, and replace hard-coded 8k buffers throughout userspace; this increases the speed for reading the framebuffer by a factor of at least 3x, as well as increasing fs performance by a similar amount, at least on synthetic benchmarks.
--- a/sys/include/ape/lib9.h
+++ b/sys/include/ape/lib9.h
@@ -7,6 +7,8 @@
#include <u.h> /* ick; need Rune defined below */
+#define IOUNIT 32768U /* default buffer size for 9p io */
+
#define MORDER 0x0003 /* mask for bits defining order of mounting */
#define MREPL 0x0000 /* mount replaces object */
#define MBEFORE 0x0001 /* mount goes before others in union directory */
--- a/sys/include/bio.h
+++ b/sys/include/bio.h
@@ -6,7 +6,7 @@
enum
{
- Bsize = 8*1024,
+ Bsize = IOUNIT,
Bungetsize = UTFmax+1, /* space for ungetc */
Bmagic = 0x314159,
Beof = -1,
--- a/sys/include/libc.h
+++ b/sys/include/libc.h
@@ -576,6 +576,7 @@
* system calls
*
*/
+#define IOUNIT 32768U /* default buffer size for 9p io */
#define STATMAX 65535U /* max length of machine-independent stat structure */
#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
#define ERRMAX 128 /* max length of error string */
--- a/sys/src/cmd/1a/a.h
+++ b/sys/src/cmd/1a/a.h
@@ -15,7 +15,7 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
+#define BUFSIZ IOUNIT
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
--- a/sys/src/cmd/1l/l.h
+++ b/sys/src/cmd/1l/l.h
@@ -114,7 +114,7 @@
NHUNK = 100000,
MINSIZ = 4,
STRINGSZ = 200,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
A6OFFSET = 32766,
};
--- a/sys/src/cmd/2a/a.h
+++ b/sys/src/cmd/2a/a.h
@@ -15,7 +15,7 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
+#define BUFSIZ IOUNIT
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
--- a/sys/src/cmd/2l/l.h
+++ b/sys/src/cmd/2l/l.h
@@ -116,7 +116,7 @@
NHUNK = 100000,
MINSIZ = 4,
STRINGSZ = 200,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
A6OFFSET = 32766
};
--- a/sys/src/cmd/5a/a.h
+++ b/sys/src/cmd/5a/a.h
@@ -12,7 +12,7 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 8192
-#define BUFSIZ 8192
+#define BUFSIZ IOUNIT
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
--- a/sys/src/cmd/5l/l.h
+++ b/sys/src/cmd/5l/l.h
@@ -197,7 +197,7 @@
NHUNK = 100000,
MINSIZ = 64,
NENT = 100,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
Roffset = 22, /* no. bits for offset in relocation address */
--- a/sys/src/cmd/6l/l.h
+++ b/sys/src/cmd/6l/l.h
@@ -118,7 +118,7 @@
MINSIZ = 8,
STRINGSZ = 200,
MINLC = 1,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
Yxxx = 0,
--- a/sys/src/cmd/7a/a.h
+++ b/sys/src/cmd/7a/a.h
@@ -17,7 +17,7 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 8192
-#define BUFSIZ 8192
+#define BUFSIZ IOUNIT
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
--- a/sys/src/cmd/7l/l.h
+++ b/sys/src/cmd/7l/l.h
@@ -238,7 +238,7 @@
STRINGSZ = 200,
NHASH = 10007,
NHUNK = 100000,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
};
--- a/sys/src/cmd/8a/a.h
+++ b/sys/src/cmd/8a/a.h
@@ -14,7 +14,7 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
+#define BUFSIZ IOUNIT
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
--- a/sys/src/cmd/8l/l.h
+++ b/sys/src/cmd/8l/l.h
@@ -110,7 +110,7 @@
MINSIZ = 4,
STRINGSZ = 200,
MINLC = 1,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
Yxxx = 0,
--- a/sys/src/cmd/9660srv/main.c
+++ b/sys/src/cmd/9660srv/main.c
@@ -7,7 +7,7 @@
enum
{
- Maxfdata = 8192,
+ Maxfdata = IOUNIT,
Maxiosize = IOHDRSZ+Maxfdata,
};
--- a/sys/src/cmd/cat.c
+++ b/sys/src/cmd/cat.c
@@ -4,7 +4,7 @@
void
cat(int f, char *s)
{
- char buf[8192];
+ char buf[IOUNIT];
long n;
while((n=read(f, buf, sizeof buf))>0)
--- a/sys/src/cmd/cp.c
+++ b/sys/src/cmd/cp.c
@@ -1,8 +1,6 @@
#include <u.h>
#include <libc.h>
-#define DEFB (8*1024)
-
int buflen;
int failed;
int gflag;
@@ -125,7 +123,7 @@
buflen = iounit(fdf);
if(buflen <= 0)
- buflen = DEFB;
+ buflen = IOUNIT;
if(copy1(fdf, fds < 0 ? fdt : fds, from, to)==0){
if(fds >= 0 && write(fds, "", 0) < 0){
--- a/sys/src/cmd/crc32.c
+++ b/sys/src/cmd/crc32.c
@@ -38,7 +38,7 @@
sum(int fd, char *name)
{
int n;
- uchar buf[8192];
+ uchar buf[IOUNIT];
u32int crc;
crc = init ^ xor;
--- a/sys/src/cmd/cwfs/portdat.h
+++ b/sys/src/cmd/cwfs/portdat.h
@@ -22,7 +22,7 @@
/* constants that don't affect disk layout */
enum {
- MAXDAT = 8192, /* max allowable data message */
+ MAXDAT = IOUNIT, /* max allowable data message */
MB = 1024*1024,
};
--- a/sys/src/cmd/exportfs/exportfs.c
+++ b/sys/src/cmd/exportfs/exportfs.c
@@ -83,7 +83,7 @@
if(messagesize == 0){
messagesize = iounit(0);
if(messagesize == 0)
- messagesize = 8192+IOHDRSZ;
+ messagesize = IOUNIT+IOHDRSZ;
}
fhash = emallocz(sizeof(Fid*)*FHASHSIZE);
--- a/sys/src/cmd/ka/a.h
+++ b/sys/src/cmd/ka/a.h
@@ -12,7 +12,7 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 500
-#define BUFSIZ 8192
+#define BUFSIZ IOUNIT
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
--- a/sys/src/cmd/kl/l.h
+++ b/sys/src/cmd/kl/l.h
@@ -96,7 +96,7 @@
FPCHIP = 1,
BIG = 4096-8,
STRINGSZ = 200,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
DATBLK = 1024,
NHASH = 10007,
--- a/sys/src/cmd/lnfs.c
+++ b/sys/src/cmd/lnfs.c
@@ -10,7 +10,7 @@
{
OPERM = 0x3, /* mask of all permission types in open mode */
Maxsize = 512*1024*1024,
- Maxfdata = 8192,
+ Maxfdata = IOUNIT,
NAMELEN = 28,
};
--- a/sys/src/cmd/md5sum.c
+++ b/sys/src/cmd/md5sum.c
@@ -23,7 +23,7 @@
sum(int fd, char *name)
{
int n;
- uchar buf[8192], digest[MD5dlen];
+ uchar buf[IOUNIT], digest[MD5dlen];
DigestState *s;
s = md5(nil, 0, nil, nil);
--- a/sys/src/cmd/mothra/html.h
+++ b/sys/src/cmd/mothra/html.h
@@ -2,7 +2,7 @@
* Parameters
*/
#define NSTACK 100 /* html grammar is not recursive, so 30 or so should do */
-#define NHBUF 8192 /* Input buffer size */
+#define NHBUF IOUNIT /* Input buffer size */
#define NPEEKC 3 /* Maximum lookahead */
#define NTOKEN 65536 /* Maximum token length */
#define NATTR 512 /* Maximum number of attributes of a tag */
--- a/sys/src/cmd/mv.c
+++ b/sys/src/cmd/mv.c
@@ -167,7 +167,7 @@
int
copy1(int fdf, int fdt, char *from, char *to)
{
- char buf[8192];
+ char buf[IOUNIT];
long n, n1;
while ((n = read(fdf, buf, sizeof buf)) > 0) {
--- a/sys/src/cmd/os.c
+++ b/sys/src/cmd/os.c
@@ -20,7 +20,7 @@
char *mnt = "/mnt/term/cmd";
char *dir = nil;
-char buf[8192];
+char buf[IOUNIT];
int fd[Nfd] = {-1};
int pid[Npid];
int nice, foreground = 1;
--- a/sys/src/cmd/qa/a.h
+++ b/sys/src/cmd/qa/a.h
@@ -12,7 +12,7 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 8192
-#define BUFSIZ 8192
+#define BUFSIZ IOUNIT
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
--- a/sys/src/cmd/ql/l.h
+++ b/sys/src/cmd/ql/l.h
@@ -93,7 +93,7 @@
FPCHIP = 1,
BIG = 32768-8,
STRINGSZ = 200,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
DATBLK = 1024,
NHASH = 10007,
--- a/sys/src/cmd/sha1sum.c
+++ b/sys/src/cmd/sha1sum.c
@@ -43,7 +43,7 @@
sum(int fd, char *name)
{
int n;
- uchar buf[8192], digest[SHA2_512dlen];
+ uchar buf[IOUNIT], digest[SHA2_512dlen];
DigestState *s;
s = (*shafunc)(nil, 0, nil, nil);
--- a/sys/src/cmd/tee.c
+++ b/sys/src/cmd/tee.c
@@ -11,7 +11,7 @@
int aflag;
-char in[8192];
+char in[IOUNIT];
int intignore(void*, char*);
--- a/sys/src/cmd/va/a.h
+++ b/sys/src/cmd/va/a.h
@@ -12,7 +12,7 @@
#define MAXALIGN 7
#define FPCHIP 1
#define NSYMB 8192
-#define BUFSIZ 8192
+#define BUFSIZ IOUNIT
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
--- a/sys/src/cmd/vl/l.h
+++ b/sys/src/cmd/vl/l.h
@@ -163,7 +163,7 @@
NHUNK = 100000,
MINSIZ = 64,
NENT = 100,
- MAXIO = 8192,
+ MAXIO = IOUNIT,
MAXHIST = 20, /* limit of path elements for history symbols */
};
--- a/sys/src/cmd/vnc/devdraw.c
+++ b/sys/src/cmd/vnc/devdraw.c
@@ -36,7 +36,6 @@
#define NHASH (1<<5)
#define HASHMASK (NHASH-1)
-#define IOUNIT (64*1024)
typedef struct Client Client;
typedef struct Draw Draw;