From: Alejandro Colomar <alx.manpages@gmail.com>
To: Git Mailing List <git@vger.kernel.org>,
Alejandro Colomar <alx@nginx.com>
Subject: Re: Dubious diff using --diff-algorithm=histogram
Date: Tue, 4 Apr 2023 21:53:05 +0200 [thread overview]
Message-ID: <0f90f1a0-56bc-7ca4-e276-9c163ec8ec2c@gmail.com> (raw)
In-Reply-To: <a0b6d751-25fd-a132-f8a5-9844e5d9b8a6@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1864 bytes --]
On 4/4/23 21:51, Alejandro Colomar wrote:
> Hi,
>
> I've met some strange diff with the histogram algorithm. I know this
> has a lot of magic in it, and it's probably not so trivial to improve,
> and maybe my code base is so weird that it makes the histogram do crazy
> stuff, but I wanted to show it to you in case there's anything that can
> be improved.
>
> So, patience is showing a better diff than histogram, which shouldn't
> happen usually, and less in this case, where p++ is such a common thing
> to do (although maybe this nxt_slow_path() macro is called a lot in the
> file and confuses the histogram?).
>
> Code base: <https://github.com/nginx/unit.git>
>
> Cheers,
> Alex
Now this has surprised me even more:
alx@asus5775:~/src/nginx/unit/space$ git diff --diff-algorithm=histogram
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8646a6ce..3559f2e2 100644
--- a/src/nxt_http_parse.c
+++ b/src/nxt_http_parse.c
@@ -340,9 +340,9 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
space_after_target:
- if (nxt_slow_path(end - p < 10)) {
+ p++;
- p++;
+ if (nxt_slow_path(end - p < 10)) {
if (p == end) {
return NXT_AGAIN;
alx@asus5775:~/src/nginx/unit/space$ git diff --diff-algorithm=patience
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8646a6ce..3559f2e2 100644
--- a/src/nxt_http_parse.c
+++ b/src/nxt_http_parse.c
@@ -340,10 +340,10 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
space_after_target:
+ p++;
+
if (nxt_slow_path(end - p < 10)) {
- p++;
-
if (p == end) {
return NXT_AGAIN;
}
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-04-04 19:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 19:51 Dubious diff using --diff-algorithm=histogram Alejandro Colomar
2023-04-04 19:53 ` Alejandro Colomar [this message]
2023-04-28 21:36 ` Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f90f1a0-56bc-7ca4-e276-9c163ec8ec2c@gmail.com \
--to=alx.manpages@gmail.com \
--cc=alx@nginx.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).