lesson learned from http://k1024.org/~iusty/blog/entry/perf-null/ – add -DMKSH_SMALL_BUT_FAST which gives more speed (8/20K less cycles, 5/9K less insns, 1.8/2.4k less branches, 65/275 less branch misses) on Debian/amd64 (klibc-static/eglibc) at cost of 0/2 more page faults and 6K/6K more text size

This commit is contained in:
tg 2012-07-01 15:55:00 +00:00
parent 798cfdc982
commit 4778a2a62f
7 changed files with 19 additions and 18 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.578 2012/07/01 15:51:24 tg Exp $' srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.579 2012/07/01 15:54:49 tg Exp $'
#- #-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 # 2011, 2012
@ -1486,7 +1486,7 @@ else
#define EXTERN #define EXTERN
#define MKSH_INCLUDES_ONLY #define MKSH_INCLUDES_ONLY
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.578 2012/07/01 15:51:24 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.579 2012/07/01 15:54:49 tg Exp $");
int main(void) { printf("Hello, World!\n"); return (0); } int main(void) { printf("Hello, World!\n"); return (0); }
EOF EOF
case $cm in case $cm in
@ -2285,6 +2285,7 @@ MKSH_NO_LIMITS omit ulimit code
MKSH_NO_SIGSETJMP define if sigsetjmp is broken or not available MKSH_NO_SIGSETJMP define if sigsetjmp is broken or not available
MKSH_NO_SIGSUSPEND use sigprocmask+pause instead of sigsuspend MKSH_NO_SIGSUSPEND use sigprocmask+pause instead of sigsuspend
MKSH_SMALL omit some code, optimise hard for size (slower) MKSH_SMALL omit some code, optimise hard for size (slower)
MKSH_SMALL_BUT_FAST disable some hard-for-size optim. (modern sys.)
MKSH_S_NOVI=1 disable Vi editing mode (default if MKSH_SMALL) MKSH_S_NOVI=1 disable Vi editing mode (default if MKSH_SMALL)
MKSH_TYPEDEF_SIG_ATOMIC_T define to e.g. 'int' if sig_atomic_t is missing MKSH_TYPEDEF_SIG_ATOMIC_T define to e.g. 'int' if sig_atomic_t is missing
MKSH_TYPEDEF_SSIZE_T define to e.g. 'long' if your OS has no ssize_t MKSH_TYPEDEF_SSIZE_T define to e.g. 'long' if your OS has no ssize_t

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.549 2012/06/28 20:17:35 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.550 2012/07/01 15:54:51 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -29,7 +29,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD # http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R40 2012/06/28 @(#)MIRBSD KSH R40 2012/07/01
description: description:
Check version of shell. Check version of shell.
stdin: stdin:
@ -38,7 +38,7 @@ name: KSH_VERSION
category: shell:legacy-no category: shell:legacy-no
--- ---
expected-stdout: expected-stdout:
@(#)LEGACY KSH R40 2012/06/28 @(#)LEGACY KSH R40 2012/07/01
description: description:
Check version of legacy shell. Check version of legacy shell.
stdin: stdin:

4
edit.c
View File

@ -28,7 +28,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING #ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.238 2012/07/01 15:36:18 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.239 2012/07/01 15:54:53 tg Exp $");
/* /*
* in later versions we might use libtermcap for this, but since external * in later versions we might use libtermcap for this, but since external
@ -88,7 +88,7 @@ static int x_vi(char *, size_t);
#endif #endif
#define x_flush() shf_flush(shl_out) #define x_flush() shf_flush(shl_out)
#ifdef MKSH_SMALL #if defined(MKSH_SMALL) && !defined(MKSH_SMALL_BUT_FAST)
#define x_putc(c) x_putcf(c) #define x_putc(c) x_putcf(c)
#else #else
#define x_putc(c) shf_putc((c), shl_out) #define x_putc(c) shf_putc((c), shl_out)

4
lex.c
View File

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.164 2012/06/28 20:05:07 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.165 2012/07/01 15:54:55 tg Exp $");
/* /*
* states while lexing word * states while lexing word
@ -131,7 +131,7 @@ short subshell_nesting_level = 0;
return (cev); \ return (cev); \
} }
#ifdef MKSH_SMALL #if defined(MKSH_SMALL) && !defined(MKSH_SMALL_BUT_FAST)
static int getsc(void); static int getsc(void);
static int static int

4
misc.c
View File

@ -30,7 +30,7 @@
#include <grp.h> #include <grp.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.194 2012/06/26 19:22:19 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.195 2012/07/01 15:54:56 tg Exp $");
#define KSH_CHVT_FLAG #define KSH_CHVT_FLAG
#ifdef MKSH_SMALL #ifdef MKSH_SMALL
@ -2006,7 +2006,7 @@ strstr(char *b, const char *l)
} }
#endif #endif
#ifdef MKSH_SMALL #if defined(MKSH_SMALL) && !defined(MKSH_SMALL_BUT_FAST)
char * char *
strndup_i(const char *src, size_t len, Area *ap) strndup_i(const char *src, size_t len, Area *ap)
{ {

10
sh.h
View File

@ -157,9 +157,9 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.571 2012/07/01 15:44:31 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.572 2012/07/01 15:54:57 tg Exp $");
#endif #endif
#define MKSH_VERSION "R40 2012/06/28" #define MKSH_VERSION "R40 2012/07/01"
/* arithmetic types: C implementation */ /* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES #if !HAVE_CAN_INTTYPES
@ -498,7 +498,7 @@ im_sorry_dave(void)
(dst) = (src) + utf_ptradj(src); \ (dst) = (src) + utf_ptradj(src); \
} while (/* CONSTCOND */ 0) } while (/* CONSTCOND */ 0)
#ifdef MKSH_SMALL #if defined(MKSH_SMALL) && !defined(MKSH_SMALL_BUT_FAST)
#define strdupx(d, s, ap) do { \ #define strdupx(d, s, ap) do { \
(d) = strdup_i((s), (ap)); \ (d) = strdup_i((s), (ap)); \
} while (/* CONSTCOND */ 0) } while (/* CONSTCOND */ 0)
@ -1859,7 +1859,7 @@ char *do_realpath(const char *);
void simplify_path(char *); void simplify_path(char *);
void set_current_wd(const char *); void set_current_wd(const char *);
int c_cd(const char **); int c_cd(const char **);
#ifdef MKSH_SMALL #if defined(MKSH_SMALL) && !defined(MKSH_SMALL_BUT_FAST)
char *strdup_i(const char *, Area *); char *strdup_i(const char *, Area *);
char *strndup_i(const char *, size_t, Area *); char *strndup_i(const char *, size_t, Area *);
#endif #endif
@ -1877,7 +1877,7 @@ ssize_t shf_read(char *, ssize_t, struct shf *);
char *shf_getse(char *, ssize_t, struct shf *); char *shf_getse(char *, ssize_t, struct shf *);
int shf_getchar(struct shf *s); int shf_getchar(struct shf *s);
int shf_ungetc(int, struct shf *); int shf_ungetc(int, struct shf *);
#ifdef MKSH_SMALL #if defined(MKSH_SMALL) && !defined(MKSH_SMALL_BUT_FAST)
int shf_getc(struct shf *); int shf_getc(struct shf *);
int shf_putc(int, struct shf *); int shf_putc(int, struct shf *);
#else #else

4
shf.c
View File

@ -24,7 +24,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.45 2011/10/25 22:36:38 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/shf.c,v 1.46 2012/07/01 15:55:00 tg Exp $");
/* flags to shf_emptybuf() */ /* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */ #define EB_READSW 0x01 /* about to switch to reading */
@ -1042,7 +1042,7 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
return (shf_error(shf) ? EOF : nwritten); return (shf_error(shf) ? EOF : nwritten);
} }
#ifdef MKSH_SMALL #if defined(MKSH_SMALL) && !defined(MKSH_SMALL_BUT_FAST)
int int
shf_getc(struct shf *shf) shf_getc(struct shf *shf)
{ {