Skip to content
Snippets Groups Projects
Commit f41d5a1c authored by Howard Chu's avatar Howard Chu
Browse files

Add region-size patch for posterity

parent dbaf7c5c
No related branches found
No related tags found
No related merge requests found
As posted to http://www.openldap.org/lists/openldap-devel/200610/msg00027.html
This is Sleepycat bug #14908. The provided patch is for 4.2.52. The
same bug is present in all versions up to 4.5.20 where it is fixed.
-------- Original Message --------
Subject: region size bug Re: [BDB-Alpha] Berkeley DB 4.5.8 ALPHA
Date: Mon, 10 Jul 2006 13:37:33 -0700
From: Howard Chu <hyc@symas.com>
To: support@sleepycat.com
CC: support@symas.com
References: <45A742B5-7DD5-4512-A204-A10FE8FC5DFC@oracle.com>
I just ran into this in 4.2.52 but the same calculation occurs in 4.4
and 4.5.8 alpha:
This computation gives the wrong results when the number of cache
regions is greater than the number of gigabytes (which we encounter on
Linux using shared memory regions, which are constrained to much smaller
than a gigabyte each).
in mp/mp_region.c:
roff_t reg_size;
/* Figure out how big each cache region is. */
reg_size = (roff_t)(dbenv->mp_gbytes / dbenv->mp_ncache) * GIGABYTE;
reg_size += ((roff_t)(dbenv->mp_gbytes %
dbenv->mp_ncache) * GIGABYTE) / dbenv->mp_ncache;
reg_size += dbenv->mp_bytes / dbenv->mp_ncache;
*reg_sizep = reg_size;
The first reg_size calculation always goes to zero when mp_ncache >
mp_gbytes.
This should have been, instead:
reg_size = GIGABYTE / dbenv->mp_ncache * dbenv->mp_gbytes;
--- mp/mp_region.c.O 2003-06-30 10:20:19.000000000 -0700
+++ mp/mp_region.c 2006-10-27 23:25:05.000000000 -0700
@@ -43,9 +43,7 @@
int htab_buckets, ret;
/* Figure out how big each cache region is. */
- reg_size = (dbenv->mp_gbytes / dbenv->mp_ncache) * GIGABYTE;
- reg_size += ((dbenv->mp_gbytes %
- dbenv->mp_ncache) * GIGABYTE) / dbenv->mp_ncache;
+ reg_size = GIGABYTE / dbenv->mp_ncache * dbenv->mp_gbytes;
reg_size += dbenv->mp_bytes / dbenv->mp_ncache;
/*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment