[SERVER-8311] usePowerOf2Sizes rounds already quantized values to next highest quantum level Created: 24/Jan/13  Updated: 11/Jul/16  Resolved: 14/May/14

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

Type: Improvement Priority: Minor - P4
Reporter: Aaron Staple Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Tested
Backwards Compatibility: Fully Compatible
Participants:

 Description   

If NamespaceDetails::getRecordAllocationSize() is passed a value that is a power of 2, and Flag_UsePowerOf2Sizes is enabled, the function will return the next power of two (or the next 1mb increment if >= 4mb).

This is only an issue in (potentially rare) cases when getRecordAllocationSize() is passed a value that is already quantized.

Test

c = db.c;
 
 
c.drop();
db.createCollection( 'c' );
printjson( db.runCommand( { collMod:'c', usePowerOf2Sizes:true } ) );
 
big = new Array( 1024 * 1024 - 41 ).toString();
doc = { _id:0, b:big };
assert.eq( 0x100000 - 0x10, Object.bsonsize( doc ) );
 
// A doc of size 0x100000 - 0x10 triggers a record allocation request of size 0x100000.                              
c.insert( doc );
 
// But the actual record size allocated is 0x200000.  This can be seen by adding logging.                            
printjson( c.dataSize() ); // 0x200000 - 0x10                                                                        
 
 
c.drop();
db.createCollection( 'c' );
printjson( db.runCommand( { collMod:'c', usePowerOf2Sizes:true } ) );
 
big = new Array( 16 * 1024 * 1024 - 41 ).toString();
doc = { _id:0, b:big };
assert.eq( 0x1000000 - 0x10, Object.bsonsize( doc ) );
// A doc of size 0x1000000 - 0x10 triggers a record allocation request of size 0x1000000.                            
c.insert( doc );
 
// But the actual record size allocated is 0x1100000.  This can be seen by adding logging.                           
printjson( c.dataSize() ); // 0x1100000 - 0x10                                     



 Comments   
Comment by Mathias Stearn [ 14/May/14 ]

If we decide to backport, the change would be to this function: https://github.com/mongodb/mongo/blob/r2.6.1/src/mongo/db/structure/catalog/namespace_details.cpp#L166-174

Comment by Githook User [ 14/May/14 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-8311 Don't increase pre-quantized power-of-two sizes
Branch: master
https://github.com/mongodb/mongo/commit/304534f11a265d8c18d788623185340c001cc26e

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