Desktop search

Submit New Article

Last Modified On :   June 12, 2007 7:36 PM PDT
Rate
 


Download this app from here

Desktop Search Sample Application
This sample application will help you get hands on experience with multi-threading using Intel’s dual core processors.   

Environment Note:

In order to use this sample, you will need a working test or development environment. This environment can be obtained by either of the following methods: 1) Creating your own virtual machine test environment with Windows XP SP 2 and Visual Studio 2005 or Microsoft Visual C# Express 2005 installed. You must also have SQL Server Express installed. 2) Install Visual Studio 2005 or Visual C# Express 2005 on a standalone machine. Install SQL Server Express on this machine as well. Regardless of environment, you should be able to peruse the contents of this sample application and be able to easily discern what changes are needed in order to implement multi-threading into your own applications. Setup:
Once you have a suitable execution and testing environment,

Copy and paste the Intel Desktop Search folder containing this sample application on to a computer which has Visual Studio 2005 or Visual C# Express installed. (Note that the virtual machine already has Visual Studio 2005 installed.)

Open the Intel Desktop Search.sln solution in Visual Studio (or Visual C# Express) as an Existing Project/Solution.

Once you have completed the setup process, you can begin debugging this sample application by pressing F5, at which point the main form will load. Once this form is loaded, you will be able to more easily examine how the examples provided in this sample application operate. In this sample application, multi-threaded sections are highlighted in two areas:
Indexing: Desktop searching begins with indexing the computer’s hard disk partitions to find all relevant information that can be searched on. In this application, we look at how multi-threading is used to index multiple partitions. For comparison, this application allows you to index your computer in a single-threaded mode (Figure 1) as well as in a multi-threaded mode (Figure 2). The application indexes text files, image files and audio files. When indexing text files, the application retrieves not only the file name and file path, but also the information stored within the file. For the image and audio files, only the file name and file path are retrieved and stored in the database. Note: If you receive a MDA warning while indexing in single-thread mode, click Continue to allow the application to finish indexing.


Figure 1 Single-threaded Indexing of Partitions


Figure 2 Multi-threaded Indexing of Partitions

Searching: The second component of the desktop search is the searching of the files indexed. In this application, the search is against SQL Server Express database. The results are stored in a three different tables (Figure 3) allowing for multi-threaded searching as each table is accessed. This again is set up so that a user can query the data in a single-threaded mode (Figure 4) as well as a multi-threaded mode (Figure 5).


Figure 3 Database Tables


Figure 4 Single-threaded Searching of the Database


Figure 5 Multi-threaded Searching of the Database


Exploring the Samples:
To observe multi-threading functionality in action, open and run the application. Then index the computer using single-threaded mode. When this is complete, the application will return the time required to index all the files on you computer. Next, index the computer again using the multi-threaded option. After this is complete, you should see an improved time required to index your machine. Once the indexing is complete, perform some searches on the indexed material and see what is returned. Again, try to search using single-threaded mode. Then search again using the multi-threaded mode. Make sure to mark the times required to return results using both search methods. Once you've had time to observe these samples, look into the Form1.cs file for more in-depth coverage of the code that is implemented. You will see that the indexing multi-threaded code occurs in the btnIndex_Click event. A new thread is started for each partition on a computer. This is a logical place to spawn new threads because no data sharing is required. The complexity and overall benefit of multi-threading is reduced if your threads must share data. You also see that the directories are recursively searched upon to return the specified data files in the traverseDirectory method. If you want to see the single-threaded code, you can access it in the btnIndexSingle_Click event. After indexing, you see that the search is multi-threaded when each table is accessed in the btnMultiSearch_Click event. Again, this is a logical place to spawn new threads because each thread is independent of one another and do not share any data. The single-threaded search is called in the btnSearch_Click event. You can access each of these events to compare which one returns the best performance. How to Extend this application: This application serves a base application that can be extended in many different areas. The premise of the indexing section uses multiple partitions. If there is only one partition on a volume, you could add multi-threading to the application by spawning threads searching for different file types. You can also add multiple threads to the application by performing a scan on the data files and then retrieving the data from the found files. When you search, you can spawn different threads to perform partial searches and combine the results. These are just a couple of examples of how this application can be used for your purposes. To see other resources related to this sample, click on the links below:

Preparing for Hyper-Threading and Dual Core Technologies

Intel Multi-Core Processor Architecture Development Backgrounder

Download this app from here.