[OpenSIPS-Users] dp_translate performance

Liviu Chircu liviu at opensips.org
Mon May 5 12:44:52 UTC 2025


Hi!

Fun question -- and a perfect use-case for the benchmark 
<https://opensips.org/docs/modules/3.6.x/benchmark.html> module, 
allowing you to find the precise answer to this question and also share 
it with us!

While the dialplan uses a hash table to store its string-based rules, 
unfortunately it seems to be hardcoded to *16* (???).  Which means on 1M 
records, you will get 62K on each bucket on average.  Now, imagine doing 
->next, ->next, ->next, etc. 62K times on each number lookup...  So I 
think performance will be decent since C lang is fast, but far from 
ideal.  The hash size should be /configurable/ /- /an excellent feature 
request for people getting into OpenSIPS development.

OTOH, the sql_cacher uses cachedb_local to store/pull its keys, which 
has a much wider hash size (IIRC, *1024* buckets).  So I think it will 
be visibly faster than dialplan when doing 1M lookups over 1M records.

Best regards,

On 03.05.2025 12:27, M S wrote:
> How better is it to use a
> for(i=0 to 1000000) {
>   if($sql_cached_value(c_features:disabled:$fU)<>NULL 
> || $sql_cached_value(c_features:disabled:$rU)) {
>       send_reply(503);
>   }
> }
>
> instead of just a:
>
> if(dp_translate($fU) || dp_translate($rU)) {
>   send_reply(503);
> }

-- 
Liviu Chircu
www.opensips-solutions.com  |www.siphub.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20250505/4d922704/attachment.html>


More information about the Users mailing list