summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-04-01 01:02:54 -0400
committerAndy Schwerin <schwerin@10gen.com>2012-04-19 15:38:15 -0400
commit9bb928d020a8469532a49f32886ee6e978648aec (patch)
tree872aec2a69289de669ec9c4daed955dda1af586d
parentd99695ccc20af5a56bd624bf6a3aa66c7493d592 (diff)
downloadmongo-9bb928d020a8469532a49f32886ee6e978648aec.tar.gz
make Extent::minSize() match allocation strategy and alloc from free list obey it
-rw-r--r--db/pdfile.cpp5
-rw-r--r--db/pdfile.h2
-rw-r--r--jstests/extent2.js31
3 files changed, 37 insertions, 1 deletions
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index ac7731ae60c..2c3a05dd885 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -434,6 +434,7 @@ namespace mongo {
}
Extent* MongoDataFile::createExtent(const char *ns, int approxSize, bool newCapped, int loops) {
+ verify( approxSize < Extent::maxSize() );
{
// make sizes align with VM page size
int newSize = (approxSize + 0xfff) & 0xfffff000;
@@ -491,6 +492,10 @@ namespace mongo {
// overflowed
high = max(approxSize, Extent::maxSize());
}
+ if ( high <= Extent::minSize() ) {
+ // the minimum extent size is 4097
+ high = Extent::minSize() + 1;
+ }
int n = 0;
Extent *best = 0;
int bestDiff = 0x7fffffff;
diff --git a/db/pdfile.h b/db/pdfile.h
index 64dba68ca41..2652f54f41b 100644
--- a/db/pdfile.h
+++ b/db/pdfile.h
@@ -313,7 +313,7 @@ namespace mongo {
Extent* getPrevExtent() { return xprev.isNull() ? 0 : DataFileMgr::getExtent(xprev); }
static int maxSize();
- static int minSize() { return 0x100; }
+ static int minSize() { return 0x1000; }
/**
* @param len lengt of record we need
* @param lastRecord size of last extent which is a factor in next extent size
diff --git a/jstests/extent2.js b/jstests/extent2.js
new file mode 100644
index 00000000000..a8613d4e848
--- /dev/null
+++ b/jstests/extent2.js
@@ -0,0 +1,31 @@
+
+
+db = db.getSisterDB( "test_extent2" );
+db.dropDatabase();
+
+t = db.foo;
+e = db["$freelist"]
+
+function insert(){
+ t.insert( { _id : 1 , x : 1 } )
+ t.insert( { _id : 2 , x : 1 } )
+ t.insert( { _id : 3 , x : 1 } )
+ t.ensureIndex( { x : 1 } );
+}
+
+insert();
+t.drop();
+
+start = e.stats();
+
+for ( i=0; i<100; i++ ) {
+ insert();
+ t.drop();
+}
+
+end = e.stats();
+
+printjson( start );
+printjson( end )
+assert.eq( 4 , start.numExtents );
+assert.eq( 4 , end.numExtents );