]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
2 | // This source code is licensed under both the GPLv2 (found in the |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
7c673cae FG |
5 | |
6 | #include "options/db_options.h" | |
7 | ||
8 | #ifndef __STDC_FORMAT_MACROS | |
9 | #define __STDC_FORMAT_MACROS | |
10 | #endif | |
11 | ||
12 | #include <inttypes.h> | |
13 | ||
14 | #include "port/port.h" | |
15 | #include "rocksdb/cache.h" | |
16 | #include "rocksdb/env.h" | |
17 | #include "rocksdb/sst_file_manager.h" | |
18 | #include "rocksdb/wal_filter.h" | |
19 | #include "util/logging.h" | |
20 | ||
21 | namespace rocksdb { | |
22 | ||
23 | ImmutableDBOptions::ImmutableDBOptions() : ImmutableDBOptions(Options()) {} | |
24 | ||
25 | ImmutableDBOptions::ImmutableDBOptions(const DBOptions& options) | |
26 | : create_if_missing(options.create_if_missing), | |
27 | create_missing_column_families(options.create_missing_column_families), | |
28 | error_if_exists(options.error_if_exists), | |
29 | paranoid_checks(options.paranoid_checks), | |
30 | env(options.env), | |
31 | rate_limiter(options.rate_limiter), | |
32 | sst_file_manager(options.sst_file_manager), | |
33 | info_log(options.info_log), | |
34 | info_log_level(options.info_log_level), | |
7c673cae FG |
35 | max_file_opening_threads(options.max_file_opening_threads), |
36 | statistics(options.statistics), | |
37 | use_fsync(options.use_fsync), | |
38 | db_paths(options.db_paths), | |
39 | db_log_dir(options.db_log_dir), | |
40 | wal_dir(options.wal_dir), | |
41 | max_subcompactions(options.max_subcompactions), | |
42 | max_background_flushes(options.max_background_flushes), | |
43 | max_log_file_size(options.max_log_file_size), | |
44 | log_file_time_to_roll(options.log_file_time_to_roll), | |
45 | keep_log_file_num(options.keep_log_file_num), | |
46 | recycle_log_file_num(options.recycle_log_file_num), | |
47 | max_manifest_file_size(options.max_manifest_file_size), | |
48 | table_cache_numshardbits(options.table_cache_numshardbits), | |
49 | wal_ttl_seconds(options.WAL_ttl_seconds), | |
50 | wal_size_limit_mb(options.WAL_size_limit_MB), | |
51 | manifest_preallocation_size(options.manifest_preallocation_size), | |
52 | allow_mmap_reads(options.allow_mmap_reads), | |
53 | allow_mmap_writes(options.allow_mmap_writes), | |
54 | use_direct_reads(options.use_direct_reads), | |
55 | use_direct_io_for_flush_and_compaction( | |
56 | options.use_direct_io_for_flush_and_compaction), | |
57 | allow_fallocate(options.allow_fallocate), | |
58 | is_fd_close_on_exec(options.is_fd_close_on_exec), | |
59 | advise_random_on_open(options.advise_random_on_open), | |
60 | db_write_buffer_size(options.db_write_buffer_size), | |
61 | write_buffer_manager(options.write_buffer_manager), | |
62 | access_hint_on_compaction_start(options.access_hint_on_compaction_start), | |
63 | new_table_reader_for_compaction_inputs( | |
64 | options.new_table_reader_for_compaction_inputs), | |
7c673cae | 65 | random_access_max_buffer_size(options.random_access_max_buffer_size), |
7c673cae | 66 | use_adaptive_mutex(options.use_adaptive_mutex), |
7c673cae FG |
67 | listeners(options.listeners), |
68 | enable_thread_tracking(options.enable_thread_tracking), | |
11fdf7f2 | 69 | enable_pipelined_write(options.enable_pipelined_write), |
7c673cae FG |
70 | allow_concurrent_memtable_write(options.allow_concurrent_memtable_write), |
71 | enable_write_thread_adaptive_yield( | |
72 | options.enable_write_thread_adaptive_yield), | |
73 | write_thread_max_yield_usec(options.write_thread_max_yield_usec), | |
74 | write_thread_slow_yield_usec(options.write_thread_slow_yield_usec), | |
75 | skip_stats_update_on_db_open(options.skip_stats_update_on_db_open), | |
76 | wal_recovery_mode(options.wal_recovery_mode), | |
77 | allow_2pc(options.allow_2pc), | |
78 | row_cache(options.row_cache), | |
79 | #ifndef ROCKSDB_LITE | |
80 | wal_filter(options.wal_filter), | |
81 | #endif // ROCKSDB_LITE | |
82 | fail_if_options_file_error(options.fail_if_options_file_error), | |
83 | dump_malloc_stats(options.dump_malloc_stats), | |
11fdf7f2 TL |
84 | avoid_flush_during_recovery(options.avoid_flush_during_recovery), |
85 | allow_ingest_behind(options.allow_ingest_behind), | |
86 | preserve_deletes(options.preserve_deletes), | |
87 | two_write_queues(options.two_write_queues), | |
88 | manual_wal_flush(options.manual_wal_flush) { | |
7c673cae FG |
89 | } |
90 | ||
91 | void ImmutableDBOptions::Dump(Logger* log) const { | |
92 | ROCKS_LOG_HEADER(log, " Options.error_if_exists: %d", | |
93 | error_if_exists); | |
94 | ROCKS_LOG_HEADER(log, " Options.create_if_missing: %d", | |
95 | create_if_missing); | |
96 | ROCKS_LOG_HEADER(log, " Options.paranoid_checks: %d", | |
97 | paranoid_checks); | |
98 | ROCKS_LOG_HEADER(log, " Options.env: %p", | |
99 | env); | |
100 | ROCKS_LOG_HEADER(log, " Options.info_log: %p", | |
101 | info_log.get()); | |
7c673cae FG |
102 | ROCKS_LOG_HEADER(log, " Options.max_file_opening_threads: %d", |
103 | max_file_opening_threads); | |
11fdf7f2 TL |
104 | ROCKS_LOG_HEADER(log, " Options.statistics: %p", |
105 | statistics.get()); | |
7c673cae FG |
106 | ROCKS_LOG_HEADER(log, " Options.use_fsync: %d", |
107 | use_fsync); | |
108 | ROCKS_LOG_HEADER( | |
109 | log, " Options.max_log_file_size: %" ROCKSDB_PRIszt, | |
110 | max_log_file_size); | |
111 | ROCKS_LOG_HEADER(log, | |
112 | " Options.max_manifest_file_size: %" PRIu64, | |
113 | max_manifest_file_size); | |
114 | ROCKS_LOG_HEADER( | |
115 | log, " Options.log_file_time_to_roll: %" ROCKSDB_PRIszt, | |
116 | log_file_time_to_roll); | |
117 | ROCKS_LOG_HEADER( | |
118 | log, " Options.keep_log_file_num: %" ROCKSDB_PRIszt, | |
119 | keep_log_file_num); | |
120 | ROCKS_LOG_HEADER( | |
121 | log, " Options.recycle_log_file_num: %" ROCKSDB_PRIszt, | |
122 | recycle_log_file_num); | |
123 | ROCKS_LOG_HEADER(log, " Options.allow_fallocate: %d", | |
124 | allow_fallocate); | |
125 | ROCKS_LOG_HEADER(log, " Options.allow_mmap_reads: %d", | |
126 | allow_mmap_reads); | |
127 | ROCKS_LOG_HEADER(log, " Options.allow_mmap_writes: %d", | |
128 | allow_mmap_writes); | |
129 | ROCKS_LOG_HEADER(log, " Options.use_direct_reads: %d", | |
130 | use_direct_reads); | |
131 | ROCKS_LOG_HEADER(log, | |
132 | " " | |
133 | "Options.use_direct_io_for_flush_and_compaction: %d", | |
134 | use_direct_io_for_flush_and_compaction); | |
135 | ROCKS_LOG_HEADER(log, " Options.create_missing_column_families: %d", | |
136 | create_missing_column_families); | |
137 | ROCKS_LOG_HEADER(log, " Options.db_log_dir: %s", | |
138 | db_log_dir.c_str()); | |
139 | ROCKS_LOG_HEADER(log, " Options.wal_dir: %s", | |
140 | wal_dir.c_str()); | |
141 | ROCKS_LOG_HEADER(log, " Options.table_cache_numshardbits: %d", | |
142 | table_cache_numshardbits); | |
143 | ROCKS_LOG_HEADER(log, | |
144 | " Options.max_subcompactions: %" PRIu32, | |
145 | max_subcompactions); | |
146 | ROCKS_LOG_HEADER(log, " Options.max_background_flushes: %d", | |
147 | max_background_flushes); | |
148 | ROCKS_LOG_HEADER(log, | |
149 | " Options.WAL_ttl_seconds: %" PRIu64, | |
150 | wal_ttl_seconds); | |
151 | ROCKS_LOG_HEADER(log, | |
152 | " Options.WAL_size_limit_MB: %" PRIu64, | |
153 | wal_size_limit_mb); | |
154 | ROCKS_LOG_HEADER( | |
155 | log, " Options.manifest_preallocation_size: %" ROCKSDB_PRIszt, | |
156 | manifest_preallocation_size); | |
157 | ROCKS_LOG_HEADER(log, " Options.is_fd_close_on_exec: %d", | |
158 | is_fd_close_on_exec); | |
159 | ROCKS_LOG_HEADER(log, " Options.advise_random_on_open: %d", | |
160 | advise_random_on_open); | |
161 | ROCKS_LOG_HEADER( | |
162 | log, " Options.db_write_buffer_size: %" ROCKSDB_PRIszt, | |
163 | db_write_buffer_size); | |
11fdf7f2 TL |
164 | ROCKS_LOG_HEADER(log, " Options.write_buffer_manager: %p", |
165 | write_buffer_manager.get()); | |
7c673cae FG |
166 | ROCKS_LOG_HEADER(log, " Options.access_hint_on_compaction_start: %d", |
167 | static_cast<int>(access_hint_on_compaction_start)); | |
168 | ROCKS_LOG_HEADER(log, " Options.new_table_reader_for_compaction_inputs: %d", | |
169 | new_table_reader_for_compaction_inputs); | |
7c673cae FG |
170 | ROCKS_LOG_HEADER( |
171 | log, " Options.random_access_max_buffer_size: %" ROCKSDB_PRIszt, | |
172 | random_access_max_buffer_size); | |
7c673cae FG |
173 | ROCKS_LOG_HEADER(log, " Options.use_adaptive_mutex: %d", |
174 | use_adaptive_mutex); | |
175 | ROCKS_LOG_HEADER(log, " Options.rate_limiter: %p", | |
176 | rate_limiter.get()); | |
177 | Header( | |
178 | log, " Options.sst_file_manager.rate_bytes_per_sec: %" PRIi64, | |
179 | sst_file_manager ? sst_file_manager->GetDeleteRateBytesPerSecond() : 0); | |
7c673cae FG |
180 | ROCKS_LOG_HEADER(log, " Options.wal_recovery_mode: %d", |
181 | wal_recovery_mode); | |
182 | ROCKS_LOG_HEADER(log, " Options.enable_thread_tracking: %d", | |
183 | enable_thread_tracking); | |
11fdf7f2 TL |
184 | ROCKS_LOG_HEADER(log, " Options.enable_pipelined_write: %d", |
185 | enable_pipelined_write); | |
7c673cae FG |
186 | ROCKS_LOG_HEADER(log, " Options.allow_concurrent_memtable_write: %d", |
187 | allow_concurrent_memtable_write); | |
188 | ROCKS_LOG_HEADER(log, " Options.enable_write_thread_adaptive_yield: %d", | |
189 | enable_write_thread_adaptive_yield); | |
190 | ROCKS_LOG_HEADER(log, | |
191 | " Options.write_thread_max_yield_usec: %" PRIu64, | |
192 | write_thread_max_yield_usec); | |
193 | ROCKS_LOG_HEADER(log, | |
194 | " Options.write_thread_slow_yield_usec: %" PRIu64, | |
195 | write_thread_slow_yield_usec); | |
196 | if (row_cache) { | |
197 | ROCKS_LOG_HEADER( | |
198 | log, " Options.row_cache: %" PRIu64, | |
199 | row_cache->GetCapacity()); | |
200 | } else { | |
201 | ROCKS_LOG_HEADER(log, | |
202 | " Options.row_cache: None"); | |
203 | } | |
204 | #ifndef ROCKSDB_LITE | |
205 | ROCKS_LOG_HEADER(log, " Options.wal_filter: %s", | |
206 | wal_filter ? wal_filter->Name() : "None"); | |
207 | #endif // ROCKDB_LITE | |
11fdf7f2 | 208 | |
7c673cae FG |
209 | ROCKS_LOG_HEADER(log, " Options.avoid_flush_during_recovery: %d", |
210 | avoid_flush_during_recovery); | |
11fdf7f2 TL |
211 | ROCKS_LOG_HEADER(log, " Options.allow_ingest_behind: %d", |
212 | allow_ingest_behind); | |
213 | ROCKS_LOG_HEADER(log, " Options.preserve_deletes: %d", | |
214 | preserve_deletes); | |
215 | ROCKS_LOG_HEADER(log, " Options.two_write_queues: %d", | |
216 | two_write_queues); | |
217 | ROCKS_LOG_HEADER(log, " Options.manual_wal_flush: %d", | |
218 | manual_wal_flush); | |
7c673cae FG |
219 | } |
220 | ||
221 | MutableDBOptions::MutableDBOptions() | |
11fdf7f2 TL |
222 | : max_background_jobs(2), |
223 | base_background_compactions(-1), | |
224 | max_background_compactions(-1), | |
7c673cae | 225 | avoid_flush_during_shutdown(false), |
11fdf7f2 | 226 | writable_file_max_buffer_size(1024 * 1024), |
7c673cae FG |
227 | delayed_write_rate(2 * 1024U * 1024U), |
228 | max_total_wal_size(0), | |
229 | delete_obsolete_files_period_micros(6ULL * 60 * 60 * 1000000), | |
11fdf7f2 TL |
230 | stats_dump_period_sec(600), |
231 | max_open_files(-1), | |
232 | bytes_per_sync(0), | |
233 | wal_bytes_per_sync(0), | |
234 | compaction_readahead_size(0) {} | |
7c673cae FG |
235 | |
236 | MutableDBOptions::MutableDBOptions(const DBOptions& options) | |
11fdf7f2 TL |
237 | : max_background_jobs(options.max_background_jobs), |
238 | base_background_compactions(options.base_background_compactions), | |
7c673cae FG |
239 | max_background_compactions(options.max_background_compactions), |
240 | avoid_flush_during_shutdown(options.avoid_flush_during_shutdown), | |
11fdf7f2 | 241 | writable_file_max_buffer_size(options.writable_file_max_buffer_size), |
7c673cae FG |
242 | delayed_write_rate(options.delayed_write_rate), |
243 | max_total_wal_size(options.max_total_wal_size), | |
244 | delete_obsolete_files_period_micros( | |
245 | options.delete_obsolete_files_period_micros), | |
11fdf7f2 TL |
246 | stats_dump_period_sec(options.stats_dump_period_sec), |
247 | max_open_files(options.max_open_files), | |
248 | bytes_per_sync(options.bytes_per_sync), | |
249 | wal_bytes_per_sync(options.wal_bytes_per_sync), | |
250 | compaction_readahead_size(options.compaction_readahead_size) {} | |
7c673cae FG |
251 | |
252 | void MutableDBOptions::Dump(Logger* log) const { | |
11fdf7f2 TL |
253 | ROCKS_LOG_HEADER(log, " Options.max_background_jobs: %d", |
254 | max_background_jobs); | |
7c673cae FG |
255 | ROCKS_LOG_HEADER(log, " Options.max_background_compactions: %d", |
256 | max_background_compactions); | |
257 | ROCKS_LOG_HEADER(log, " Options.avoid_flush_during_shutdown: %d", | |
258 | avoid_flush_during_shutdown); | |
11fdf7f2 TL |
259 | ROCKS_LOG_HEADER( |
260 | log, " Options.writable_file_max_buffer_size: %" ROCKSDB_PRIszt, | |
261 | writable_file_max_buffer_size); | |
7c673cae FG |
262 | ROCKS_LOG_HEADER(log, " Options.delayed_write_rate : %" PRIu64, |
263 | delayed_write_rate); | |
264 | ROCKS_LOG_HEADER(log, " Options.max_total_wal_size: %" PRIu64, | |
265 | max_total_wal_size); | |
266 | ROCKS_LOG_HEADER( | |
267 | log, " Options.delete_obsolete_files_period_micros: %" PRIu64, | |
268 | delete_obsolete_files_period_micros); | |
269 | ROCKS_LOG_HEADER(log, " Options.stats_dump_period_sec: %u", | |
270 | stats_dump_period_sec); | |
11fdf7f2 TL |
271 | ROCKS_LOG_HEADER(log, " Options.max_open_files: %d", |
272 | max_open_files); | |
273 | ROCKS_LOG_HEADER(log, | |
274 | " Options.bytes_per_sync: %" PRIu64, | |
275 | bytes_per_sync); | |
276 | ROCKS_LOG_HEADER(log, | |
277 | " Options.wal_bytes_per_sync: %" PRIu64, | |
278 | wal_bytes_per_sync); | |
279 | ROCKS_LOG_HEADER(log, | |
280 | " Options.compaction_readahead_size: %" ROCKSDB_PRIszt, | |
281 | compaction_readahead_size); | |
7c673cae FG |
282 | } |
283 | ||
284 | } // namespace rocksdb |