commit c36792bd79f3a97f292ab0612aa5c3ab1b4d9e70 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Tue Apr 7 20:52:28 2020 -0700 Revert my KEY_OPS_CFLAGS change to src/Makefile.in Now that -Og inlining has been improved this is no longer helpful. * src/Makefile.in (KEY_OPS_CFLAGS): Remove. All uses removed. This improved CPU performance of ‘make compile-always’ by 5% on my platform, which was gcc -Og, GCC 9.3.1 20200317 (Red Hat 9.3.1-1), Fedora 31 x86-64 (AMD Phenom II X4 910e, circa 2010). diff --git a/src/Makefile.in b/src/Makefile.in index dfd322553b..552dd2e50a 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -377,14 +377,11 @@ endif # Flags that might be in WARN_CFLAGS but are not valid for Objective C. NON_OBJC_CFLAGS = -Wignored-attributes -Wignored-qualifiers -Wopenmp-simd -# Cajole GCC into inlining key ops even if it wouldn't normally. -KEY_OPS_CFLAGS = $(if $(filter -Og,$(CFLAGS)),-DDEFINE_KEY_OPS_AS_MACROS) - # -Demacs makes some files produce the correct version for use in Emacs. # MYCPPFLAGS is for by-hand Emacs-specific overrides, e.g., # "make MYCPPFLAGS='-DDBUS_DEBUG'". -EMACS_CFLAGS = -Demacs $(KEY_OPS_CFLAGS) $(MYCPPFLAGS) \ - -I. -I$(srcdir) -I$(lib) -I$(top_srcdir)/lib \ +EMACS_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \ + -I$(lib) -I$(top_srcdir)/lib \ $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ $(PNG_CFLAGS) $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ commit b9b32074cecb0e0d20cf527eadacbb0b7f5cced9 Author: Paul Eggert Date: Tue Apr 7 16:57:04 2020 -0700 Improve inlining when compiling with -Og * src/conf_post.h (EXTERN_INLINE) [!EMACS_EXTERN_INLINE]: Make it static inline, not merely static. This is a worthwhile performance improvement on my two platforms A and B (see below). On my platform A this change improves user+system CPU performance of ‘make compile-always’ by 52% on an -Og build, and by 1.4% on the default -O2 build. On my platform B this improves the same benchmark by 41% on an -Og build, and by -0.8% on the default -O2 build. That "-0.8%" is a small negative for this change, and I recall that it is why I didn't make this change earlier. However, Platform B uses an older GCC so we needn't worry overmuch about this small negative. With this change the performance advantage of -O2 over -Og has dropped on platform A; formerly -O2 was 87% faster than -Og, and now it is only 25% faster. On platform B the performance advantage of -O2 over -Og has dropped from being 62% faster to being 14% faster. Platform A is GCC 9.3.1 20200317 (Red Hat 9.3.1-1) on Fedora 31 x86-64 (AMD Phenom II X4 910e, circa 2010). Platform B is GCC (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 on Ubuntu 18.04.4 (Intel Xeon E3-1225 V2, circa 2012). This patch was inspired by a suggestion by Andrea Corallo in: https://lists.gnu.org/r/emacs-devel/2020-04/msg00263.html diff --git a/src/conf_post.h b/src/conf_post.h index eb8fb18c00..79fb4cfe8a 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -432,15 +432,13 @@ extern int emacs_setenv_TZ (char const *); #else -/* Use 'static' instead of 'extern inline' because 'static' typically - has better performance for Emacs. Do not use the 'inline' keyword, - as modern compilers inline automatically. ATTRIBUTE_UNUSED - pacifies gcc -Wunused-function. */ +/* Use 'static inline' instead of 'extern inline' because 'static inline' + has much better performance for Emacs when compiled with 'gcc -Og'. */ # ifndef INLINE # define INLINE EXTERN_INLINE # endif -# define EXTERN_INLINE static ATTRIBUTE_UNUSED +# define EXTERN_INLINE static inline # define INLINE_HEADER_BEGIN # define INLINE_HEADER_END commit 6382e1330814ca4df20eeccd8b4ef9ca17b997af Author: Robert Pluim Date: Thu Apr 2 18:41:33 2020 +0200 Add :coding support to open-network-stream and open-gnutls-stream * doc/lispref/processes.texi (Network): Describe :coding keyword support. * doc/misc/emacs-gnutls.texi (Help For Developers): Describe :coding keyword support. * etc/NEWS: Announce change to open-network-stream and open-gnutls-stream. * lisp/net/gnutls.el (open-gnutls-stream): Add support for :coding, pass it down to open-network-stream. * lisp/net/network-stream.el (open-network-stream) (network-stream-open-plain, network-stream-open-starttls): Add support for :coding, pass it down to make-network-process. (network-stream-open-shell): Add support-for :coding, use set-process-coding-system to set it after process creation. diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 14cd079c56..735e9fd7db 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -2463,6 +2463,12 @@ that are mainly relevant to encrypted connections: @item :nowait @var{boolean} If non-@code{nil}, try to make an asynchronous connection. +@item :coding @var{coding} +Use this to set the coding systems used by the network process, in +preference to binding @code{coding-system-for-read} or +@code{coding-system-for-write}. @xref{Network Processes} for +details. + @item :type @var{type} The type of connection. Options are: diff --git a/doc/misc/emacs-gnutls.texi b/doc/misc/emacs-gnutls.texi index 555a4b1b56..c3e69178fc 100644 --- a/doc/misc/emacs-gnutls.texi +++ b/doc/misc/emacs-gnutls.texi @@ -190,7 +190,7 @@ the connection process. The optional @var{parameters} argument is a list of keywords and values. The only keywords which currently have any effect are -@code{:client-certificate} and @code{:nowait}. +@code{:client-certificate}, @code{:nowait}, and @code{:coding}. Passing @w{@code{:client certificate t}} triggers looking up of client certificates matching @var{host} and @var{service} using the diff --git a/etc/NEWS b/etc/NEWS index 1af368caa6..ef2697f485 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -339,6 +339,15 @@ Emacs depended on the previous behavior; if you really want the process' coding-system to be nil, use 'set-process-coding-system' after the process has been created, or pass in ":coding '(nil nil)". ++++ +** 'open-network-stream' now accepts a :coding argument. +This allows specifying the coding systems used by a network process +for encoding and decoding without having to bind +coding-system-for-{read,write} or call 'set-process-coding-system'. + ++++ +** 'open-gnutls-stream' now also accepts a :coding argument. + * Changes in Emacs 28.1 on Non-Free Operating Systems diff --git a/lisp/net/gnutls.el b/lisp/net/gnutls.el index 459156e6d2..cd86b4dea6 100644 --- a/lisp/net/gnutls.el +++ b/lisp/net/gnutls.el @@ -169,8 +169,9 @@ Third arg HOST is the name of the host to connect to, or its IP address. Fourth arg SERVICE is the name of the service desired, or an integer specifying a port number to connect to. Fifth arg PARAMETERS is an optional list of keyword/value pairs. -Only :client-certificate and :nowait keywords are recognized, and -have the same meaning as for `open-network-stream'. +Only :client-certificate, :nowait, and :coding keywords are +recognized, and have the same meaning as for +`open-network-stream'. For historical reasons PARAMETERS can also be a symbol, which is interpreted the same as passing a list containing :nowait and the value of that symbol. @@ -208,7 +209,8 @@ trust and key files, and priority string." (gnutls-boot-parameters :type 'gnutls-x509pki :keylist keylist - :hostname (puny-encode-domain host))))))) + :hostname (puny-encode-domain host)))) + :coding (plist-get parameters :coding)))) (if nowait process (gnutls-negotiate :process process diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el index e99d7a372c..1d5cf382a8 100644 --- a/lisp/net/network-stream.el +++ b/lisp/net/network-stream.el @@ -113,6 +113,10 @@ values: `ssl' -- Equivalent to `tls'. `shell' -- A shell connection. +:coding is a symbol or a cons used to specify the coding systems +used to decode and encode the data which the process reads and +writes. See `make-network-process' for details. + :return-list specifies this function's return value. If omitted or nil, return a process object. A non-nil means to return (PROC . PROPS), where PROC is a process object and PROPS @@ -189,7 +193,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." :host (puny-encode-domain host) :service service :nowait (plist-get parameters :nowait) :tls-parameters - (plist-get parameters :tls-parameters)) + (plist-get parameters :tls-parameters) + :coding (plist-get parameters :coding)) (let ((work-buffer (or buffer (generate-new-buffer " *stream buffer*"))) (fun (cond ((and (eq type 'plain) @@ -249,7 +254,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." (stream (make-network-process :name name :buffer buffer :host (puny-encode-domain host) :service service - :nowait (plist-get parameters :nowait)))) + :nowait (plist-get parameters :nowait) + :coding (plist-get parameters :coding)))) (when (plist-get parameters :warn-unless-encrypted) (setq stream (nsm-verify-connection stream host service nil t))) (list stream @@ -270,7 +276,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE) (stream (make-network-process :name name :buffer buffer :host (puny-encode-domain host) - :service service)) + :service service + :coding (plist-get parameters :coding))) (greeting (and (not (plist-get parameters :nogreeting)) (network-stream-get-response stream start eoc))) (capabilities (network-stream-command stream capability-command @@ -350,7 +357,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." (setq stream (make-network-process :name name :buffer buffer :host (puny-encode-domain host) - :service service)) + :service service + :coding (plist-get parameters :coding))) (network-stream-get-response stream start eoc))) (unless (process-live-p stream) (error "Unable to negotiate a TLS connection with %s/%s" @@ -453,6 +461,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." (let* ((capability-command (plist-get parameters :capability-command)) (eoc (plist-get parameters :end-of-command)) (start (with-current-buffer buffer (point))) + (coding (plist-get parameters :coding)) (stream (let ((process-connection-type nil)) (start-process name buffer shell-file-name shell-command-switch @@ -461,6 +470,13 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." (format-spec-make ?s host ?p service)))))) + (when coding (if (consp coding) + (set-process-coding-system stream + (car coding) + (cdr coding)) + (set-process-coding-system stream + coding + coding))) (list stream (network-stream-get-response stream start eoc) (network-stream-command stream capability-command commit 23b04ef0e7d03cd7c178b544d5fff2bda4c7c504 Author: Robert Pluim Date: Fri Apr 3 17:37:01 2020 +0200 Use length field when dns-query is using TCP * net/dns.el (dns-write): Correct spelling in docstring. (dns-read): Add optional tcp-p parameter, skip 2-byte length field if non-nil. (dns-query): Tell dns-read and dns-write if we're using TCP. diff --git a/lisp/net/dns.el b/lisp/net/dns.el index 177df4e332..53ea0b19b5 100644 --- a/lisp/net/dns.el +++ b/lisp/net/dns.el @@ -138,7 +138,7 @@ updated. Set this variable to t to disable the check.") (defun dns-write (spec &optional tcp-p) "Write a DNS packet according to SPEC. -If TCP-P, the first two bytes of the package with be the length field." +If TCP-P, the first two bytes of the packet will be the length field." (with-temp-buffer (set-buffer-multibyte nil) (dns-write-bytes (dns-get 'id spec) 2) @@ -189,13 +189,15 @@ If TCP-P, the first two bytes of the package with be the length field." (dns-write-bytes (buffer-size) 2)) (buffer-string))) -(defun dns-read (packet) +(defun dns-read (packet &optional tcp-p) (with-temp-buffer (set-buffer-multibyte nil) (let ((spec nil) queries answers authorities additionals) (insert packet) - (goto-char (point-min)) + ;; When using TCP we have a 2 byte length field to ignore. + (goto-char (+ (point-min) + (if tcp-p 2 0))) (push (list 'id (dns-read-bytes 2)) spec) (let ((byte (dns-read-bytes 1))) (push (list 'response-p (if (zerop (logand byte (ash 1 7))) nil t)) @@ -407,23 +409,25 @@ If REVERSEP, look up an IP address." nil) (with-temp-buffer (set-buffer-multibyte nil) - (let ((process (condition-case () - (dns-make-network-process (car dns-servers)) - (error - (message - "dns: Got an error while trying to talk to %s" - (car dns-servers)) - nil))) + (let* ((process (condition-case () + (dns-make-network-process (car dns-servers)) + (error + (message + "dns: Got an error while trying to talk to %s" + (car dns-servers)) + nil))) (step 100) (times (* dns-timeout 1000)) - (id (random 65000))) + (id (random 65000)) + (tcp-p (and process (not (process-contact process :type))))) (when process (process-send-string process (dns-write `((id ,id) (opcode query) (queries ((,name (type ,type)))) - (recursion-desired-p t)))) + (recursion-desired-p t)) + tcp-p)) (while (and (zerop (buffer-size)) (> times 0)) (let ((step-sec (/ step 1000.0))) @@ -436,7 +440,7 @@ If REVERSEP, look up an IP address." (when (and (>= (buffer-size) 2) ;; We had a time-out. (> times 0)) - (let ((result (dns-read (buffer-string)))) + (let ((result (dns-read (buffer-string) tcp-p))) (if fullp result (let ((answer (car (dns-get 'answers result))))