Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
🥺
conduwuit
Commits
d434dfb3
Unverified
Commit
d434dfb3
authored
3 years ago
by
Timo Kösters
Browse files
Options
Downloads
Patches
Plain Diff
feat: config option for rocksdb max open files
parent
5b8d2a73
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/database.rs
+6
-0
6 additions, 0 deletions
src/database.rs
src/database/abstraction/rocksdb.rs
+22
-7
22 additions, 7 deletions
src/database/abstraction/rocksdb.rs
with
28 additions
and
7 deletions
src/database.rs
+
6
−
0
View file @
d434dfb3
...
...
@@ -49,6 +49,8 @@ pub struct Config {
database_path
:
String
,
#[serde(default
=
"default_db_cache_capacity_mb"
)]
db_cache_capacity_mb
:
f64
,
#[serde(default
=
"default_rocksdb_max_open_files"
)]
rocksdb_max_open_files
:
i32
,
#[serde(default
=
"default_pdu_cache_capacity"
)]
pdu_cache_capacity
:
u32
,
#[serde(default
=
"default_cleanup_second_interval"
)]
...
...
@@ -127,6 +129,10 @@ fn default_db_cache_capacity_mb() -> f64 {
10.0
}
fn
default_rocksdb_max_open_files
()
->
i32
{
512
}
fn
default_pdu_cache_capacity
()
->
u32
{
1_000_000
}
...
...
This diff is collapsed.
Click to expand it.
src/database/abstraction/rocksdb.rs
+
22
−
7
View file @
d434dfb3
...
...
@@ -5,6 +5,7 @@
pub
struct
Engine
{
rocks
:
rocksdb
::
DBWithThreadMode
<
rocksdb
::
MultiThreaded
>
,
cache_capacity_bytes
:
usize
,
max_open_files
:
i32
,
cache
:
rocksdb
::
Cache
,
old_cfs
:
Vec
<
String
>
,
}
...
...
@@ -16,7 +17,11 @@ pub struct RocksDbEngineTree<'a> {
write_lock
:
RwLock
<
()
>
,
}
fn
db_options
(
cache_capacity_bytes
:
usize
,
rocksdb_cache
:
&
rocksdb
::
Cache
)
->
rocksdb
::
Options
{
fn
db_options
(
cache_capacity_bytes
:
usize
,
max_open_files
:
i32
,
rocksdb_cache
:
&
rocksdb
::
Cache
,
)
->
rocksdb
::
Options
{
let
mut
block_based_options
=
rocksdb
::
BlockBasedOptions
::
default
();
block_based_options
.set_block_cache
(
rocksdb_cache
);
...
...
@@ -36,7 +41,7 @@ fn db_options(cache_capacity_bytes: usize, rocksdb_cache: &rocksdb::Cache) -> ro
//db_opts.set_use_direct_io_for_flush_and_compaction(true);
db_opts
.create_if_missing
(
true
);
db_opts
.increase_parallelism
(
num_cpus
::
get
()
as
i32
);
db_opts
.set_max_open_files
(
512
);
db_opts
.set_max_open_files
(
max_open_files
);
db_opts
.set_compression_type
(
rocksdb
::
DBCompressionType
::
Zstd
);
db_opts
.set_compaction_style
(
rocksdb
::
DBCompactionStyle
::
Level
);
db_opts
.optimize_level_style_compaction
(
cache_capacity_bytes
);
...
...
@@ -52,7 +57,11 @@ fn open(config: &Config) -> Result<Self> {
let
cache_capacity_bytes
=
(
config
.db_cache_capacity_mb
*
1024.0
*
1024.0
)
as
usize
;
let
rocksdb_cache
=
rocksdb
::
Cache
::
new_lru_cache
(
cache_capacity_bytes
)
.unwrap
();
let
db_opts
=
db_options
(
cache_capacity_bytes
,
&
rocksdb_cache
);
let
db_opts
=
db_options
(
cache_capacity_bytes
,
config
.rocksdb_max_open_files
,
&
rocksdb_cache
,
);
let
cfs
=
rocksdb
::
DBWithThreadMode
::
<
rocksdb
::
MultiThreaded
>
::
list_cf
(
&
db_opts
,
...
...
@@ -66,7 +75,11 @@ fn open(config: &Config) -> Result<Self> {
cfs
.iter
()
.map
(|
name
|
{
rocksdb
::
ColumnFamilyDescriptor
::
new
(
name
,
db_options
(
cache_capacity_bytes
,
&
rocksdb_cache
),
db_options
(
cache_capacity_bytes
,
config
.rocksdb_max_open_files
,
&
rocksdb_cache
,
),
)
}),
)
?
;
...
...
@@ -74,6 +87,7 @@ fn open(config: &Config) -> Result<Self> {
Ok
(
Arc
::
new
(
Engine
{
rocks
:
db
,
cache_capacity_bytes
,
max_open_files
:
config
.rocksdb_max_open_files
,
cache
:
rocksdb_cache
,
old_cfs
:
cfs
,
}))
...
...
@@ -82,9 +96,10 @@ fn open(config: &Config) -> Result<Self> {
fn
open_tree
(
&
self
,
name
:
&
'static
str
)
->
Result
<
Arc
<
dyn
Tree
>>
{
if
!
self
.old_cfs
.contains
(
&
name
.to_owned
())
{
// Create if it didn't exist
let
_
=
self
.rocks
.create_cf
(
name
,
&
db_options
(
self
.cache_capacity_bytes
,
&
self
.cache
));
let
_
=
self
.rocks
.create_cf
(
name
,
&
db_options
(
self
.cache_capacity_bytes
,
self
.max_open_files
,
&
self
.cache
),
);
}
Ok
(
Arc
::
new
(
RocksDbEngineTree
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment