@@ -156,10 +156,7 @@ static const Size max_changes_in_memory = 4096;
156
156
* major bottleneck, especially when spilling to disk while decoding batch
157
157
* workloads.
158
158
*/
159
- static const Size max_cached_changes = 4096 * 2 ;
160
159
static const Size max_cached_tuplebufs = 4096 * 2 ; /* ~8MB */
161
- static const Size max_cached_transactions = 512 ;
162
-
163
160
164
161
/* ---------------------------------------
165
162
* primary reorderbuffer support routines
@@ -241,6 +238,16 @@ ReorderBufferAllocate(void)
241
238
242
239
buffer -> context = new_ctx ;
243
240
241
+ buffer -> change_context = SlabContextCreate (new_ctx ,
242
+ "Change" ,
243
+ SLAB_DEFAULT_BLOCK_SIZE ,
244
+ sizeof (ReorderBufferChange ));
245
+
246
+ buffer -> txn_context = SlabContextCreate (new_ctx ,
247
+ "TXN" ,
248
+ SLAB_DEFAULT_BLOCK_SIZE ,
249
+ sizeof (ReorderBufferTXN ));
250
+
244
251
hash_ctl .keysize = sizeof (TransactionId );
245
252
hash_ctl .entrysize = sizeof (ReorderBufferTXNByIdEnt );
246
253
hash_ctl .hcxt = buffer -> context ;
@@ -251,8 +258,6 @@ ReorderBufferAllocate(void)
251
258
buffer -> by_txn_last_xid = InvalidTransactionId ;
252
259
buffer -> by_txn_last_txn = NULL ;
253
260
254
- buffer -> nr_cached_transactions = 0 ;
255
- buffer -> nr_cached_changes = 0 ;
256
261
buffer -> nr_cached_tuplebufs = 0 ;
257
262
258
263
buffer -> outbuf = NULL ;
@@ -261,8 +266,6 @@ ReorderBufferAllocate(void)
261
266
buffer -> current_restart_decoding_lsn = InvalidXLogRecPtr ;
262
267
263
268
dlist_init (& buffer -> toplevel_by_lsn );
264
- dlist_init (& buffer -> cached_transactions );
265
- dlist_init (& buffer -> cached_changes );
266
269
slist_init (& buffer -> cached_tuplebufs );
267
270
268
271
return buffer ;
@@ -291,19 +294,8 @@ ReorderBufferGetTXN(ReorderBuffer *rb)
291
294
{
292
295
ReorderBufferTXN * txn ;
293
296
294
- /* check the slab cache */
295
- if (rb -> nr_cached_transactions > 0 )
296
- {
297
- rb -> nr_cached_transactions -- ;
298
- txn = (ReorderBufferTXN * )
299
- dlist_container (ReorderBufferTXN , node ,
300
- dlist_pop_head_node (& rb -> cached_transactions ));
301
- }
302
- else
303
- {
304
- txn = (ReorderBufferTXN * )
305
- MemoryContextAlloc (rb -> context , sizeof (ReorderBufferTXN ));
306
- }
297
+ txn = (ReorderBufferTXN * )
298
+ MemoryContextAlloc (rb -> txn_context , sizeof (ReorderBufferTXN ));
307
299
308
300
memset (txn , 0 , sizeof (ReorderBufferTXN ));
309
301
@@ -344,18 +336,7 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
344
336
txn -> invalidations = NULL ;
345
337
}
346
338
347
- /* check whether to put into the slab cache */
348
- if (rb -> nr_cached_transactions < max_cached_transactions )
349
- {
350
- rb -> nr_cached_transactions ++ ;
351
- dlist_push_head (& rb -> cached_transactions , & txn -> node );
352
- VALGRIND_MAKE_MEM_UNDEFINED (txn , sizeof (ReorderBufferTXN ));
353
- VALGRIND_MAKE_MEM_DEFINED (& txn -> node , sizeof (txn -> node ));
354
- }
355
- else
356
- {
357
- pfree (txn );
358
- }
339
+ pfree (txn );
359
340
}
360
341
361
342
/*
@@ -366,19 +347,8 @@ ReorderBufferGetChange(ReorderBuffer *rb)
366
347
{
367
348
ReorderBufferChange * change ;
368
349
369
- /* check the slab cache */
370
- if (rb -> nr_cached_changes )
371
- {
372
- rb -> nr_cached_changes -- ;
373
- change = (ReorderBufferChange * )
374
- dlist_container (ReorderBufferChange , node ,
375
- dlist_pop_head_node (& rb -> cached_changes ));
376
- }
377
- else
378
- {
379
- change = (ReorderBufferChange * )
380
- MemoryContextAlloc (rb -> context , sizeof (ReorderBufferChange ));
381
- }
350
+ change = (ReorderBufferChange * )
351
+ MemoryContextAlloc (rb -> change_context , sizeof (ReorderBufferChange ));
382
352
383
353
memset (change , 0 , sizeof (ReorderBufferChange ));
384
354
return change ;
@@ -434,21 +404,9 @@ ReorderBufferReturnChange(ReorderBuffer *rb, ReorderBufferChange *change)
434
404
break ;
435
405
}
436
406
437
- /* check whether to put into the slab cache */
438
- if (rb -> nr_cached_changes < max_cached_changes )
439
- {
440
- rb -> nr_cached_changes ++ ;
441
- dlist_push_head (& rb -> cached_changes , & change -> node );
442
- VALGRIND_MAKE_MEM_UNDEFINED (change , sizeof (ReorderBufferChange ));
443
- VALGRIND_MAKE_MEM_DEFINED (& change -> node , sizeof (change -> node ));
444
- }
445
- else
446
- {
447
- pfree (change );
448
- }
407
+ pfree (change );
449
408
}
450
409
451
-
452
410
/*
453
411
* Get an unused, possibly preallocated, ReorderBufferTupleBuf fitting at
454
412
* least a tuple of size tuple_len (excluding header overhead).
0 commit comments