Skip to content

Commit edbb43a

Browse files
committed
3.0 allocation changes
1 parent 5e12048 commit edbb43a

File tree

6 files changed

+72
-37
lines changed

6 files changed

+72
-37
lines changed

source/core/storage.txt

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -167,42 +167,40 @@ Power of 2 Sized Allocations
167167
MongoDB 3.0 uses the power of 2 sizes allocation as the default record
168168
allocation strategy for MMAPv1. With the power of 2 sizes allocation
169169
strategy, each record has a size in bytes that is a power of 2 (e.g.
170-
32, 64, 128, 256, 512 ... 16777216). The smallest allocation for a
171-
document is 32 bytes.
170+
32, 64, 128, 256, 512 ... 2MB). For documents larger than 2MB, the
171+
allocation is rounded up to the nearest multiple of 2MB.
172172

173173
The power of 2 sizes allocation strategy has the following key
174174
properties:
175175

176-
- Can efficiently reuse freed records to reduce fragmentation. The
177-
limited number of record allocation sizes help ensure that MongoDB
178-
can efficiently reuse free space created by document deletion or
179-
relocation.
176+
- Can efficiently reuse freed records to reduce fragmentation.
177+
Quantizing record allocation sizes into a fixed set of sizes
178+
increases the probability that an insert will fit into the free space
179+
created by an earlier document deletion or relocation.
180180

181-
- Can minimize the occurrence of re-allocation. In many cases, the
182-
record allocations are significantly larger than the documents they
183-
hold. This significantly larger size minimizes the chance that the
184-
:program:`mongod` will need to allocate a new record if the document
185-
grows. Although the power of 2 sizes strategy can minimize the
186-
occurrence of reallocation, it does not eliminate
187-
document re-allocation.
181+
- Can reduce moves. The added padding space gives a document room to
182+
grow without requiring a move. In addition to saving the cost of
183+
moving, this results in less updates to indexes. Although the power
184+
of 2 sizes strategy can minimize moves, it does not eliminate them
185+
entirely.
188186

189187
.. _exact-fit-allocation:
190188

191-
Exact Fit Allocation with No Padding
192-
````````````````````````````````````
189+
No Padding Allocation Strategy
190+
``````````````````````````````
193191

194192
.. versionchanged:: 3.0.0
195193

196194
For collections whose workloads do not change the document sizes, such
197-
as workloads that consist of insert-only operations, insert-and-remove
198-
operations on documents of uniform size, or update operations that do
199-
not increase document size, you can disable the :ref:`power of 2
200-
allocation <power-of-2-allocation>` using the :dbcommand:`collMod`
201-
command with the :collflag:`noPadding` flag or the
202-
:method:`db.createCollection()` method with the ``noPadding`` option.
203-
204-
Prior to version 3.0.0, MongoDB used an exact fit allocation strategy
205-
that included a dynamically calculated :data:`padding
195+
as workloads that consist of insert-only operations or update
196+
operations that do not increase document size (such as incrementing a
197+
counter), you can disable the :ref:`power of 2 allocation
198+
<power-of-2-allocation>` using the :dbcommand:`collMod` command with
199+
the :collflag:`noPadding` flag or the :method:`db.createCollection()`
200+
method with the ``noPadding`` option.
201+
202+
Prior to version 3.0.0, MongoDB used an allocation strategy that
203+
included a dynamically calculated :data:`padding
206204
<collStats.paddingFactor>` as a factor of the document size.
207205

208206
Capped Collections

source/includes/apiargs-method-db.createCollection-options-param.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,17 @@ description: |2
8282
flag set to true, the allocation strategy does not include
8383
additional space to accomodate document growth, as such, document
8484
growth will result in new allocation. Use for collections with
85-
workloads that are insert-only or insert-and-remove-only.
85+
workloads that are insert-only or in-place updates (such as
86+
incrementing counters).
8687
8788
Defaults to ``false``.
8889
90+
.. warning::
91+
92+
Do not set ``noPadding`` if the workload includes any removes or
93+
updates that may cause documents to grow. For more information,
94+
see :ref:`exact-fit-allocation`.
95+
8996
interface: method
9097
name: noPadding
9198
operation: db.createCollection

source/reference/command/collMod.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ Disable All Record Padding
8484
document size, and any updates that results in document growth will
8585
require a new allocation.
8686

87-
*Only* set :collflag:`noPadding` to ``true`` for collections whose
88-
workloads have *no* update operations that cause documents to grow,
89-
such as for collections with workloads that are insert-only. For
90-
more information, see :ref:`exact-fit-allocation`.
87+
.. warning::
88+
89+
Only set :collflag:`noPadding` to ``true`` for collections whose
90+
workloads have *no* update operations that cause documents to grow,
91+
such as for collections with workloads that are insert-only. For
92+
more information, see :ref:`exact-fit-allocation`.
9193

9294
Powers of Two Record Allocation
9395
```````````````````````````````

source/release-notes/3.0-compatibility.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ parameter such that you can no longer use the parameter to disable the
114114
power of 2 sizes allocation for a collection. Instead, use the
115115
:dbcommand:`collMod` command with the :collflag:`noPadding` flag or the
116116
:method:`db.createCollection()` method with the ``noPadding`` option.
117+
Only set ``noPadding`` for collections with workloads that consist only
118+
of inserts or in-place updates (such as incrementing counters).
119+
120+
.. warning::
121+
122+
Only set :collflag:`noPadding` to ``true`` for collections whose
123+
workloads have *no* update operations that cause documents to grow,
124+
such as for collections with workloads that are insert-only. For
125+
more information, see :ref:`exact-fit-allocation`.
117126

118127
For more information, see :ref:`3.0-mmapv1-padding`.
119128

source/release-notes/3.0-downgrade.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ Follow the downgrade procedures:
3838

3939
- To downgrade a standalone MongoDB instance, see :ref:`3.0-downgrade-standalone`.
4040

41+
.. note::
42+
43+
*Optional*. Consider :dbcommand:`compacting <compact>` collections
44+
after downgrading. Otherwise, older versions will not be able to
45+
reuse free space regions larger than 2MB created while running 3.0.
46+
This can result in wasted space but no data loss following the
47+
downgrade.
48+
4149
Downgrade MongoDB Processes
4250
---------------------------
4351

source/release-notes/3.0.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,26 @@ MMAPv1 have changed. See :ref:`3.0-compatibility-configuration-file`.
110110
MMAPv1 Record Allocation Behavior Changes
111111
`````````````````````````````````````````
112112

113-
The default allocation strategy for collections in instances that use
114-
MMAPv1 is :ref:`power of 2 allocation <power-of-2-allocation>`. For
115-
collections with insert-only or insert-and-remove-only workloads, you
116-
can disable the power of 2 strategy.
117-
118-
To disable the power of 2 strategy for a collection, use the
113+
MongoDB 3.0 no longer implements dynamic record allocation and
114+
deprecates :term:`paddingFactor <padding factor>`. The default
115+
allocation strategy for collections in instances that use MMAPv1 is
116+
:ref:`power of 2 allocation <power-of-2-allocation>`, which has been
117+
improved to better handle large document sizes. In 3.0, the
118+
``usePowerOf2Sizes`` flag is ignored, so the power of 2 strategy is
119+
used for all collections that do not have ``noPadding`` flag set.
120+
121+
For collections with workloads that consist only of inserts or in-place
122+
updates (such as incrementing counters), you can disable the power of 2
123+
strategy. To disable the power of 2 strategy for a collection, use the
119124
:dbcommand:`collMod` command with the :collflag:`noPadding` flag or the
120-
:method:`db.createCollection()` method with the ``noPadding`` option.
125+
:method:`db.createCollection()` method with the ``noPadding`` option.
126+
127+
.. warning::
121128

129+
Do not set ``noPadding`` if the workload includes any removes or
130+
updates that may cause documents to grow. For more information, see
131+
:ref:`exact-fit-allocation`.
132+
122133
.. seealso:: :ref:`3.0-compatiblity-record-alloc`
123134

124135
.. _3.0-replica-sets:
@@ -407,4 +418,4 @@ Additional Resources
407418

408419
- `All Third Party License Notices <https://github.com/mongodb/mongo/blob/v3.0/distsrc/THIRD-PARTY-NOTICES>`_.
409420

410-
- `All JIRA issues resolved in 3.0 <https://jira.mongodb.org/issues/?filter=17007>`_.
421+
- `All JIRA issues resolved in 3.0 <http://bit.ly/1CpOu6t>`_.

0 commit comments

Comments
 (0)