ub_server_running_memory_layout
2016-06-22 11:31:05 0 举报
ub_server_running_memory_layout 是一个用于描述服务器运行时内存布局的概念。它涉及到服务器在运行过程中,各种数据和程序在内存中的分配和组织方式。一个良好的内存布局可以提高服务器的性能和稳定性,因为它可以确保关键数据和代码位于内存中容易访问的位置,从而减少访问延迟并提高缓存命中率。此外,合理的内存布局还可以帮助服务器更有效地利用有限的内存资源,避免内存碎片和浪费。在实际应用中,开发人员需要根据服务器的硬件特性、操作系统和应用程序的需求来设计和优化内存布局。
作者其他创作
大纲/内容
......
void* user_buf
....................
void* parent
指针service_handler_base*
thread_data
从client fd读入请求内容
12 pointers 1 per threadeach stores addr of athread_instance_data objadjacently allocated in heap
type=void *size=8 bytes
...........................
nshead
mcpack
ub_server_pdata_t
int fd
字符串\"create_direct_trans\"
一个thread的client fd读入的请求放入本thread的read buffer发往该thread的thread_instance_data里面的handlers_ map里面的对应的service_handler_wrapper对象中的handler对象,比如create_direct_trans_service对象的handle函数处理处理的响应也存入本thread的write buffer最终发给本thread的client fd
内部调用obj-handle()
void* data
thread_instance_data
create_direct_trans_service obj
pay_direct_trans_service obj
pthread_t pid
void* write_buf
12 thread_instance_data obj separately allocated in heap
associate with
g_pkey for thread 1
按nshead+mcpack协议解析请求内容供实际各service对象的handle函数内部消费
.................................
ub_server_handle
Stack
void* usersef_buf
each per-thread pointerstores addr of another pointer storing the addr of the per-thread thread_instance_data obj
type=void*size=sizeof(/thread_instance_data**)
1)inside one thread_instance_data its thread_data member variable is used by all service objs like create_direct_trans_serice for construction2)members of thread_data like sql_db_session_map are initialized inside constructors of service classes like create_direct_trans_service
int (* cb_native)()
thread_instance_data for thread 0newed inside dispatcher::create_thread_datahold own map of cmd-service_handler_wrapper*
total size=12*sizeof(void *)there are 12 pointers1 per threadadjacently allocated in heap
.........................
int sev_sock
13 per-thread data key12 worker threads1 main threadthis is in kernel space
字符串\"pay_direct_trans\"
void* pool
each thread_instance_data objhas its own set of pointerspointing to their own set of service objs like create_direct_trans_serivce
all service objs in one thread share db sessions(essentially connections to mysql servers)held by that thread's thread_data instance
void* read_buf
Heap
g_pkey for thread 12
向client fd写入响应内容
g_pkey for main thread
redis_client *p_redis_client_
Code
按nshead+mcpack协议打包响应内容实际内容由各service对象的handle函数内部填充
int (* cb_drastic)()
use own thread_data for construction
Data
0 条评论
下一页