13.02.2013 Views

2 Debian Code Search: An Overview

2 Debian Code Search: An Overview

2 Debian Code Search: An Overview

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4 <strong>Search</strong> result quality<br />

4.11 Performance by processing step (profiling)<br />

When optimizing software, the first step is to profile the software to see which part of it is<br />

actually slow. This is important because intuitively, one might have an entirely different part<br />

in mind, for example an algorithm which has some potential for optimization, while there<br />

are many other low-hanging fruit which can yield even greater performance improvements.<br />

To profile which parts of <strong>Debian</strong> <strong>Code</strong> <strong>Search</strong> are slow, additional parameters have been<br />

added to dcs-web, just like in section 4.10.1. Since the code is so simple, the additional<br />

measurements do not influence the performance itself in any noticeable way:<br />

func <strong>Search</strong>(w http.ResponseWriter , r *http.Request) {<br />

var t0, t1 time.Time<br />

t0 = time.Now()<br />

// ... send request to index -backend ...<br />

t1 = time.Now()<br />

// ...<br />

w.Header().Add("dcs -t0", fmt.Sprintf("%.2fms",<br />

float32(t1.Sub(t0).Nanoseconds())/1000/1000))<br />

}<br />

4.11.1 Before any optimization<br />

Figure 4.10 shows that a substantial amount of time is used for the trigram index lookup:<br />

It takes about 40 ms until the first result appears. Note that results are ranked as they are<br />

received, so the “ranking” step covers receiving and ranking the files.<br />

response time<br />

100 ms<br />

80 ms<br />

60 ms<br />

40 ms<br />

20 ms<br />

0 ms<br />

Response split into steps<br />

0 20 40 60 80 100<br />

total time<br />

grep<br />

request<br />

sorting<br />

ranking<br />

n-gram<br />

Figure 4.10: The trigram index lookup (“n-gram”) took almost as long as the actual searching<br />

of files containing possible matches (“grep”) before optimization.<br />

52

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!