Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Justin Zobel
Abstract
The size of
We propose a new
Introduction
School
address.
Thus, some years ago, the fastest algorithms were
rsinha@cs.rmit.edu.au
School of Computer Science and Information Technology,
jz@cs.rmit.edu.au
whatever the cache size is on that particular hardware, method. Using a cache simulator, we show that the gain
may rapidly degrade as data set size increases. Radix-
Not only is it more efficient for the data sets tested, but
A burst trie
was proposed in the early 1990s [5] and has since then
radixsort.
quicksort.
Forward radixsort Forward radixsort was developed by Andersson and Nilsson in 1994 [1, 15]. It com-
per.
Forward-16.
MSD radixsort MSD radixsort examines only the
radixsort.
Burstsort is
inserted be c1 , . . . , cn of n characters.
The leading
inserted.
When
of varying parameters.
rapidly.
When
1 Our
ABC
ABC
T
RN
RK
WXYZ
WXYZ
ABC
ABCDE
S T
YZ
ST
WXYZ
NE
ES
Figure 1: Burst trie with four trie nodes, five containers, and nine strings, without duplicates.
prefixes are inspected once only. Also, in many data
Trie nodes are retrieved at random, but there are relatively few of these and thus most can be simultaneously
Experiments
The words
the access trie would be expected to have a reasonable non-alphabetic characters in web pages (after removal
number of containers, in the range 10100 for an of tags, images, and other non-text information). The
Choosing L = 8, 192 web URLs have been drawn from the same collection.
means that container sizes will typically be in the range The genomic strings are from GenBank. For word and
2 Some
Set 2
Set 3
Set 4
Set 5
Set 6
1.013
3.136
7.954
27.951
93.087
304.279
0.599
1.549
3.281
9.315
25.456
70.246
3.162
10
31.623
100
316.230
1.1
3.212
10.796
35.640
117.068
381.967
3.162
10
31.623
100
316.230
3.162
10
31.623
100
316.230
0.953
3.016
9.537
30.158
95.367
301.580
0.751
1.593
2.363
2.600
2.620
2.620
3.162
10
31.623
100
316.230
1.004
3.167
10.015
31.664
100.121
316.606
(10 )
0.891
2.762
8.575
26.833
83.859
260.140
3.162
10
31.623
100
316.230
3.03
9.607
30.386
96.156
304.118
0.361
0.92354
2.355
5.769
12.898
3.162
10
31.623
100
Duplicates
Size M b
(105 )
Distinct Words
Distinct Words
Distinct Words
URL
Size M b
Results
Set 2
Set 3
Set 4
Set 5
Set 6
122
528
1,770
7,600
30,100
114,440
Multikey quicksort
62
272
920
3,830
14,950
56,070
MBM radixsort
58
238
822
3,650
15,460
61,560
MSD radixsort
72
290
1,000
3,870
14,470
56,790
74
288
900
3,360
12,410
51,870
Forward-8
Adaptive radixsort
146
676
2,030
7,590
28,670
113,540
Forward-16
116
486
1,410
5,120
19,150
74,770
58
218
630
2,220
7,950
29,910
Burstsort
Time (normalise)
0.0006
Burstsort
Adaptive radixsort
MSD radixsort
Multikey quicksort
MBM radixsort
Forward 16
Quicksort
Forward 8
0.0004
0.0002
100000
1000000
10000000
Size of dataset
relative performance.
not. For all of these sets of strings drawn from real data,
for 256 characters), and the distribution of characters burstsort is consistently the fastest method.
is close to uniform random. Burstsort is relatively even
more efficient for this data than for the words drawn
For
cost per string declines with data set size; for all other
Time (normalise)
0.0006
Burstsort
Adaptive radixsort
MSD radixsort
Multikey quicksort
MBM radixsort
Forward 16
Forward 8
Quicksort
0.0004
0.0002
100000
1000000
10000000
Size of dataset
Set 2
Set 3
Set 4
Set 5
Set 6
156
674
2,580
9,640
35,330
129,720
72
324
1,250
4,610
16,670
62,680
MBM radixsort
72
368
1,570
6,200
23,700
90,700
MSD radixsort
102
442
1,640
5,770
20,550
79,840
Adaptive radixsort
92
404
1,500
4,980
17,800
66,100
Forward-8
246
1,074
3,850
12,640
41,110
147,770
Forward-16
174
712
2,380
7,190
23,290
86,400
70
258
870
2,830
8,990
31,540
Burstsort
be used.
We
have
experimented
artificially-created datasets,
3 Available
with
several
other
from www.cs.princeton.edu/~rs/strings.
Time (normalise)
0.0006
Burstsort
Multikey quicksort
Adaptive radixsort
MSD radixsort
MBM radixsort
Forward 16
Forward 8
Quicksort
0.0004
0.0002
100000
1000000
10000000
Size of dataset
Figure 4: Genome sorting time. The vertical scale is time in milliseconds divided by n log n.
the worst cases in the algorithms. We generated three
collections ranging in size from one to ten million
strings, as follows.
A. The length of the strings is one hundred, the alphabet has only one character, and the size of the
collection is one million.
B. The length of the strings ranges from one to a
hundred, the alphabet size is small (nine) and
the characters appear randomly. The size of the
collection is ten million.
C. The length of the strings ranges from one to hun-
Quicksort
1,040
34,440
3,900
Multikey quicksort
11,530
18,750
5,970
MBM radixsort
18,130
40,220
19,620
MSD radixsort
10,580
26,380
5,630
7,870
20,060
4,270
Adaptive radixsort
Forward-8
12,290
38,800
6,580
Forward-16
8,140
27,890
4,450
Burstsort
2,730
10,090
1,420
We have used
the data has behaved rather like real strings, but with
exaggerated string lengths. In Set C, MBM radixsort cates case was observed for the other data sets. Figure 7
in the other experiments, the only method to ever do is normalised by n (not n log n as in Figure 3) to show
better than burstsortis extremely poor.
Cache efficiency To test our hypothesis that the efficiency of burstsort was due to its ability to make better
0.0010
Time (normalise)
Burstsort
Multikey quicksort
Adaptive radixsort
Quicksort
MSD radixsort
Forward 16
MBM radixsort
Forward 8
0.0005
100000
1000000
10000000
Size of dataset
Figure 5: URL sorting time. The vertical scale is time in milliseconds divided by n log n.
efficiency, while for large data sets burstsort is clearly
once is so valuable.
for numbers [12, 16, 17, 20] has shown that, for other
of instructions per key, next only to adaptive radixsort, methods are based on elementary forms of radixsort,
and for no duplicates the number of cache misses rises
strings.
Time (normalise)
0.0004
Burstsort
MBM radixsort
Adaptive radixsort
MSD radixsort
Multikey quicksort
Forward 16
Forward 8
Quicksort
0.0002
0.0000
100000
1000000
10000000
Size of dataset
Conclusions
References
asymptotic behaviour.
The main factor that makes burstsort more efficient
than the alternatives is the low rate of cache miss on
large data sets. The trend of current hardware is for
processors to get faster and memories to get larger,
but without substantially speeding up, so that the
number of cycles required to access memory continues
to grow. In this environment, algorithms that make
good use of cache are increasingly more efficient than
the alternatives.
Engineering a
23(11):12491265, 1993.
[6] D. Harman. Overview of the second text retrieval conference (TREC-2). Information Processing & Management, 31(3):271289, 1995.
[7] D. Hawking, N. Craswell, P. Thistlewaite, and D. Harman. Results and challenges in web search evaluation.
In Proc. World-Wide Web Conference, 1999.
[8] S. Heinz and J. Zobel. Practical data structures for
managing small sets of strings.
In M. Oudshoorn,
20
Cache misses/Key
15
Burstsort
MBM radixsort
Adaptive Radixsort
MSD radixsort
Multikey quicksort
Quicksort
Forward 16
Forward 8
10
0
100000
1000000
10000000
Size of dataset
Cache misses/Key
30
Burstsort
Quicksort
Adaptive radixsort
Multikey quicksort
MBM radixsort
MSD radixsort
Forward 16
20
10
0
100000
1000000
10000000
Size of dataset
Figure 7: Cache misses, 1 Mb cache, 8-way associativity, 32 bytes block size. Upper: no duplicates. Lower: URLs.
Transactions on Information Systems, 20(2):192223,
2002.
[11] D. S. Johnson. A theoreticians guide to the experimental analysis of algorithms. In Goldwasser, Johnson, and
http://www.cacheprof.org.
[13] P. M. McIlroy, K. Bostic, and M. D. McIlroy. Engineering radix sort. Computing Systems, 6(1):527, 1993.
[14] A. Moffat, G. Eddy, and O. Petersson.
Splaysort: