Performance Tuning
Performance Tuning
Depending on the size of your project, you may want to tune Source Insight for better performance. The Preferences dialog box, and the Project Settings dialog box both contain options that affect performance.
Factors That Affect Performance
Source Insight was designed to push some of the limits of functionality for a programming editor. As such, it has features that can stress a system that is too slow or not optimized for it. This section describes factors that you can control which affect Source Insight's performance.
Project Size
The size of a project has a large effect on the performance of certain features in Source Insight. The project size can be measured in number of files, and in number of declared symbols.
Tip:
Use Project Report to see project size statistics.
To find out how large your project is, use the Project > Project Report command and note the top lines of the report. At the top of the project report, Source Insight prints the number of files, the number of symbols, and the number of symbol index entries in the project. You can also see these same statistics in the Project >
Rebuild Project
dialog box at the bottom of the dialog box. (You do not have to rebuild the project to see the statistics.)
Project Index Settings
The Project Settings dialog box contains options for indexing your project. If you enable all the indexing options, and your project is large, you may hurt performance.
The symptoms of too large an index are:
•
Disk thrashing while building or rebuilding a large project, with little progress is being made. It is normal for a very large project to require a significant amount of disk access near the end of the rebuilding phase.
•
Opening or closing a project takes a long time.
•
Synchronizing individual files is slow.
•
The Project Symbol List window (F7) is slow to come up, accompanied by a lot of disk activity. It is normal for this to pause a second or two the first time you use it.
Tip:
Name Fragment indexing a large project can be slow and memory intensive
If you have a large project (over 500,000 symbols) you should try turning off the symbol name fragment indexing. You can find out how large the database is by selecting Project > Rebuild Project and looking at the statistics on the bottom of the dialog box. Just cancel this dialog box when you are done. If the number of index entries is over 1 million, then things can start to slow down. Adding more memory to your machine will improve performance.
To remove the name fragment indexing, run the Project > Project Settings command and turn off Quick browsing for symbol name fragments. Then use the Rebuild Project command to recreate your project from scratch.
Memory Usage
Source Insight very efficient in its memory use. However, Source Insight uses virtual memory in proportion to the size of your project. If your projects are large, Source Insight will require more virtual memory. Large projects can use a lot of virtual memory.
142 Source Insight 4 User Guide
Performance Tuning
Source Insight makes heavy use of memory-mapped files. This is a operating system feature whereby files can be mapped into virtual address space, so that a file looks like a block of memory to a program. Source
Insight uses memory-mapped files to provide the fastest possible access to source files and database files.
Source Insight uses an efficient way of mapping large project databases and indexes into virtual memory.
The size of a project database is proportional to the number of declared symbols in the project. Therefore, if your project is very large, the amount of memory used by Source Insight as reported by Task Manager (the
Working Set) can be several hundred megabytes. However, most of the memory represents portions of the symbol database mapped into virtual memory space. Source Insight does not require this much physical memory.
Custom Parsing Expressions
You can augment a language with your own custom parsing regular expressions. You can edit these expressions by right clicking on a source file and selecting Language Properties.
Be careful with the custom parsing expressions you define. If you have too many expressions, or you are using a regular expression that is inherently slow to match, you may notice that it takes a moment or two to parse your files.
A regular expression can be slow to match if it starts with a pattern that is easily matched, but ends with a pattern that often does not match. For example:
[a-z]*(\([a-z]+\))
This expression will be slow to match because the pattern starts with [a-z]*, which means, "match any zero or more alphabetic characters". Most characters in a file will potentially match, cause the pattern matcher to try and fail to match many times.
Location of Files on a Network
While it is possible to add source files to your project from a remote network drive, that can cause Source
Insight to slow down because access to network drives is slower in general.
In addition, locating the project data folder on a network drive can also result is poor performance. We recommend locating the Project Data Directory on your local, non-networked drive.
Location of the "Documents" Folder
In Windows, the "Documents" folder is a virtual folder that can exist either locally, or on a remote network drive. Since Source Insight stores per-user data inside that folder, some operations can become slow if you locate this folder on a remote drive. In particular, if you used the Import External Symbols feature, the resulting import project symbols are stored in the
Documents\Source Insight 4.0\Projects
folder. Therefore auto-completion while typing can become slow.
If possible, locate your "Documents" folder on your local drive. If you cannot do that, then you can set a registry entry to force Source Insight to use a local drive for the per-user data folder.
In regedit.exe, find the key:
HKEY_CURRENT_USER\Software\Source Dynamics\Source Insight\4.0\Paths
Add a new string value named "UserDataDir". Set the string value to the full path of the folder you want to user for per-user data.
Speeding Up Program Features
This section contains recommendations for speeding up different aspects of Source Insight.
Speeding Up Syntax Formatting
Source Insight has many interesting and useful display features for formatting source code. Some of those features require a significant amount of processing.
Source Insight 4 User Guide 143
Performance Tuning
The display code has been sped up considerably to be able to provide more features with acceptable performance. It is possible to reduce the display functionality to speed it up.
The Preferences: Syntax Formatting dialog box lets you specify how detailed you want the display. Each option has a performance cost. The significant options are listed here, starting with the least costly, to the slowest and most costly:
1.
Apply styles for references to members
2.
3.
4.
5.
6.
7.
Apply styles for symbol declarations
Apply styles for local symbol declarations
Apply styles for references to function-local symbols
Apply styles for non-function-local symbols
Find references using the Project Symbol Path
Qualify member references
Formatting "references" is slower than "declarations".
In general, identifying "references" is slower than "declarations". Identifying references to symbols can be slower if the project is very large, because each reference has to be resolved with a symbol lookup.
The symbol lookup engine has been heavily optimized to allow formatting references to symbols at "display speed". A lot of information is cached in the process, so you may notice that the first time you open a file and start scrolling around in it, it may slow down sometimes. Subsequent viewing of the file will speed up.
Some people want the fastest possible display. However, you may be willing to sacrifice a little of that speed in turn for more useful information that increases productivity.
Speeding Up Typing in Browse Dialog Boxes
Typing and filtering symbol lists can become slow if you have a large project, and you have the Project Set-
tings: Quick browsing for symbol name fragments
turned on. Source Insight is trying to perform name fragment matching on a large name fragment index.
You can address this two different ways. Either you can turn off name fragment indexing in the Project Settings dialog box, or you can change the behavior of the list filtering with the Preferences: Typing dialog box.
The Project Settings options control what is stored and indexed in the symbol database.
The Preferences: Typing options control how the information is used in the lists. You do need the name fragment information in the database to use the symbol name fragment matching features of the lists. (But, not for file name lists.)
If memory permits, leave Project Settings: Quick browsing for symbol name fragments enabled, and turn off
Preferences: Typing: Match name fragments while typing
. Even with name fragment matching while typing disabled, you can still use it by prefixing what you type with a space. That is, prefixing what you type with a space toggles the name fragment matching on and off.
If you encounter a lot of disk thrashing while trying to match any name fragments in lists, then your project may be just too big for the available memory.
In Preferences: Typing, turning off both "Match name fragments" and "Match members" will speed it up more and return list filtering to version 2.1 functionality.
144 Source Insight 4 User Guide
Performance Tuning
Speeding Up Building and Synchronizing Projects
A very large project will take a while to build or rebuild. To speed it up, you can try the following:
•
In Project Settings, turn off Quick browsing for symbol name fragments. This index option uses a lot of memory and slows the indexing process.
•
In Project Settings, turn off Quick browsing for member names. This index option can use a lot of memory also.
•
Reduce the number of file types that are added to your projects. By default, Source Insight comes with many file types defined, such as Visual Basic files, and ASP files. If you have files like that in your source tree, but you have no need to work on them, then remove them from your project. You can permanently exclude those file types from your projects by selecting Options > File Type Options and unchecking the option Include when adding to projects – for each type of file you want to exclude from your projects.
•
Break your project into smaller projects. If you want to still use the Jump To Definition command between the projects, you can add the "sub-projects" to the project symbol path, which is defined in the Preferences: Symbol Lookups dialog box.
Speeding Up Relation Windows
The Relation Window shows relationships between symbols. It works like the Context Window in that it works in the background and automatically shows information about what is selected. For example, if you select a function call, it can show you the call tree starting at that function.
The Relation Window can require a lot of processing. Some relationships are slower to compute. The relationships fall into three categories, listed here from fastest to slowest:
•
Contains
– show the contents of the current symbol. For example, show members of a struct.
•
Calls
– show what other symbols are referred to by the current symbol. For example, show functions that are called by the current function.
•
References
– show what other symbols refer to the current symbol. For example, show functions that call the current function.
It Takes More Work to Show References
For very large projects, the "References" relationship will be by far the slowest to compute. The performance seems very acceptable on a Pentium II machine with a moderate sized project (about 200,000 lines of code).
Limiting the relations to non-reference type relations will speed the Relation Window up.
It also works well to lock the Relation Window. To lock the Relation Window, click on the lock button in the
Relation Window toolbar. You can refresh the Relation Window at any time by using the Refresh Relation Window command, or by clicking on the Refresh button in the Relation Window toolbar.
Speeding Up Auto-Completion
As you type an identifier, the auto-completion window pops up to propose matching identifier names. Every time you type a character, Source Insight considers the symbol data for that file to be "stale". To give you the most accurate auto-completion results, Source Insight would need to reparse your file after each character you type. There is an option that controls this in the Preferences: Symbol Lookups dialog box.
The Parse locally before lookup option causes Source Insight to reparse before the auto-completion window appears. On a fast machine, or in a small file, the speed will be acceptable. However, turning this option off will result in a faster response.
Speeding Up Searching Files
Use Lookup References instead of Search Files.
There are several ways to search across multiple files in Source Insight. The commands: Search Files, Lookup
References
, and Search Project all perform multi-file searches.
Source Insight 4 User Guide 145
Performance Tuning
The fastest type of search in Source Insight is the Lookup References search. When you search this way,
Source Insight looks for references to a single whole-word item. When you search for a single whole-word,
Source Insight uses a special index file to make the search fast. It's a good idea to get into the habit of using
Lookup References
, instead of Search Files, when you can.
Speeding Up Lookup References
The Lookup References command has a few options that affect its speed.
The Smart Reference Matching option means that the search is scope and context-sensitive; the search results will only contain matches for references to the exact symbol you specify, using the surrounding context. This option slows the process down because each same-string occurrence has to be qualified with a symbol lookup, which requires some parsing on the fly. If you turn this off, it will work like the Search Files command; that is, it will search for the string across all the project files.
The Skip Comments and Search Only Comments options also slow the search down a little, but not as much as the smart reference matching option.
146 Source Insight 4 User Guide