You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Igor Galić <i....@brainsware.org> on 2013/08/20 21:51:46 UTC

Re: [4/4] git commit: remove global variable dependencies from adjust_num_of_net_threads()

> Branch: refs/heads/master
> Commit: 8064935bbb3ce0eef740ee06b420b4ea5eada34f
> Parents: d2e5b80
> Author: James Peach <jp...@apache.org>
> Authored: Tue Aug 20 12:26:00 2013 -0700
> Committer: James Peach <jp...@apache.org>
> Committed: Tue Aug 20 12:26:00 2013 -0700
> 
> ----------------------------------------------------------------------
>  proxy/Main.cc | 43 ++++++++++++++++++++++---------------------
>  1 file changed, 22 insertions(+), 21 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8064935b/proxy/Main.cc
> ----------------------------------------------------------------------
> diff --git a/proxy/Main.cc b/proxy/Main.cc
> index c80081c..bd3151e 100644
> --- a/proxy/Main.cc
> +++ b/proxy/Main.cc
> @@ -1154,48 +1154,49 @@ getNumSSLThreads(void)
>    return num_of_ssl_threads;
>  }
>  
> -static void
> -adjust_num_of_net_threads(void)
> +static int
> +adjust_num_of_net_threads(int nthreads)
>  {
>    float autoconfig_scale = 1.0;
>    int nth_auto_config = 1;
>    int num_of_threads_tmp = 1;
>  
>    TS_ReadConfigInteger(nth_auto_config,
>    "proxy.config.exec_thread.autoconfig");
> +
> +  Debug("threads", "initial number of net threads is %d", nthreads);
> +  Debug("threads", "net threads auto-configuration %s", nth_auto_config ?
> "enabled" : "disabled");
> +
>    if (!nth_auto_config) {
>      TS_ReadConfigInteger(num_of_threads_tmp,
>      "proxy.config.exec_thread.limit");
> -    if (num_of_threads_tmp <= 0)
> +
> +    if (num_of_threads_tmp <= 0) {
>        num_of_threads_tmp = 1;
> -    else if (num_of_threads_tmp > MAX_EVENT_THREADS)
> +    } else if (num_of_threads_tmp > MAX_EVENT_THREADS) {
>        num_of_threads_tmp = MAX_EVENT_THREADS;
> -    num_of_net_threads = num_of_threads_tmp;
> -    if (is_debug_tag_set("threads")) {
> -      fprintf(stderr, "# net threads Auto config - disabled - use config
> file settings\n");
>      }
> +
> +    nthreads = num_of_threads_tmp;
>    } else {                      /* autoconfig is enabled */
> -    num_of_threads_tmp = num_of_net_threads;
> +    num_of_threads_tmp = nthreads;
>      TS_ReadConfigFloat(autoconfig_scale,
>      "proxy.config.exec_thread.autoconfig.scale");
>      num_of_threads_tmp = (int) ((float) num_of_threads_tmp *
>      autoconfig_scale);
> +
>      if (num_of_threads_tmp) {
> -      num_of_net_threads = num_of_threads_tmp;
> +      nthreads = num_of_threads_tmp;
>      }
> +
>      if (unlikely(num_of_threads_tmp > MAX_EVENT_THREADS)) {
>        num_of_threads_tmp = MAX_EVENT_THREADS;
>      }
> -    if (is_debug_tag_set("threads")) {
> -      fprintf(stderr, "# net threads Auto config - enabled\n");
> -      fprintf(stderr, "# autoconfig scale: %f\n", autoconfig_scale);
> -      fprintf(stderr, "# scaled number of net threads: %d\n",
> num_of_threads_tmp);

in digging through logging code of the plugins code I've sometimes
seen sometimes seen fprintf(stderr,
but I perfectly ignorant of its existence in our core code..

Could someone explain what this does? (it prints stuff to the redirected
stderr, yes, but) Why it's there? 
Why we have 3+ different ways of logging?

-- i
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE


Re: [4/4] git commit: remove global variable dependencies from adjust_num_of_net_threads()

Posted by James Peach <jp...@apache.org>.
On Aug 20, 2013, at 12:51 PM, Igor Galić <i....@brainsware.org> wrote:
[snip]
>> 
>> -    if (is_debug_tag_set("threads")) {
>> -      fprintf(stderr, "# net threads Auto config - enabled\n");
>> -      fprintf(stderr, "# autoconfig scale: %f\n", autoconfig_scale);
>> -      fprintf(stderr, "# scaled number of net threads: %d\n",
>> num_of_threads_tmp);
> 
> in digging through logging code of the plugins code I've sometimes
> seen sometimes seen fprintf(stderr,
> but I perfectly ignorant of its existence in our core code..
> 
> Could someone explain what this does? (it prints stuff to the redirected
> stderr, yes, but) Why it's there? 
> Why we have 3+ different ways of logging?

My guess is that at some point this code was executed before logging was initialized.

J