summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/mem-types.h
diff options
context:
space:
mode:
authorVenky Shankar <vshankar@redhat.com>2015-02-03 19:03:30 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-18 21:22:33 -0700
commit87a9d23627586a5d5cd8a502a08ecbdb6f0f7bb2 (patch)
tree7e627c0810e151177364f66a9442529d1e95826f /libglusterfs/src/mem-types.h
parentd236b01a8bf68b83c76ea1cfa8351833e19695f7 (diff)
libglusterfs/rot-buffs: rotational buffers
This patch introduces rotational buffers aiming at the classic multiple producer and multiple consumer problem. A fixed set of buffer list is allocated during initialization, where each list consist of a list of buffers. Each buffer is an iovec pointing to a memory region of fixed allocation size. Multiple producers write data to these buffers. A buffer list starts with a single buffer (iovec) and allocates more when required (although this can be preallocatd in multiples of k). rot-buffs allow multiple producers to write data parallely with a bit of extra cost of taking locks. Therefore, it's much suited for large writes. Multiple producers are allowed to write in the buffer parallely by "reserving" write space for selected number of bytes and returning pointer to the start of the reserved area. The write size is selected by the producer before it starts the write (which is often known). Therefore, the write itself need not be serialized -- just the space reservation needs to be done safely. The other part is when a consumer kicks in to consume what has been produced. At this point, a buffer list switch is performed. The "current" buffer list pointer is safely pointed to the next available buffer list. New writes are now directed to the just switched buffer list (the old buffer list is now considered out of rotation). Note that the old buffer still may have producers in progress (pending writes), so the consumer has to wait till the writers are drained. Currently this is the slow path for producers (write completion) and needs to be improved. Currently, there is special handling for cases where the number of consumers match (or exceed) the number of producers, which could result in writer starvation. In this scenario, when a consumers requests a buffer list for consumption, a check is performed for writer starvation and consumption is denied until at least another buffer list is ready of the producer for writes, i.e., one (or more) consumer(s) completed, thereby putting the buffer list back in rotation. [ NOTE: I've not performance tested this producer-consumer model yet. It's being used in changelog for event notification. The list of buffers (iovecs) are directly passed to RPC layer. ] Change-Id: I88d235522b05ab82509aba861374a2312bff57f2 BUG: 1170075 Signed-off-by: Venky Shankar <vshankar@redhat.com> Reviewed-on: http://review.gluster.org/9706 Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src/mem-types.h')
-rw-r--r--libglusterfs/src/mem-types.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h
index 5f4e7bcd2c2..4dd59b002a5 100644
--- a/libglusterfs/src/mem-types.h
+++ b/libglusterfs/src/mem-types.h
@@ -131,17 +131,20 @@ enum gf_common_mem_types_ {
gf_common_mt_parser_t = 115,
gf_common_quota_meta_t = 116,
/*related to gfdb library*/
- gfdb_mt_time_t,
- gf_mt_sql_cbk_args_t,
- gf_mt_gfdb_query_record_t,
- gf_mt_gfdb_link_info_t,
- gf_mt_gfdb_db_operations_t,
- gf_mt_sql_connection_t,
- gf_mt_sql_conn_node_t,
- gf_mt_db_conn_node_t,
- gf_mt_db_connection_t,
- gfdb_mt_db_record_t,
+ gfdb_mt_time_t = 117,
+ gf_mt_sql_cbk_args_t = 118,
+ gf_mt_gfdb_query_record_t = 119,
+ gf_mt_gfdb_link_info_t = 120,
+ gf_mt_gfdb_db_operations_t = 121,
+ gf_mt_sql_connection_t = 122,
+ gf_mt_sql_conn_node_t = 123,
+ gf_mt_db_conn_node_t = 124,
+ gf_mt_db_connection_t = 125,
+ gfdb_mt_db_record_t = 126,
/*related to gfdb library*/
+ gf_common_mt_rbuf_t = 127,
+ gf_common_mt_rlist_t = 128,
+ gf_common_mt_rvec_t = 129,
gf_common_mt_end
};
#endif