Opened 6 years ago

#1437 new enhancement

Optimize locality for listening sockets with the help of SO_INCOMING_CPU

Reported by: vadimjunk@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.12.x
Keywords: Cc:
uname -a: Linux localhost.localdomain 4.9.51-13 #1 SMP Wed Sep 20 12:07:38 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.12.2
built by gcc 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04)
built with OpenSSL 1.0.2 (compatible; BoringSSL) (running with BoringSSL)
TLS SNI support enabled
configure arguments: --with-cc-opt='-O3 -g' --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-http_geoip_module --lock-path=/var/lock/nginx.lock --pid-path=/var/run/ --with-debug --with-http_addition_module --with-http_flv_module --with-http_dav_module --with-http_gzip_static_module --with-http_gunzip_module --with-threads --with-file-aio --with-http_perl_module --with-http_realip_module --with-http_stub_status_module --with-http_sub_module --with-http_xslt_module --with-http_auth_request_module --with-http_ssl_module


To achieve the best cpu locality for listening sockets with SO_REUSEPORT we can set socket option SO_INCOMING_CPU with cpu number taken from worker_affinity.
The included patch works with linux kernel 4.4+ and takes first active cpu for worker from affinity in case of multiple cpus set for worker.

Attachments (1)

SO_INCOMING_CPU.patch (1.3 KB ) - added by vadimjunk@… 6 years ago.

Download all attachments as: .zip

Change History (1)

by vadimjunk@…, 6 years ago

Attachment: SO_INCOMING_CPU.patch added
Note: See TracTickets for help on using tickets.