[asterisk-dev] Optimize CDR batch mode

George Joseph gjoseph at digium.com
Tue Jun 16 07:40:40 CDT 2020


On Mon, Jun 15, 2020 at 10:22 PM Gabriel Ortiz Lour <ortiz.admin at gmail.com>
wrote:

> Hi all,
>
>   I was looking around cdr batch mode and I think that should be two
> signalling functions:
>
> ast_cdr_batch_start();
> ast_cdr_batch_finish();
>
> This two functions would tell all the BackEnds about the batch mode
> happening, so in the PGSQL backend the CDR loading could be done in a
> single COPY sql command, which is much faster than single INSERTs
>
> Sounds like a small addition for having a much faster CDR insertion
>
> Gabriel Ortiz
>
>
>
Hi Gabriel,

Sounds like a good idea.



>
> The do_batch_backend_process would look like this:
> static void *do_batch_backend_process(void *data)
> {
> struct cdr_batch_item *processeditem;
> struct cdr_batch_item *batchitem = data;
>
> ast_cdr_batch_start();
>
> /* Push each CDR into storage mechanism(s) and free all the memory */
> while (batchitem) {
> post_cdr(batchitem->cdr);
> ast_cdr_free(batchitem->cdr);
> processeditem = batchitem;
> batchitem = batchitem->next;
> ast_free(processeditem);
> }
>
> ast_cdr_batch_finish();
>
> return NULL;
> }
> --
>

To make this work, I think you'd have to modify cdr_beitem to have 2 new
callbacks, then you'd have to create a new version of ast_cdr_register()
that accepts callbacks for the batch_start and batch_end functions.
Then ast_cdr_batch_start() and ast_cdr_batch_end() would iterate over the
registered backends and call those calkbacks if they existed.  Should be
easy (for the core cdr part anyway).

Will you be submitting Gerrit reviews for this feature?


> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev



-- 
George Joseph
Asterisk Software Developer
direct/fax +1 256 428 6012
Check us out at www.sangoma.com and www.asterisk.org
[image: image.png]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20200616/28c6e6b6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 5142 bytes
Desc: not available
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20200616/28c6e6b6/attachment.png>


More information about the asterisk-dev mailing list