diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-08-10 22:00:34 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-08-10 22:00:34 +0000 |
commit | 74f7fe561e31637bdbf21aeb817d4a22bbf9c91a (patch) | |
tree | bae9da9f2c749d290ad4f1764dc205bcd23b750e /doc/gdbm.texinfo | |
parent | 6b6dcc80555d77858733e44b72e92d1dc60e2c38 (diff) | |
download | gdbm-74f7fe561e31637bdbf21aeb817d4a22bbf9c91a.tar.gz gdbm-74f7fe561e31637bdbf21aeb817d4a22bbf9c91a.tar.bz2 |
Improve memory mapping support.
The new code is more flexible and performs better when
lots of inserts are being made (e.g. when populating the
database with new data).
* src/gdbm.h.in (GDBM_SETMAXMAPSIZE): New constant.
* src/gdbmconst.h (SIZE_T_MAX): New define.
* src/gdbmdefs.h (gdbm_file_info) <cache_size>: Change type
to size_t.
<mmap_inited,mapped_size_max>: New member.
<mapped_remap>: Remove.
* src/gdbmopen.c: Fix a typo.
(gdbm_open): Initialize new members.
(_gdbm_init_cache): Second argument is size_t.
* src/gdbmsetopt.c (gdbm_setopt): Optval argument is void*.
Handle GDBM_SETMAXMAPSIZE.
Improve error checking.
* src/mmap.c (_GDBM_IN_MAPPED_REGION_P): Fix comparison with
the lower bound.
(_GDBM_NEED_REMAP): Return true if mapped_region is NULL.
(SUM_FILE_SIZE): Rewrite.
(_gdbm_mapped_unmap): Don't call msync.
(_gdbm_internal_remap): Take 2 arguments, the second one
giving the new mapped size.
Unmap the region prior to remapping it.
Always pass NULL as the argument to mmap.
(_gdbm_mapped_remap): Rewrite the logic. Change semantics of the
third argument. All uses updated.
(_gdbm_mapped_init): Reflect the above changes.
(_gdbm_mapped_read,_gdbm_mapped_write): Use mmap_inited to decide
whether to use mmap, because mapped_region can be reset to zero
by another functions (namely, _gdbm_mapped_lseek).
Reset mmap_inited to FALSE, if _gdbm_mapped_remap fails.
(_gdbm_mapped_lseek): Rewrite offset computations. Invalidate
the mapped region.
* src/proto.h (_gdbm_init_cache): Change prototype.
* src/update.c (write_header, _gdbm_end_update): Remove checks
for dbf->mapped_region.
* tests/gtload.c: Implement the -maxmap option (set maximal
mapped memory size).
* doc/gdbm.texinfo: Document GDBM_SETMAXMAPSIZE.
Diffstat (limited to 'doc/gdbm.texinfo')
-rw-r--r-- | doc/gdbm.texinfo | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/gdbm.texinfo b/doc/gdbm.texinfo index c349941..5dc8a97 100644 --- a/doc/gdbm.texinfo +++ b/doc/gdbm.texinfo | |||
@@ -738,7 +738,7 @@ The @var{errno} argument is usually the value of the global variable | |||
738 | open database. | 738 | open database. |
739 | 739 | ||
740 | @deftypefn {gdbm interface} int gdbm_setopt (GDBM_FILE @var{dbf}, int @var{option}, @ | 740 | @deftypefn {gdbm interface} int gdbm_setopt (GDBM_FILE @var{dbf}, int @var{option}, @ |
741 | int *@var{value}, int @var{size}) | 741 | void *@var{value}, int @var{size}) |
742 | Sets an option on the database. | 742 | Sets an option on the database. |
743 | 743 | ||
744 | The parameters are: | 744 | The parameters are: |
@@ -809,6 +809,14 @@ a @acronym{CPU} expensive process with time, though, especially if | |||
809 | used in conjunction with GDBM_CENTFREE. The @var{value} should point | 809 | used in conjunction with GDBM_CENTFREE. The @var{value} should point |
810 | to an integer: @samp{TRUE} to turn free block merging on, and @samp{FALSE} to | 810 | to an integer: @samp{TRUE} to turn free block merging on, and @samp{FALSE} to |
811 | turn it off. | 811 | turn it off. |
812 | |||
813 | @kwindex GDBM_SETMAXMAPSIZE | ||
814 | @item GDBM_SETMAXMAPSIZE | ||
815 | Sets maximum size of the memory mapped region. The @var{value} should | ||
816 | point to a value of type @code{size_t}, @code{unsigned long} or | ||
817 | @code{unsigned}. The actual value is rounded to the nearest page | ||
818 | boundary (the page size is obtained from | ||
819 | @code{sysconf(_SC_PAGESIZE)}). | ||
812 | @end table | 820 | @end table |
813 | 821 | ||
814 | The return value will be @samp{-1} upon failure, or @samp{0} upon | 822 | The return value will be @samp{-1} upon failure, or @samp{0} upon |