~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/transaction_log/module.cc

Adds a vector of write buffers to the transaction log applier
object.  This eliminates the calls to malloc() for writing
most transaction log entries (the only calls to malloc() will
be when an existing write buffer is not large enough).  

There is a configuration setting now for the number of write
buffers to create on startup.  The slot algorithm is a simple
modulo on the session ID.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
 * in truncating the log file. 
62
62
 */
63
63
static bool sysvar_transaction_log_truncate_debug= false;
 
64
/**
 
65
 * The name of the main transaction log file on disk.  With no prefix,
 
66
 * this goes into Drizzle's $datadir.
 
67
 */
64
68
static const char DEFAULT_LOG_FILE_PATH[]= "transaction.log"; /* In datadir... */
65
69
/** 
66
70
 * Transaction Log plugin system variable - Should we write a CRC32 checksum for 
76
80
 * TransactionLog::SYNC_METHOD_EVERY_SECOND == 2  ... sync at most once a second
77
81
 */
78
82
static uint32_t sysvar_transaction_log_sync_method= 0;
 
83
/**
 
84
 * Transaction Log plugin system variable - Number of slots to create
 
85
 * for managing write buffers
 
86
 */
 
87
static uint32_t sysvar_transaction_log_num_write_buffers= 8;
79
88
 
80
89
/** DATA_DICTIONARY views */
81
90
static TransactionLogTool *transaction_log_tool;
99
108
  if (sysvar_transaction_log_enabled)
100
109
  {
101
110
    transaction_log= new (nothrow) TransactionLog(string(sysvar_transaction_log_file),
102
 
                                                  sysvar_transaction_log_sync_method);
 
111
                                                  sysvar_transaction_log_sync_method,
 
112
                                                  sysvar_transaction_log_checksum_enabled);
103
113
 
104
114
    if (transaction_log == NULL)
105
115
    {
120
130
    /* Create the applier plugin and register it */
121
131
    transaction_log_applier= new (nothrow) TransactionLogApplier("transaction_log_applier",
122
132
                                                                 *transaction_log, 
123
 
                                                                 sysvar_transaction_log_checksum_enabled);
 
133
                                                                 sysvar_transaction_log_num_write_buffers);
124
134
    if (transaction_log_applier == NULL)
125
135
    {
126
136
      errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate the TransactionLogApplier instance.  Got error: %s\n"), 
212
222
                           set_truncate_debug, /* update func */
213
223
                           false /* default */);
214
224
 
215
 
static DRIZZLE_SYSVAR_STR(log_file,
 
225
static DRIZZLE_SYSVAR_STR(file,
216
226
                          sysvar_transaction_log_file,
217
227
                          PLUGIN_VAR_READONLY,
218
228
                          N_("Path to the file to use for transaction log"),
241
251
                           2,
242
252
                           0);
243
253
 
 
254
static DRIZZLE_SYSVAR_UINT(num_write_buffers,
 
255
                           sysvar_transaction_log_num_write_buffers,
 
256
                           PLUGIN_VAR_OPCMDARG,
 
257
                           N_("Number of slots for in-memory write buffers (default=8)."),
 
258
                           NULL, /* check func */
 
259
                           NULL, /* update func */
 
260
                           8, /* default */
 
261
                           4,
 
262
                           8192,
 
263
                           0);
 
264
 
244
265
static drizzle_sys_var* sys_variables[]= {
245
266
  DRIZZLE_SYSVAR(enable),
246
267
  DRIZZLE_SYSVAR(truncate_debug),
247
 
  DRIZZLE_SYSVAR(log_file),
 
268
  DRIZZLE_SYSVAR(file),
248
269
  DRIZZLE_SYSVAR(enable_checksum),
249
270
  DRIZZLE_SYSVAR(sync_method),
 
271
  DRIZZLE_SYSVAR(num_write_buffers),
250
272
  NULL
251
273
};
252
274