Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add WriteBufferManager to c api #11710

Closed
wants to merge 3 commits into from
Closed

Conversation

guswynn
Copy link
Contributor

@guswynn guswynn commented Aug 16, 2023

I want to use the WriteBufferManager in my rust project, which requires exposing it through the c api, just like Cache is.

Hopefully the changes are fairly straightfoward!

@facebook-github-bot
Copy link
Contributor

Hi @guswynn!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@facebook-github-bot
Copy link
Contributor

@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@benoitmeriaux
Copy link
Contributor

a patch to add test, and a wbm setter in the option adapted from #12007

Subject: [PATCH] add write_buffer_manager setter into options in c bindings, and add tests
---
Index: db/c.cc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/db/c.cc b/db/c.cc
--- a/db/c.cc	(revision 3139ce4247cd97a3b9f740ea667256c40856ed06)
+++ b/db/c.cc	(revision dbce3b9b7b19e58b601dd3be0ade60f08f615bcc)
@@ -2940,6 +2940,11 @@
   opt->rep.write_buffer_size = s;
 }
 
+void rocksdb_options_set_write_buffer_manager(
+    rocksdb_options_t* opt, rocksdb_write_buffer_manager_t* wbm) {
+  opt->rep.write_buffer_manager = wbm->rep;
+}
+
 size_t rocksdb_options_get_write_buffer_size(rocksdb_options_t* opt) {
   return opt->rep.write_buffer_size;
 }
Index: db/c_test.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/db/c_test.c b/db/c_test.c
--- a/db/c_test.c	(revision 3139ce4247cd97a3b9f740ea667256c40856ed06)
+++ b/db/c_test.c	(revision dbce3b9b7b19e58b601dd3be0ade60f08f615bcc)
@@ -3733,6 +3733,29 @@
     rocksdb_wait_for_compact_options_destroy(wco);
   }
 
+   StartPhase("write_buffer_manager");
+    {
+      rocksdb_cache_t* lru;
+      lru = rocksdb_cache_create_lru(100);
+
+      rocksdb_write_buffer_manager_t* write_buffer_manager;
+      write_buffer_manager = rocksdb_write_buffer_manager_create_with_cache(200, lru);
+
+      CheckCondition(true ==
+                     rocksdb_write_buffer_manager_enabled(write_buffer_manager));
+      CheckCondition(true == rocksdb_write_buffer_manager_cost_to_cache(
+                                 write_buffer_manager));
+      CheckCondition(200 == rocksdb_write_buffer_manager_buffer_size(
+                                write_buffer_manager));
+
+      rocksdb_write_buffer_manager_set_buffer_size(write_buffer_manager, 300);
+      CheckCondition(300 == rocksdb_write_buffer_manager_buffer_size(
+                                write_buffer_manager));
+
+      rocksdb_write_buffer_manager_destroy(write_buffer_manager);
+      rocksdb_cache_destroy(lru);
+    }
+
   StartPhase("cancel_all_background_work");
   rocksdb_cancel_all_background_work(db, 1);
 
Index: include/rocksdb/c.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h
--- a/include/rocksdb/c.h	(revision 3139ce4247cd97a3b9f740ea667256c40856ed06)
+++ b/include/rocksdb/c.h	(revision dbce3b9b7b19e58b601dd3be0ade60f08f615bcc)
@@ -1061,6 +1061,8 @@
     rocksdb_block_based_table_options_t*, unsigned char);
 extern ROCKSDB_LIBRARY_API void rocksdb_options_set_block_based_table_factory(
     rocksdb_options_t* opt, rocksdb_block_based_table_options_t* table_options);
+extern ROCKSDB_LIBRARY_API void rocksdb_options_set_write_buffer_manager(
+    rocksdb_options_t* opt, rocksdb_write_buffer_manager_t* wbm);
 
 /* Cuckoo table options */
 

if you want to add this @ajkr

@facebook-github-bot
Copy link
Contributor

@ajkr merged this pull request in 6d10f8d.

facebook-github-bot pushed a commit that referenced this pull request Nov 17, 2023
…#12007)

Summary:
following #11710
 - add test on wbm c api
- add a setter for WBM in `DBOptions`

Pull Request resolved: #12007

Reviewed By: cbi42

Differential Revision: D51430042

Pulled By: ajkr

fbshipit-source-id: 608bc4d3ed35a84200459d0230b35be64b3475f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants