Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: CalvinNeo <[email protected]>
  • Loading branch information
CalvinNeo committed Mar 14, 2024
1 parent adc4557 commit 8469457
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ pub fn gen_engine_store_server_helper(
fn_kvstore_region_exists: Some(ffi_kvstore_region_exists),
fn_clear_fap_snapshot: Some(ffi_clear_fap_snapshot),
fn_report_thread_allocate_info: Some(ffi_report_thread_allocate_info),
fn_report_thread_allocate_batch: Some(ffi_report_thread_allocate_batch),
ps: PageStorageInterfaces {
fn_create_write_batch: Some(ffi_mockps_create_write_batch),
fn_wb_put_page: Some(ffi_mockps_wb_put_page),
Expand Down Expand Up @@ -670,3 +671,10 @@ unsafe extern "C" fn ffi_report_thread_allocate_info(
}
}
}

unsafe extern "C" fn ffi_report_thread_allocate_batch(
_: *mut interfaces_ffi::EngineStoreServerWrap,
_name: interfaces_ffi::BaseBuffView,
_data: interfaces_ffi::ReportThreadAllocateInfoBatch,
) {
}
32 changes: 15 additions & 17 deletions proxy_components/proxy_ffi/src/engine_store_helper_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,29 @@ impl EngineStoreServerHelper {
}

pub fn directly_report_jemalloc_alloc(&self) {
JEMALLOC_TNAME.with(|thread_name| {
JEMALLOC_ALLOCP.with(|p| unsafe {
JEMALLOC_TNAME.with(|thread_name| unsafe {
let a = JEMALLOC_ALLOCP.with(|p| {
let p = *p.borrow_mut();
if p == std::ptr::null_mut() {
return;
return 0;
}
(self.fn_report_thread_allocate_info.into_inner())(
self.inner,
BaseBuffView::from(thread_name.borrow().as_bytes()),
interfaces_ffi::ReportThreadAllocateInfoType::Alloc,
*p,
);
*p
});
JEMALLOC_DEALLOCP.with(|p| unsafe {
let d = JEMALLOC_DEALLOCP.with(|p| {
let p = *p.borrow_mut();
if p == std::ptr::null_mut() {
return;
return 0;
}
(self.fn_report_thread_allocate_info.into_inner())(
self.inner,
BaseBuffView::from(thread_name.borrow().as_bytes()),
interfaces_ffi::ReportThreadAllocateInfoType::Dealloc,
*p,
);
*p
});
(self.fn_report_thread_allocate_batch.into_inner())(
self.inner,
BaseBuffView::from(thread_name.borrow().as_bytes()),
interfaces_ffi::ReportThreadAllocateInfoBatch {
alloc: a,
dealloc: d,
},
);
});
}

Expand Down
17 changes: 14 additions & 3 deletions proxy_components/proxy_ffi/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,12 @@ pub mod root {
Reset = 0,
AllocPtr = 1,
DeallocPtr = 2,
Alloc = 3,
Dealloc = 4,
}
#[repr(C)]
#[derive(Debug)]
pub struct ReportThreadAllocateInfoBatch {
pub alloc: u64,
pub dealloc: u64,
}
#[repr(C)]
#[derive(Debug)]
Expand Down Expand Up @@ -767,6 +771,13 @@ pub mod root {
value: u64,
),
>,
pub fn_report_thread_allocate_batch: ::std::option::Option<
unsafe extern "C" fn(
arg1: *mut root::DB::EngineStoreServerWrap,
name: root::DB::BaseBuffView,
data: root::DB::ReportThreadAllocateInfoBatch,
),
>,
}
extern "C" {
pub fn ffi_get_server_info_from_proxy(
Expand All @@ -775,7 +786,7 @@ pub mod root {
arg3: root::DB::RawVoidPtr,
) -> u32;
}
pub const RAFT_STORE_PROXY_VERSION: u64 = 1764984388775075973;
pub const RAFT_STORE_PROXY_VERSION: u64 = 4690628711022033644;
pub const RAFT_STORE_PROXY_MAGIC_NUMBER: u32 = 324508639;
}
}
2 changes: 1 addition & 1 deletion raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once
#include <cstdint>
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 1764984388775075973ull; }
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 4690628711022033644ull; }
10 changes: 8 additions & 2 deletions raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@ enum class ReportThreadAllocateInfoType : uint64_t {
Reset = 0,
AllocPtr,
DeallocPtr,
Alloc,
Dealloc,
};

struct ReportThreadAllocateInfoBatch {
uint64_t alloc;
uint64_t dealloc;
};

struct EngineStoreServerHelper {
Expand Down Expand Up @@ -385,6 +388,9 @@ struct EngineStoreServerHelper {
BaseBuffView name,
ReportThreadAllocateInfoType type,
uint64_t value);
void (*fn_report_thread_allocate_batch)(EngineStoreServerWrap *,
BaseBuffView name,
ReportThreadAllocateInfoBatch data);
};

#ifdef __cplusplus
Expand Down

0 comments on commit 8469457

Please sign in to comment.