Article View: news.software.readers
Article #13470[Patch] Make tin threading faster
From: Shih-Kun Huang
Date: Mon, 05 Dec 1994 09:38
Date: Mon, 05 Dec 1994 09:38
96 lines
3532 bytes
3532 bytes
I am not sure if the following patch has been done.
It is a little modification for tin122's make_thread to
speed up "making thread" from O(n^2) to O(n) at the expanse of one
extra int for each "hash node".
Two files art.c and hashstr.c are modified and the modifications
are wrapped with "FAST_THREADING". Please add -DFAST_THREADING to your
Makefile before making the new tin.
I have tested to make thread in a newsgroups with 7445 articles:
without patch: grouping 10 seconds, threading 19 seconds
with patch: grouping 10 seconds, threading less than 1 second
The patch has been tested on my site for several weeks without problems
I am afraid I missed something unconsidered, so post here.
---------------------------------------------------------------------
diff -rus tin/art.c ntin/art.c
--- tin/art.c Tue Nov 29 09:51:23 1994
+++ ntin/art.c Tue Nov 29 09:51:16 1994
@@ -462,9 +462,27 @@
}
*/
for (i = 0; i < top; i++) {
+#ifdef FAST_THREADING
+ int j, *aptr;
+#endif
if (arts[i].thread != ART_NORMAL || IGNORE_ART(i)) {
continue;
}
+#ifdef FAST_THREADING
+ aptr = (int*)arts[i].subject;
+ aptr -=2;
+ j = *aptr;
+ if (j != -1 && j < i) {
+ if (! IGNORE_ART(i) && arts[i].inthread == FALSE &&
+ ((arts[i].subject == arts[j].subject) ||
+ ((arts[i].part || arts[i].patch) &&
+ arts[i].archive == arts[j].archive))) {
+ arts[j].thread = i;
+ arts[i].inthread = TRUE;
+ }
+ }
+ *aptr = i;
+#else
for (j = i+1; j < top; j++) {
if (! IGNORE_ART(j) && arts[j].inthread == FALSE &&
((arts[i].subject == arts[j].subject) ||
@@ -475,6 +493,7 @@
break;
}
}
+#endif
}
}
diff -rus tin/hashstr.c ntin/hashstr.c
--- tin/hashstr.c Tue Nov 29 09:51:23 1994
+++ ntin/hashstr.c Tue Nov 29 09:51:16 1994
@@ -32,7 +32,6 @@
struct t_hashnode *table[HASHNODE_TABLE_SIZE];
-
char *
hash_str (s)
char *s;
@@ -85,8 +84,14 @@
p = (struct t_hashnode *) my_malloc ((unsigned) sizeof (struct t_hashnode));
p->next = (struct t_hashnode *) 0;
+#ifdef FAST_THREADING
+ iptr = (int *) my_malloc ((unsigned) strlen (s) + sizeof (int)*2 + 1);
+ *iptr++ = -1;
+ *iptr++ = -1;
+#else
iptr = (int *) my_malloc ((unsigned) strlen (s) + sizeof (int) + 1);
*iptr++ = -1;
+#endif
p->s = (char *) iptr;
strcpy (p->s, s);
return (p);
@@ -118,7 +123,11 @@
next = p->next;
if (p->s != (char *) 0) {
iptr = (int *) p->s;
+#ifdef FAST_THREADING
+ iptr-=2;
+#else
iptr--;
+#endif
free ((char *) iptr);
}
free ((char *) p);
--------------------- end of patch ---------------------------------
Technical Details
Message-ID:
<3bun3j$c9u@news.csie.nctu.edu.tw>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!bga.com!news.sprintlink.net!howland.reston.ans.net!nctuccca.edu.tw!news.cc.nctu.edu.tw!news.csie.nctu.edu.tw!skhuangShow Full Headers
Complete Article Headers
Message-ID: <3bun3j$c9u@news.csie.nctu.edu.tw> Subject: [Patch] Make tin threading faster Date: Mon, 05 Dec 1994 09:38:59 +0000 From: skhuang@csie.nctu.edu.tw (Shih-Kun Huang) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!bga.com!news.sprintlink.net!howland.reston.ans.net!nctuccca.edu.tw!news.cc.nctu.edu.tw!news.csie.nctu.edu.tw!skhuang Newsgroups: news.software.readers Organization: Dep. Computer Sci. & Information Eng., Chiao Tung Univ., Taiwan, R.O.C Lines: 96 Reply-To: skhuang@csie.nctu.edu.tw NNTP-Posting-Host: skhuang@operator-gw.csie.nctu.edu.tw X-Newsreader: TIN [version 1.2 PL2]