13
13
.. default-domain :: config
14
14
.. highlight :: ini
15
15
16
- ========================
17
- Compaction Configuration
18
- ========================
16
+ ==========
17
+ Compaction
18
+ ==========
19
19
20
20
.. _config/database_compaction :
21
21
@@ -39,160 +39,129 @@ Database Compaction Options
39
39
[database_compaction]
40
40
checkpoint_after = 5242880
41
41
42
- .. _config/compactions :
42
+ .. _config/view_compaction :
43
43
44
- Compaction Daemon Rules
44
+ View Compaction Options
45
45
=======================
46
46
47
- .. config :section :: compactions :: Compaction Daemon Rules
48
-
49
- A list of rules to determine when to run automatic compaction. The
50
- :option: `daemons/compaction_daemon ` compacts databases and their respective
51
- view groups when all the condition parameters are satisfied. Configuration
52
- can be per-database or global, and it has the following format::
53
-
54
- [compactions]
55
- database_name = [ {ParamName, ParamValue}, {ParamName, ParamValue}, ... ]
56
- _default = [ {ParamName, ParamValue}, {ParamName, ParamValue}, ... ]
57
-
58
- For example::
59
-
60
- [compactions]
61
- _default = [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "23:00"}, {to, "04:00"}]
62
-
63
- - ``db_fragmentation ``: If the ratio of legacy data, including metadata, to
64
- current data in the database file size is equal to or greater than this
65
- value, this condition is satisfied. The percentage is expressed as an
66
- integer percentage. This value is computed as:
67
-
68
- .. code-block :: none
69
-
70
- (sizes.file - sizes.active) / sizes.file * 100
71
-
72
- The sizes.active and sizes.file values can be obtained when
73
- querying :http:get: `/{db} `.
47
+ .. config :section :: view_compaction :: View Compaction Options
74
48
75
- - ``view_fragmentation ``: If the ratio of legacy data, including metadata,
76
- to current data in a view index file size is equal to or greater then
77
- this value, this database compaction condition is satisfied. The
78
- percentage is expressed as an integer percentage. This value is computed
79
- as:
49
+ .. config :option :: keyvalue_buffer_size :: Key-Values buffer size
80
50
81
- .. code-block :: none
51
+ Specifies maximum copy buffer size in bytes used during compaction::
82
52
83
- (sizes.file - sizes.active) / sizes.file * 100
53
+ [view_compaction]
54
+ keyvalue_buffer_size = 2097152
84
55
85
- The sizes.active and sizes.file values can be obtained when querying a
86
- :ref: `view group's information URI <api/ddoc/info >`.
56
+ .. _config/compactions :
87
57
88
- - ``from `` and ``to ``: The period for which a database (and its view group)
89
- compaction is allowed. The value for these parameters must obey the
90
- format:
58
+ Compaction Daemon
59
+ =================
91
60
92
- .. code-block :: none
61
+ CouchDB ships with an automated, event-driven daemon internally known as "smoosh" that
62
+ continuously re-prioritizes the database and secondary index files on each node and
63
+ automatically compacts the files that will recover the most free space according to the
64
+ following parameters.
93
65
94
- HH:MM - HH:MM (HH in [0..23], MM in [0..59])
66
+ .. config : section :: smoosh :: Compaction Daemon Rules
95
67
96
- - ``strict_window ``: If a compaction is still running after the end of the
97
- allowed period, it will be canceled if this parameter is set to `true `.
98
- It defaults to `false ` and is meaningful only if the *period * parameter
99
- is also specified.
68
+ .. config :option :: db_channels :: Active database channels
100
69
101
- - ``parallel_view_compaction ``: If set to `true `, the database and its
102
- views are compacted in parallel. This is only useful on certain setups,
103
- like for example when the database and view index directories point to
104
- different disks. It defaults to `false `.
70
+ A comma-delimited list of channels that are sent the names of database
71
+ files when those files are updated. Each channel can choose whether to
72
+ enqueue the database for compaction; once a channel has enqueued the
73
+ database, no additional channel in the list will be given the
74
+ opportunity to do so.
105
75
106
- Before a compaction is triggered, an estimation of how much free disk space
107
- is needed is computed. This estimation corresponds to two times the data
108
- size of the database or view index. When there's not enough free disk space
109
- to compact a particular database or view index, a warning message is
110
- logged.
76
+ .. config :option :: view_channels :: Active secondary index channels
111
77
112
- Examples:
78
+ A comma-delimited list of channels that are sent the names of secondary
79
+ index files when those files are updated. Each channel can choose
80
+ whether to enqueue the index for compaction; once a channel has enqueued
81
+ the index, no additional channel in the list will be given the
82
+ opportunity to do so.
113
83
114
- #.
115
- ::
84
+ .. config :option :: staleness :: Minimum time between priority calculations
116
85
117
- [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}]
86
+ The number of minutes that the (expensive) priority calculation on an
87
+ individual can be stale for before it is recalculated. Defaults to 5.
118
88
119
- The `foo ` database is compacted if its fragmentation is 70% or more. Any
120
- view index of this database is compacted only if its fragmentation is
121
- 60% or more.
89
+ .. config :option :: cleanup_index_files :: Automatically delete orphaned index files
122
90
123
- #.
124
- ::
91
+ If set to true, the compaction daemon will delete the files for indexes
92
+ that are no longer associated with any design document. Defaults to
93
+ `false ` and probably shouldn't be changed unless the node is running low
94
+ on disk space, and only after considering the ramifications.
125
95
126
- [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}]
96
+ .. config : option :: wait_secs :: Warmup period before triggering first compaction
127
97
128
- Similar to the preceding example but a compaction (database or view
129
- index) is only triggered if the current time is between midnight and 4
130
- AM .
98
+ The time a channel waits before starting compactions to allow time to
99
+ observe the system and make a smarter decision about what to compact
100
+ first. Hardly ever changed from the default of 30 (seconds) .
131
101
132
- #.
133
- ::
102
+ .. config :section :: smoosh.<channel> :: Per-channel configuration
134
103
135
- [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}, {strict_window, true}]
104
+ The following settings control the resource allocation for a given compaction
105
+ channel.
136
106
137
- Similar to the preceding example - a compaction (database or view index)
138
- is only triggered if the current time is between midnight and 4 AM. If
139
- at 4 AM the database or one of its views is still compacting, the
140
- compaction process will be canceled.
107
+ .. config :option :: capacity
141
108
142
- #.
143
- ::
109
+ The maximum number of items the channel can hold (lowest priority item
110
+ is removed to make room for new items). Defaults to 9999.
144
111
145
- [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}, {strict_window, true}, {parallel_view_compaction, true}]
112
+ .. config : option :: concurrency
146
113
147
- Similar to the preceding example, but a database and its views can be
148
- compacted in parallel .
114
+ The maximum number of jobs that can run concurrently in this channel.
115
+ Defaults to 1 .
149
116
150
- .. _ config/compaction_daemon :
117
+ .. config : option :: from
151
118
152
- Configuration of Compaction Daemon
153
- ==================================
119
+ .. config : option :: to
154
120
155
- .. config :section :: compaction_daemon :: Configuration of Compaction Daemon
121
+ The time period during which this channel is allowed to execute
122
+ compactions. The value for each of these parameters must obey the format
123
+ `HH:MM ` with HH in [0..23] and MM in [0..59]. Each channel listed in the
124
+ top-level daemon configuration continuously builds its priority queue
125
+ regardless of the period defined here. The default is to allow the
126
+ channel to execute compactions all the time.
156
127
157
- .. config :option :: check_interval
128
+ .. config : option :: strict_window
158
129
159
- The delay, in seconds, between each check for which database and view
160
- indexes need to be compacted. In other words, this delay will occur
161
- after *all * databases and views are compacted (or at least checked)::
130
+ If set to `true `, any compaction that is still running after the end of
131
+ the allowed perio will be suspended, and then resumed during the next
132
+ window. It defaults to `false `, in which case any running compactions
133
+ will be allowed to finish, but no new ones will be started.
162
134
163
- [compaction_daemon]
164
- check_interval = 3600
135
+ There are also several settings that collectively control whether a channel will
136
+ enqueue a file for compaction and how it prioritizes files within its queue:
165
137
166
- .. config :option :: min_file_size
138
+ .. config :option :: max_priority
167
139
168
- If a database or view index file is smaller than this value (in bytes),
169
- compaction will not happen. Very small files always have high
170
- fragmentation, so compacting them is inefficient. ::
140
+ Each item must have a priority lower than this to be enqueued. Defaults
141
+ to infinity.
171
142
172
- [compaction_daemon]
173
- min_file_size = 131072
143
+ .. config :option :: max_size
174
144
175
- .. config :option :: snooze_period_ms
145
+ The item must be no larger than this many bytes in length to be
146
+ enqueued. Defaults to infinity.
176
147
177
- With lots of databases and/or with lots of design docs in one or more
178
- databases, the compaction_daemon can create significant CPU load when
179
- checking whether databases and view indexes need compacting. The
180
- ``snooze_period_ms `` setting ensures a smoother CPU load. Defaults to
181
- 3000 milliseconds wait.
148
+ .. config :option :: min_priority
182
149
183
- [compaction_daemon]
184
- snooze_period_ms = 3000
150
+ The item must have a priority at least this high to be enqueued.
151
+ Defaults to 5.0 for ratio and 16 MB for slack.
185
152
186
- .. _ config/view_compaction :
153
+ .. config : option :: min_changes
187
154
188
- Views Compaction Options
189
- ========================
155
+ The minimum number of changes since last compaction before the item will
156
+ be enqueued. Defaults to 0. Currently only works for databases.
190
157
191
- .. config :section :: view_compaction :: Views Compaction Options
158
+ .. config :option :: min_size
192
159
193
- .. config :option :: keyvalue_buffer_size :: Key-Values buffer size
160
+ The item must be at least this many bytes in length to be enqueued.
161
+ Defaults to 1mb (1048576 bytes).
194
162
195
- Specifies maximum copy buffer size in bytes used during compaction::
163
+ .. config : option :: priority
196
164
197
- [view_compaction]
198
- keyvalue_buffer_size = 2097152
165
+ The method used to calculate priority. Can be ratio (calculated as
166
+ `sizes.file/sizes.active `) or slack (calculated as `sizes.file -
167
+ sizes.active `). Defaults to ratio.
0 commit comments