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
d4cfee4e
Commit
d4cfee4e
authored
1 year ago
by
Jason Volk
Committed by
🥺
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
add rocksdb env to options. keep options in engine state.
Signed-off-by:
Jason Volk
<
jason@zemos.net
>
parent
af605a03
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/database/abstraction/rocksdb.rs
+10
-5
10 additions, 5 deletions
src/database/abstraction/rocksdb.rs
with
10 additions
and
5 deletions
src/database/abstraction/rocksdb.rs
+
10
−
5
View file @
d4cfee4e
...
@@ -17,6 +17,8 @@ pub(crate) struct Engine {
...
@@ -17,6 +17,8 @@ pub(crate) struct Engine {
rocks
:
rust_rocksdb
::
DBWithThreadMode
<
rust_rocksdb
::
MultiThreaded
>
,
rocks
:
rust_rocksdb
::
DBWithThreadMode
<
rust_rocksdb
::
MultiThreaded
>
,
cache
:
rust_rocksdb
::
Cache
,
cache
:
rust_rocksdb
::
Cache
,
old_cfs
:
Vec
<
String
>
,
old_cfs
:
Vec
<
String
>
,
opts
:
rust_rocksdb
::
Options
,
env
:
rust_rocksdb
::
Env
,
config
:
Config
,
config
:
Config
,
}
}
...
@@ -27,7 +29,7 @@ struct RocksDbEngineTree<'a> {
...
@@ -27,7 +29,7 @@ struct RocksDbEngineTree<'a> {
write_lock
:
RwLock
<
()
>
,
write_lock
:
RwLock
<
()
>
,
}
}
fn
db_options
(
rocksdb_cache
:
&
rust_rocksdb
::
Cache
,
config
:
&
Config
)
->
rust_rocksdb
::
Options
{
fn
db_options
(
config
:
&
Config
,
env
:
&
rust_rocksdb
::
Env
,
rocksdb_cache
:
&
rust_rocksdb
::
Cache
)
->
rust_rocksdb
::
Options
{
// block-based options: https://docs.rs/rocksdb/latest/rocksdb/struct.BlockBasedOptions.html#
// block-based options: https://docs.rs/rocksdb/latest/rocksdb/struct.BlockBasedOptions.html#
let
mut
block_based_options
=
rust_rocksdb
::
BlockBasedOptions
::
default
();
let
mut
block_based_options
=
rust_rocksdb
::
BlockBasedOptions
::
default
();
...
@@ -44,6 +46,7 @@ fn db_options(rocksdb_cache: &rust_rocksdb::Cache, config: &Config) -> rust_rock
...
@@ -44,6 +46,7 @@ fn db_options(rocksdb_cache: &rust_rocksdb::Cache, config: &Config) -> rust_rock
// database options: https://docs.rs/rocksdb/latest/rocksdb/struct.Options.html#
// database options: https://docs.rs/rocksdb/latest/rocksdb/struct.Options.html#
let
mut
db_opts
=
rust_rocksdb
::
Options
::
default
();
let
mut
db_opts
=
rust_rocksdb
::
Options
::
default
();
db_opts
.set_env
(
env
);
let
rocksdb_log_level
=
match
config
.rocksdb_log_level
.as_ref
()
{
let
rocksdb_log_level
=
match
config
.rocksdb_log_level
.as_ref
()
{
"debug"
=>
Debug
,
"debug"
=>
Debug
,
...
@@ -125,8 +128,8 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
...
@@ -125,8 +128,8 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
fn
open
(
config
:
&
Config
)
->
Result
<
Self
>
{
fn
open
(
config
:
&
Config
)
->
Result
<
Self
>
{
let
cache_capacity_bytes
=
(
config
.db_cache_capacity_mb
*
1024.0
*
1024.0
)
as
usize
;
let
cache_capacity_bytes
=
(
config
.db_cache_capacity_mb
*
1024.0
*
1024.0
)
as
usize
;
let
rocksdb_cache
=
rust_rocksdb
::
Cache
::
new_lru_cache
(
cache_capacity_bytes
);
let
rocksdb_cache
=
rust_rocksdb
::
Cache
::
new_lru_cache
(
cache_capacity_bytes
);
let
db_env
=
rust_rocksdb
::
Env
::
new
()
?
;
let
db_opts
=
db_options
(
&
rocksdb_cache
,
config
);
let
db_opts
=
db_options
(
config
,
&
db_env
,
&
rocksdb_cache
);
debug!
(
"Listing column families in database"
);
debug!
(
"Listing column families in database"
);
let
cfs
=
let
cfs
=
...
@@ -138,13 +141,15 @@ fn open(config: &Config) -> Result<Self> {
...
@@ -138,13 +141,15 @@ fn open(config: &Config) -> Result<Self> {
let
db
=
rust_rocksdb
::
DBWithThreadMode
::
<
rust_rocksdb
::
MultiThreaded
>
::
open_cf_descriptors
(
let
db
=
rust_rocksdb
::
DBWithThreadMode
::
<
rust_rocksdb
::
MultiThreaded
>
::
open_cf_descriptors
(
&
db_opts
,
&
db_opts
,
&
config
.database_path
,
&
config
.database_path
,
cfs
.iter
()
.map
(|
name
|
rust_rocksdb
::
ColumnFamilyDescriptor
::
new
(
name
,
db_opt
ions
(
&
rocksdb_cache
,
config
))),
cfs
.iter
()
.map
(|
name
|
rust_rocksdb
::
ColumnFamilyDescriptor
::
new
(
name
,
db_opt
s
.clone
(
))),
)
?
;
)
?
;
Ok
(
Arc
::
new
(
Engine
{
Ok
(
Arc
::
new
(
Engine
{
rocks
:
db
,
rocks
:
db
,
cache
:
rocksdb_cache
,
cache
:
rocksdb_cache
,
old_cfs
:
cfs
,
old_cfs
:
cfs
,
opts
:
db_opts
,
env
:
db_env
,
config
:
config
.clone
(),
config
:
config
.clone
(),
}))
}))
}
}
...
@@ -153,7 +158,7 @@ fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>> {
...
@@ -153,7 +158,7 @@ fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>> {
if
!
self
.old_cfs
.contains
(
&
name
.to_owned
())
{
if
!
self
.old_cfs
.contains
(
&
name
.to_owned
())
{
// Create if it didn't exist
// Create if it didn't exist
debug!
(
"Creating new column family in database: {}"
,
name
);
debug!
(
"Creating new column family in database: {}"
,
name
);
let
_
=
self
.rocks
.create_cf
(
name
,
&
db_options
(
&
self
.cache
,
&
self
.config
)
);
let
_
=
self
.rocks
.create_cf
(
name
,
&
self
.opts
);
}
}
Ok
(
Arc
::
new
(
RocksDbEngineTree
{
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