PennMUSH Community

Changeset 1272

Show
Ignore:
Timestamp:
09/18/08 20:36:09 (2 months ago)
Author:
shawnw
Message:

Some chunk tweaks: Favor pread() over lseek() and read(), and same for writing, and increase migration speed (The latter seems to reduce fragmentation significantly faster on M*U*S*H).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/branches/devel/config.h.in

    r1258 r1272  
    317317#endif 
    318318 
     319#undef HAVE_PREAD 
     320 
     321#undef HAVE_PWRITE 
     322 
    319323/* Variables and defines */ 
    320324 
  • 1.8.3/branches/devel/configure

    r1271 r1272  
    1248812488 
    1248912489        if test ! -x "$PG_CONFIG"; then 
    12490             { $as_echo "$as_me:$LINENO: WARNING: $PG_CONFIG does not exist or it is not an exectuable file" >&5 
    12491 $as_echo "$as_me: WARNING: $PG_CONFIG does not exist or it is not an exectuable file" >&2;} 
    1249212490            PG_CONFIG="no" 
    1249312491            found_postgresql="no" 
     
    1556915567 
    1557015568for ac_func in fcntl pselect poll ppoll pollts kqueue epoll_ctl inotify_init 
     15569do 
     15570as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` 
     15571{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 
     15572$as_echo_n "checking for $ac_func... " >&6; } 
     15573if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then 
     15574  $as_echo_n "(cached) " >&6 
     15575else 
     15576  cat >conftest.$ac_ext <<_ACEOF 
     15577/* confdefs.h.  */ 
     15578_ACEOF 
     15579cat confdefs.h >>conftest.$ac_ext 
     15580cat >>conftest.$ac_ext <<_ACEOF 
     15581/* end confdefs.h.  */ 
     15582/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. 
     15583   For example, HP-UX 11i <limits.h> declares gettimeofday.  */ 
     15584#define $ac_func innocuous_$ac_func 
     15585 
     15586/* System header to define __stub macros and hopefully few prototypes, 
     15587    which can conflict with char $ac_func (); below. 
     15588    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since 
     15589    <limits.h> exists even on freestanding compilers.  */ 
     15590 
     15591#ifdef __STDC__ 
     15592# include <limits.h> 
     15593#else 
     15594# include <assert.h> 
     15595#endif 
     15596 
     15597#undef $ac_func 
     15598 
     15599/* Override any GCC internal prototype to avoid an error. 
     15600   Use char because int might match the return type of a GCC 
     15601   builtin and then its argument prototype would still apply.  */ 
     15602#ifdef __cplusplus 
     15603extern "C" 
     15604#endif 
     15605char $ac_func (); 
     15606/* The GNU C library defines this for functions which it implements 
     15607    to always fail with ENOSYS.  Some functions are actually named 
     15608    something starting with __ and the normal name is an alias.  */ 
     15609#if defined __stub_$ac_func || defined __stub___$ac_func 
     15610choke me 
     15611#endif 
     15612 
     15613int 
     15614main () 
     15615{ 
     15616return $ac_func (); 
     15617  ; 
     15618  return 0; 
     15619} 
     15620_ACEOF 
     15621rm -f conftest.$ac_objext conftest$ac_exeext 
     15622if { (ac_try="$ac_link" 
     15623case "(($ac_try" in 
     15624  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
     15625  *) ac_try_echo=$ac_try;; 
     15626esac 
     15627eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" 
     15628$as_echo "$ac_try_echo") >&5 
     15629  (eval "$ac_link") 2>conftest.er1 
     15630  ac_status=$? 
     15631  grep -v '^ *+' conftest.er1 >conftest.err 
     15632  rm -f conftest.er1 
     15633  cat conftest.err >&5 
     15634  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 
     15635  (exit $ac_status); } && { 
     15636     test -z "$ac_c_werror_flag" || 
     15637     test ! -s conftest.err 
     15638       } && test -s conftest$ac_exeext && { 
     15639     test "$cross_compiling" = yes || 
     15640     $as_test_x conftest$ac_exeext 
     15641       }; then 
     15642  eval "$as_ac_var=yes" 
     15643else 
     15644  $as_echo "$as_me: failed program was:" >&5 
     15645sed 's/^/| /' conftest.$ac_ext >&5 
     15646 
     15647    eval "$as_ac_var=no" 
     15648fi 
     15649 
     15650rm -rf conftest.dSYM 
     15651rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ 
     15652      conftest$ac_exeext conftest.$ac_ext 
     15653fi 
     15654ac_res=`eval 'as_val=${'$as_ac_var'} 
     15655         $as_echo "$as_val"'` 
     15656           { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 
     15657$as_echo "$ac_res" >&6; } 
     15658as_val=`eval 'as_val=${'$as_ac_var'} 
     15659         $as_echo "$as_val"'` 
     15660   if test "x$as_val" = x""yes; then 
     15661  cat >>confdefs.h <<_ACEOF 
     15662#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 
     15663_ACEOF 
     15664 
     15665fi 
     15666done 
     15667 
     15668 
     15669 
     15670for ac_func in pread pwrite 
    1557115671do 
    1557215672as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` 
  • 1.8.3/branches/devel/configure.in

    r1271 r1272  
    225225AC_CHECK_FUNCS([socketpair sigaction sigprocmask valloc writev]) 
    226226AC_CHECK_FUNCS([fcntl pselect poll ppoll pollts kqueue epoll_ctl inotify_init]) 
     227AC_CHECK_FUNCS([pread pwrite]) 
    227228 
    228229AC_FUNC_SNPRINTF 
  • 1.8.3/branches/devel/src/chunk.c

    r918 r1272  
    224224#include <io.h> 
    225225#else 
     226#define _XOPEN_SOURCE 500 
    226227#include <unistd.h> 
    227228#endif 
     
    12401241  char *pos; 
    12411242  size_t remaining; 
    1242   int done; 
     1243  ssize_t done; 
    12431244 
    12441245  debug_log("read_cache_region %04x", region); 
    12451246 
     1247#ifndef HAVE_PREAD 
    12461248  /* Try to seek up to 3 times... */ 
    12471249  for (j = 0; j < 3; j++) 
     
    12591261    mush_panicf("chunk swap file seek, errno %d: %s", errno, strerror(errno)); 
    12601262#endif 
     1263#endif /* !HAVE_PREAD */ 
    12611264  pos = (char *) rhp; 
    12621265  remaining = REGION_SIZE; 
    12631266  for (j = 0; j < 10; j++) { 
    1264 #ifdef WIN32 
    1265 #ifndef __MINGW32__ 
     1267#if defined(HAVE_PREAD) 
     1268    done = pread(fd, pos, remaining, file_offset); 
     1269#elif defined(WIN32) && !defined(__MINGW32__) 
    12661270    if (!ReadFile(fd, pos, remaining, &done, NULL)) { 
    12671271      /* nothing */ 
    12681272    } 
    1269 #endif 
    12701273#else 
    12711274    done = read(fd, pos, remaining); 
     
    12741277      remaining -= done; 
    12751278      pos += done; 
     1279      file_offset += done; 
    12761280      if (!remaining) 
    12771281        return; 
    12781282    } 
    1279 #ifndef WIN32 
    1280     if (done == -1 && errno == EAGAIN) 
    1281       sleep(0); 
    1282 #endif 
    12831283  } 
    12841284#ifdef WIN32 
     
    13021302  int j; 
    13031303  char *pos; 
    1304   size_t remaining; 
    1305   int done; 
     1304  size_t remaining;  
     1305  ssize_t done; 
    13061306 
    13071307  debug_log("write_cache_region %04x", region); 
    13081308 
     1309#ifndef HAVE_PWRITE 
    13091310  /* Try to seek up to 3 times... */ 
    13101311  for (j = 0; j < 3; j++) 
     
    13221323    mush_panicf("chunk swap file seek, errno %d: %s", errno, strerror(errno)); 
    13231324#endif 
     1325#endif /* !HAVE_PWRITE */ 
    13241326  pos = (char *) rhp; 
    13251327  remaining = REGION_SIZE; 
     1328 
     1329  /* SW: I'm not sure why Talek has this loop so many times -- the 
     1330     only recoverable way the writes should fail is if they're 
     1331     interrupted by a signal and can't be restarted for some 
     1332     reason. */ 
    13261333  for (j = 0; j < 10; j++) { 
    1327 #ifdef WIN32 
    1328 #ifndef __MINGW32__ 
     1334     
     1335#if defined(HAVE_PWRITE 
     1336    done = pwrite(fd, pos, remaining, file_offset); 
     1337#elif defined(WIN32) && !defined(__MINGW32__) 
    13291338    if (!WriteFile(fd, pos, remaining, &done, NULL)) { 
    13301339      /* nothing */ 
     
    13331342    done = write(fd, pos, remaining); 
    13341343#endif 
    1335 #else 
    1336     done = write(fd, pos, remaining); 
    1337 #endif 
    13381344    if (done >= 0) { 
    13391345      remaining -= done; 
    13401346      pos += done; 
     1347      file_offset += done; 
    13411348      if (!remaining) 
    13421349        return; 
    13431350    } 
    1344 #ifndef WIN32 
    1345     if (done == -1 && errno == EAGAIN) 
    1346       sleep(0); 
    1347 #endif 
    1348   } 
     1351  } 
     1352#endif 
    13491353#ifdef WIN32 
    13501354  mush_panicf("chunk swap file write, %lu remaining, GetLastError %d", 
     
    13531357  mush_panicf("chunk swap file write, %lu remaining, errno %d: %s", 
    13541358              (unsigned long) remaining, errno, strerror(errno)); 
    1355 #endif 
    13561359} 
    13571360