[PATCH] Optimal performance when use http non-persistent connection

Zhangshaokun zhangshaokun at hisilicon.com
Mon Nov 11 03:07:02 UTC 2019


# HG changeset patch
# User Rui Sun <sunrui26 at huawei.com<mailto:sunrui26 at huawei.com>>
# Date 1572848389 -28800
#      Mon Nov 04 14:19:49 2019 +0800
# Branch local
# Node ID a5ae6e9e99f747fcb45082bac8795622938184f1
# Parent  89adf49fe76ada86d84e2af8f5cee9ca8c3dca19
Optimal performance when use http non-persistent connection

diff -r 89adf49fe76a -r a5ae6e9e99f7 src/core/ngx_cycle.c
--- a/src/core/ngx_cycle.c        Mon Oct 21 20:22:30 2019 +0300
+++ b/src/core/ngx_cycle.c     Mon Nov 04 14:19:49 2019 +0800
@@ -35,6 +35,40 @@
/* STUB */


+void
+ngx_change_pid_core(ngx_cycle_t *cycle)
+{
+    ngx_pid_t           setpid;
+    ngx_cpuset_t        *setaffinity=NULL;
+    setpid = ngx_getpid();
+    {
+#if (NGX_HAVE_CPU_AFFINITY)
+        ngx_core_conf_t  *ccf;
+
+        ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
+
+        if (ccf->cpu_affinity == NULL) {
+            setaffinity = NULL;
+        }
+
+        if (ccf->cpu_affinity_auto) {
+           setaffinity = NULL;
+        }
+
+        setaffinity = &ccf->cpu_affinity[0];
+
+#else
+
+        setaffinity = NULL;
+
+#endif
+    }
+
+    if (setaffinity)
+           // set new mask
+        sched_setaffinity(setpid, sizeof(ngx_cpuset_t), setaffinity);
+}
+
ngx_cycle_t *
ngx_init_cycle(ngx_cycle_t *old_cycle)
{
@@ -278,6 +312,8 @@
         return NULL;
     }

+    ngx_change_pid_core(cycle);
+
     if (ngx_test_config && !ngx_quiet_mode) {
         ngx_log_stderr(0, "the configuration file %s syntax is ok",
                        cycle->conf_file.data);

华为技术有限公司 Huawei Technologies Co., Ltd.
[Company_logo]

________________________________
本邮件及其附件含有华为公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁
止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中
的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件!
This e-mail and its attachments contain confidential information from HUAWEI, which
is intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by
phone or email immediately and delete it!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20191111/f7d19c4c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-Optimal_performance_when_use_http_non-persistent_connection.patch
Type: application/octet-stream
Size: 1540 bytes
Desc: patch-Optimal_performance_when_use_http_non-persistent_connection.patch
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20191111/f7d19c4c/attachment.obj>


More information about the nginx-devel mailing list