* Dubious diff using --diff-algorithm=histogram
@ 2023-04-04 19:51 Alejandro Colomar
2023-04-04 19:53 ` Alejandro Colomar
2023-04-28 21:36 ` Alejandro Colomar
0 siblings, 2 replies; 3+ messages in thread
From: Alejandro Colomar @ 2023-04-04 19:51 UTC (permalink / raw)
To: Git Mailing List, Alejandro Colomar
[-- Attachment #1.1: Type: text/plain, Size: 2802 bytes --]
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
---
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..92bdfb1f 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:
- if (nxt_slow_path(end - p < 10)) {
-
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..92bdfb1f 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;
}
alx@asus5775:~/src/nginx/unit/space$ git diff --diff-algorithm=myers
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8646a6ce..92bdfb1f 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:
- if (nxt_slow_path(end - p < 10)) {
-
p++;
+ if (nxt_slow_path(end - p < 10)) {
+
if (p == end) {
return NXT_AGAIN;
}
alx@asus5775:~/src/nginx/unit/space$ git diff --diff-algorithm=minimal
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8646a6ce..92bdfb1f 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:
- if (nxt_slow_path(end - p < 10)) {
-
p++;
+ if (nxt_slow_path(end - p < 10)) {
+
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 --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Dubious diff using --diff-algorithm=histogram
2023-04-04 19:51 Dubious diff using --diff-algorithm=histogram Alejandro Colomar
@ 2023-04-04 19:53 ` Alejandro Colomar
2023-04-28 21:36 ` Alejandro Colomar
1 sibling, 0 replies; 3+ messages in thread
From: Alejandro Colomar @ 2023-04-04 19:53 UTC (permalink / raw)
To: Git Mailing List, Alejandro Colomar
[-- 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 --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Dubious diff using --diff-algorithm=histogram
2023-04-04 19:51 Dubious diff using --diff-algorithm=histogram Alejandro Colomar
2023-04-04 19:53 ` Alejandro Colomar
@ 2023-04-28 21:36 ` Alejandro Colomar
1 sibling, 0 replies; 3+ messages in thread
From: Alejandro Colomar @ 2023-04-28 21:36 UTC (permalink / raw)
To: Git Mailing List, Alejandro Colomar
[-- Attachment #1.1: Type: text/plain, Size: 1018 bytes --]
Here's another example of a dubious diff using histogram:
@@ -50,8 +65,11 @@ .SH Examples
nxt_unit_ctx_t *ctx;
nxt_unit_init_t init;
- bzero(&init, sizeof(nxt_unit_init_t));
+ if (argc == 3 && strcmp(argv[1], "-t") == 0) {
+ nthreads = atoi(argv[2]);
+ }
+ bzero(&init, sizeof(nxt_unit_init_t));
init.callbacks.request_handler = &request_handler;
init.callbacks.ready_handler = &ready_handler;
That call to bzero(3) is the only one in the entire file.
patience shows this instead:
@@ -50,8 +65,11 @@ .SH Examples
nxt_unit_ctx_t *ctx;
nxt_unit_init_t init;
+ if (argc == 3 && strcmp(argv[1], "-t") == 0) {
+ nthreads = atoi(argv[2]);
+ }
+
bzero(&init, sizeof(nxt_unit_init_t));
-
init.callbacks.request_handler = &request_handler;
init.callbacks.ready_handler = &ready_handler;
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-28 21:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-04 19:51 Dubious diff using --diff-algorithm=histogram Alejandro Colomar
2023-04-04 19:53 ` Alejandro Colomar
2023-04-28 21:36 ` Alejandro Colomar
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).