[SERVER-12336] paddingFactor is 1 or 2 Created: 12/Jan/14  Updated: 09/Jul/16  Resolved: 24/Feb/14

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 2.5.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

With 2.5.5-pre as of Jan 5.

> for (i=0;i<10000;i++) { db.padtest.insert({}); }
> db.padtest.stats()
{
	"ns" : "db.padtest",
	"count" : 10000,
	"size" : 240032,
	"avgObjSize" : 24,
	"storageSize" : 696320,
	"numExtents" : 4,
	"nindexes" : 1,
	"lastExtentSize" : 524288,
	"paddingFactor" : 1,
	"systemFlags" : 1,
	"userFlags" : 0,
	"totalIndexSize" : 335216,
	"indexSizes" : {
		"_id_" : 335216
	},
	"ok" : 1
}
> db.padtest.update({},{$set:{a:1}},{multi:true})
> db.padtest.stats()
{
	"ns" : "db.padtest",
	"count" : 10000,
	"size" : 858776,
	"avgObjSize" : 85,
	"storageSize" : 2793472,
	"numExtents" : 5,
	"nindexes" : 1,
	"lastExtentSize" : 2097152,
	"paddingFactor" : 2,
	"systemFlags" : 1,
	"userFlags" : 0,
	"totalIndexSize" : 335216,
	"indexSizes" : {
		"_id_" : 335216
	},
	"ok" : 1
}
> db.padtest.update({},{$set:{a:1}},{multi:true})
> db.padtest.stats()
{
	"ns" : "db.padtest",
	"count" : 10000,
	"size" : 858776,
	"avgObjSize" : 85,
	"storageSize" : 2793472,
	"numExtents" : 5,
	"nindexes" : 1,
	"lastExtentSize" : 2097152,
	"paddingFactor" : 2,
	"systemFlags" : 1,
	"userFlags" : 0,
	"totalIndexSize" : 335216,
	"indexSizes" : {
		"_id_" : 335216
	},
	"ok" : 1
}

Padding factor is showing as either 1 or 2. Not sure if it's a display or internal setting problem.



 Comments   
Comment by Asya Kamsky [ 22/Feb/14 ]

I think I see what happened (re-testing with 2.6.0-rc0) - we use powersOf2 now?
When I increased the size of each document that was within the original space, padding stayed as 1. When I increased the size passing the initial allocation, all the documents doubled in size even though I only added a single small field, so padding factor became 2.

I think this is probably works as designed but will need to be mentioned in release notes?

Comment by Eliot Horowitz (Inactive) [ 13/Jan/14 ]

What exactly is different than 2.4?
Can you provide a full script that's different on 2.4 and 2.6?

Comment by Asya Kamsky [ 13/Jan/14 ]

Also just noticed, that no matter what padding factor was, a multi $unset seems to set it back to 1.

Comment by Asya Kamsky [ 13/Jan/14 ]

The problem is that after I updated (multi) which grew them all and made padding factor 2, I then did the same update again (a bunch of times) all of which do NOT grow the documents. But the padding factor is still 2. This is different than 2.4.x behavior - is this change by design?

I then inserted 100 more, got padding factor 1.934 at which point I did this:

db.padtest.update({},{$unset:{a:1}},{multi:true})
db.padtest.stats()
{
	"ns" : "db.padtest",
	"count" : 10106,
	"size" : 865696,
	"avgObjSize" : 85,
	"storageSize" : 2793472,
	"numExtents" : 5,
	"nindexes" : 1,
	"lastExtentSize" : 2097152,
	"paddingFactor" : 1,
	"systemFlags" : 1,
	"userFlags" : 0,
	"totalIndexSize" : 335216,
	"indexSizes" : {
		"_id_" : 335216
	},
	"ok" : 1
}

Is padding factor supposed to revert to 1 at this point?

Comment by Eliot Horowitz (Inactive) [ 13/Jan/14 ]

You made them all bigger

Add this at the end

> db.padtest.stats()
{
	"ns" : "test.padtest",
	"count" : 10000,
	"size" : 858880,
	"avgObjSize" : 85,
	"storageSize" : 2793472,
	"numExtents" : 5,
	"nindexes" : 1,
	"lastExtentSize" : 2097152,
	"paddingFactor" : 2,
	"systemFlags" : 1,
	"userFlags" : 0,
	"totalIndexSize" : 335216,
	"indexSizes" : {
		"_id_" : 335216
	},
	"ok" : 1
}
> for (i=0;i<100;i++) { db.padtest.insert({}); }
SingleWriteResult({
	"writeErrors" : [ ],
	"writeConcernErrors" : [ ],
	"nInserted" : 1,
	"nUpserted" : 0,
	"nUpdated" : 0,
	"nModified" : 0,
	"nRemoved" : 0,
	"upserted" : [ ]
})
> db.padtest.stats()
{
	"ns" : "test.padtest",
	"count" : 10100,
	"size" : 865280,
	"avgObjSize" : 85,
	"storageSize" : 2793472,
	"numExtents" : 5,
	"nindexes" : 1,
	"lastExtentSize" : 2097152,
	"paddingFactor" : 1.9660000000000037,
	"systemFlags" : 1,
	"userFlags" : 0,
	"totalIndexSize" : 335216,
	"indexSizes" : {
		"_id_" : 335216
	},
	"ok" : 1
}

Generated at Thu Feb 08 03:28:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.