Welcome! Log In Create A New Profile

Advanced

Re: HTTP/2: used bitwise operation to replace division and modulo.

March 05, 2018 03:30AM
On Sun, Mar 04, 2018 at 10:36:43PM -0800, tokers wrote:
> # HG changeset patch
> # User Alex Zhang <zchao1995@gmail.com>
> # Date 1520229178 -28800
> # Mon Mar 05 13:52:58 2018 +0800
> # Node ID 03ecef37a93d541e55802393636c101a4da14550
> # Parent 265c29b0b8b8c54b1c623268481ed85324ce3c79
> HTTP/2: used bitwise operation to replace division and modulo.
>
> Signed-off-by: Alex Zhang <zchao1995@gmail.com>

No, thanks.

- there is no difference in assembler output even with -O0,
with either GCC or Clang, and the author likes it the way
it's written;

- this would require parenthesis around the & operator on
the LHS of ==.

- the patch is incomplete.

Also, please fix your MUA so that it doesn't break patches
by wrapping lines.

> diff -r 265c29b0b8b8 -r 03ecef37a93d src/http/v2/ngx_http_v2.c
> --- a/src/http/v2/ngx_http_v2.c Thu Mar 01 11:42:55 2018 +0300
> +++ b/src/http/v2/ngx_http_v2.c Mon Mar 05 13:52:58 2018 +0800
> @@ -1094,7 +1094,7 @@
> "depends on %ui excl:%ui weight:%ui",
> h2c->state.sid, depend, excl, weight);
>
> - if (h2c->state.sid % 2 == 0 || h2c->state.sid <= h2c->last_sid) {
> + if (h2c->state.sid & 0x1 == 0 || h2c->state.sid <= h2c->last_sid) {
> ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
> "client sent HEADERS frame with incorrect identifier
> "
> "%ui, the last was %ui", h2c->state.sid,
> h2c->last_sid);
> diff -r 265c29b0b8b8 -r 03ecef37a93d src/http/v2/ngx_http_v2_filter_module.c
> --- a/src/http/v2/ngx_http_v2_filter_module.c Thu Mar 01 11:42:55 2018
> +0300
> +++ b/src/http/v2/ngx_http_v2_filter_module.c Mon Mar 05 13:52:58 2018
> +0800
> @@ -1149,8 +1149,8 @@
> value -= prefix;
>
> while (value >= 128) {
> - *pos++ = value % 128 + 128;
> - value /= 128;
> + *pos++ = (value & 0x7f) + 128;
> + value >>= 7;
> }
>
> *pos++ = (u_char) value;

> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel


--
Ruslan Ermilov
Assume stupidity not malice
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

HTTP/2: used bitwise operation to replace division and modulo.

tokers 709 March 05, 2018 01:38AM

Re: HTTP/2: used bitwise operation to replace division and modulo.

ru@nginx.com 517 March 05, 2018 03:30AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 313
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready