db

mp_method.c

Go to the documentation of this file.
00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1996, 1997, 1998, 1999, 2000
00005  * Sleepycat Software. All rights reserved.
00006  */
00007 #include "config.h"
00008 
00009 #ifndef lint
00010 static const char revid[] = "$Id: mp__method_8c-source.html,v 1.1 2008年06月08日 10:20:48 sebdiaz Exp $";
00011 #endif /* not lint */
00012 
00013 #ifndef NO_SYSTEM_INCLUDES
00014 #include <sys/types.h>
00015 #endif
00016 
00017 #ifdef HAVE_RPC
00018 #include "db_server.h"
00019 #endif
00020 
00021 #include "db_int.h"
00022 #include "db_shash.h"
00023 #include "mp.h"
00024 
00025 #ifdef HAVE_RPC
00026 #include "gen_client_ext.h"
00027 #include "rpc_client_ext.h"
00028 #endif
00029 
00030 static int __memp_set_cachesize __P((DB_ENV *, u_int32_t, u_int32_t, int));
00031 static int __memp_set_mp_mmapsize __P((DB_ENV *, size_t));
00032 
00033 /*
00034  * CDB___memp_dbenv_create --
00035  * Mpool specific creation of the DB_ENV structure.
00036  *
00037  * PUBLIC: void CDB___memp_dbenv_create __P((DB_ENV *));
00038  */
00039 void
00040 CDB___memp_dbenv_create(dbenv)
00041 DB_ENV *dbenv;
00042 {
00043 /*
00044  * We default to 32 8K pages. We don't default to a flat 256K, because
00045  * some systems require significantly more memory to hold 32 pages than
00046  * others. For example, HP-UX with POSIX pthreads needs 88 bytes for
00047  * a POSIX pthread mutex and almost 200 bytes per buffer header, while
00048  * Solaris needs 24 and 52 bytes for the same structures.
00049  */
00050 dbenv->mp_bytes = 32 * ((8 * 1024) + sizeof(BH));
00051 dbenv->mp_ncache = 1;
00052 
00053 dbenv->set_mp_mmapsize = __memp_set_mp_mmapsize;
00054 dbenv->set_cachesize = __memp_set_cachesize;
00055 
00056 #ifdef HAVE_RPC
00057 /*
00058  * If we have a client, overwrite what we just setup to
00059  * point to client functions.
00060  */
00061 if (F_ISSET(dbenv, DB_ENV_RPCCLIENT)) {
00062 dbenv->set_cachesize = __dbcl_env_cachesize;
00063 dbenv->set_mp_mmapsize = __dbcl_set_mp_mmapsize;
00064 }
00065 #endif
00066 
00067 }
00068 
00069 /*
00070  * __memp_set_cachesize --
00071  * Initialize the cache size.
00072  */
00073 static int
00074 __memp_set_cachesize(dbenv, gbytes, bytes, ncache)
00075 DB_ENV *dbenv;
00076 u_int32_t gbytes, bytes;
00077 int ncache;
00078 {
00079 ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_cachesize");
00080 
00081 dbenv->mp_gbytes = gbytes + bytes / GIGABYTE;
00082 dbenv->mp_bytes = bytes % GIGABYTE;
00083 dbenv->mp_ncache = ncache == 0 ? 1 : ncache;
00084 
00085 /*
00086  * If the application requested less than 500Mb, increase the
00087  * cachesize by 25% to account for our overhead. (I'm guessing
00088  * that caches over 500Mb are specifically sized, i.e., it's
00089  * a large server and the application actually knows how much
00090  * memory is available.)
00091  *
00092  * There is a minimum cache size, regardless.
00093  */
00094 if (dbenv->mp_gbytes == 0) {
00095 if (dbenv->mp_bytes < 500 * MEGABYTE)
00096 dbenv->mp_bytes += dbenv->mp_bytes / 4;
00097 if (dbenv->mp_bytes < DB_CACHESIZE_MIN)
00098 dbenv->mp_bytes = DB_CACHESIZE_MIN;
00099 }
00100 
00101 return (0);
00102 }
00103 
00104 /*
00105  * __memp_set_mp_mmapsize --
00106  * Set the maximum mapped file size.
00107  */
00108 static int
00109 __memp_set_mp_mmapsize(dbenv, mp_mmapsize )
00110 DB_ENV *dbenv;
00111 size_t mp_mmapsize;
00112 {
00113 dbenv->mp_mmapsize = mp_mmapsize;
00114 return (0);
00115 }

Generated on Sun Jun 8 10:56:38 2008 for GNUmifluz by doxygen 1.5.5

AltStyle によって変換されたページ (->オリジナル) /