diff --git a/proxy_components/mock-engine-store/src/mock_store/mock_engine_store_server.rs b/proxy_components/mock-engine-store/src/mock_store/mock_engine_store_server.rs index 0cd00a26d56..40b94118b82 100644 --- a/proxy_components/mock-engine-store/src/mock_store/mock_engine_store_server.rs +++ b/proxy_components/mock-engine-store/src/mock_store/mock_engine_store_server.rs @@ -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), @@ -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, +) { +} diff --git a/proxy_components/proxy_ffi/src/engine_store_helper_impls.rs b/proxy_components/proxy_ffi/src/engine_store_helper_impls.rs index f6ab4b239c5..2bfe20ece09 100644 --- a/proxy_components/proxy_ffi/src/engine_store_helper_impls.rs +++ b/proxy_components/proxy_ffi/src/engine_store_helper_impls.rs @@ -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, + }, + ); }); } diff --git a/proxy_components/proxy_ffi/src/interfaces.rs b/proxy_components/proxy_ffi/src/interfaces.rs index 27297048713..000e06223d5 100644 --- a/proxy_components/proxy_ffi/src/interfaces.rs +++ b/proxy_components/proxy_ffi/src/interfaces.rs @@ -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)] @@ -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( @@ -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; } } diff --git a/raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version b/raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version index dc8002623ec..16051a1cf7d 100644 --- a/raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version +++ b/raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version @@ -1,3 +1,3 @@ #pragma once #include -namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 1764984388775075973ull; } \ No newline at end of file +namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 4690628711022033644ull; } \ No newline at end of file diff --git a/raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h b/raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h index 9763b9de75a..00f42f192da 100644 --- a/raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h +++ b/raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h @@ -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 { @@ -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