Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make Extent::minSize() match allocation strategy and alloc from free …

…list obey it
  • Loading branch information...
commit 9bb928d020a8469532a49f32886ee6e978648aec 1 parent d99695c
@erh erh authored andy10gen committed
Showing with 37 additions and 1 deletion.
  1. +5 −0 db/pdfile.cpp
  2. +1 −1  db/pdfile.h
  3. +31 −0 jstests/extent2.js
View
5 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;
View
2  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
View
31 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 );
Please sign in to comment.
Something went wrong with that request. Please try again.