<div>HiŁ¬<span style="font-family: "lucida Grande", Verdana;">Maxim</span></div><div><br>This feature is not a much needed, but it can reduce the cost of manual configuration. If there is a better implementation that can solve this problem, we are also very much looking forward to it. </div><div>I hope you can think again. Thanks.</div><div><br></div><div><span style="font-family: "lucida Grande", Verdana;">Regards,</span></div><div><span style="font-family: "lucida Grande", Verdana;">Agile6v</span></div><div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b> "Maxim Dounin";<mdounin@mdounin.ru>;</div><div><b>Date: </b> Apr 25, 2018</div><div><b>To: </b> "nginx-devel"<nginx-devel@nginx.org>; <wbr></div><div></div><div><b>Subject: </b> Re: [PATCH] The auto parameter of the worker_processes supports todetect the container environment.</div></div><div><br></div>Hello!<br><br>On Wed, Apr 25, 2018 at 12:47:13AM +0800, agile6v wrote:<br><br>> # HG changeset patch<br>> # User Agile6v <agile6v@agile6v.com><br>> # Date 1524585905 -28800<br>> #      Wed Apr 25 00:05:05 2018 +0800<br>> # Node ID 89793df28d1bcf2baf00e389e6806d32d7435886<br>> # Parent  7c614ef3c6ea330c62630d5065f961a27d0f82cd<br>> The auto parameter of the worker_processes supports to detect the container environment.<br>> <br>> <br>> Docker mounts cgroup information into container starting with version 1.8,<br>> so it is possible to determine the appropriate number of CPUs based on the <br>> cgroup information in the container. Refer to JDK related implementation:<br>> https://bugs.openjdk.java.net/browse/JDK-8146115<br>> <br>> <br>> diff -r 7c614ef3c6ea -r 89793df28d1b auto/sources<br>> --- a/auto/sources      Wed Apr 18 16:11:41 2018 +0300<br>> +++ b/auto/sources Wed Apr 25 00:05:05 2018 +0800<br>> @@ -192,8 +192,8 @@<br>>  FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c<br>>  FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c<br>>  <br>> -LINUX_DEPS="src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux.h"<br>> -LINUX_SRCS=src/os/unix/ngx_linux_init.c<br>> +LINUX_DEPS="src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux.h src/os/unix/ngx_container.h"<br>> +LINUX_SRCS="src/os/unix/ngx_linux_init.c src/os/unix/ngx_container.c"<br>>  LINUX_SENDFILE_SRCS=src/os/unix/ngx_linux_sendfile_chain.c<br>>  <br>>  <br>> diff -r 7c614ef3c6ea -r 89793df28d1b src/os/unix/ngx_container.c<br>> --- /dev/null        Thu Jan 01 00:00:00 1970 +0000<br>> +++ b/src/os/unix/ngx_container.c  Wed Apr 25 00:05:05 2018 +0800<br>> @@ -0,0 +1,418 @@<br>> +<br>> +/*<br>> + * Copyright (C) agile6v<br>> + * Copyright (C) Xiaomi, Inc.<br>> + */<br>> +<br>> +#include <ngx_config.h><br>> +#include <ngx_core.h><br>> +<br>> +#define NGX_BUFFER_SIZE     8192<br>> +#define PER_CPU_SHARES      1024<br>> +<br>> +typedef struct {<br>> +    ngx_str_t root;<br>> +    ngx_str_t path;<br>> +    ngx_str_t mount_point;<br>> +} cgroup_subsystem_info;<br>> +<br>> +static cgroup_subsystem_info cpu_subsystem;<br>> +<br>> +static ngx_str_t proc_cgroup_file   = ngx_string("/proc/self/cgroup");<br>> +static ngx_str_t proc_mount_file    = ngx_string("/proc/self/mountinfo");<br>> +static ngx_str_t cpu_cfs_period     = ngx_string("/cpu.cfs_period_us");<br>> +static ngx_str_t cpu_cfs_quota      = ngx_string("/cpu.cfs_quota_us");<br>> +static ngx_str_t cpu_cfs_shares     = ngx_string("/cpu.shares");<br><br>[...]<br><br>400+ lines of code to obtain a number which is expected to be <br>directly available via the sysconf(_SC_NPROCESSORS_ONLN) call <br>might be a bit too many.<br><br>Thank you for your effort, but no.<br><br>-- <br>Maxim Dounin<br>http://mdounin.ru/<br>_______________________________________________<br>nginx-devel mailing list<br>nginx-devel@nginx.org<br>http://mailman.nginx.org/mailman/listinfo/nginx-devel</div>