summaryrefslogtreecommitdiffstats
path: root/private/sdktools/wst/readme
blob: 85832871a4cab38584ce7106fde493169cfdd211 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283


		Microsoft Windows NT Working Set Tuner README File

                       September 04, 1994



1.  Description:
----------------

	Windows NT (32-bit) Working Set Tuner (WST) for x86, Mips,
        Alpha, and PowerPC platforms.

	The working set of a program is a collection of those pages in the
	program's virtual address space which have recently been referenced.
	As the working set size decreases, memory demand decreases.  Since
	it is advantageous to minimize the memory demand, the working set
	tuner DLL is developed to measure code working set, and produce an
	ordering of the functions (procedures) within the code which will be
	small, if not minimal, in a paging environment.  In any practical case
	there are probably many optimal assignments of functions to pages.
	Although this method does not claim optimality, it will produce results
	at least as good as a programmer could achieve by hand in a reasonable
	amount of time.  This method consists of two parts:

	1)  Data Collection:

		Data is collected in C programs by using the attributed
	profiling hook provided by the Microsoft C compiler (compiling with the
	"-Gh" option).  Data is not collected in assembler language programs.
	A hook routine in the working set tuner DLL, WST.DLL, is called before
	each C functions is called.  The hook examines its environment to
	determine the identity of the called function.  A bit is set in a
	bitmap every time a function is called within the specified time segment.
	A new bitmap is used (new snapshot) for each new time segment: smaller
	time segments will cause higher frequency of snapshots which will
	produce better working set (with some diminishing point of return...).
	The collected WST data is dumped upon the program's termination or via
	WST's dump facility called WstDump.exe.  Functions' symbols in the
	program's symbol table are used by the WST.dll to match function names
	to bits in the bitmap.

	2)  Data Reduction:

		Two post-processing tools, WstCat.exe & WsTune.exe, were
	developed to process the collected data and produce an ordering of the
	functions (packing list) which, when placed into pages, will result
	in a smaller working set of pages in memory compared to its original
	working set size for the activity measured.  The packing list, created
	using an ordering algorithm, can be used by the linker to perform the
	actual packing within the executable's object modules.



2.  WST Files:
--------------

	o  wst.ini	 -- WST initialization file.
	o  wst.dll	 -- WST DLL.
	o  wst.lib	 -- WST library file containing WST entry point.
	o  wstdump.exe	 -- Dump utility for dumping/clearing wst data, and
			    stopping data collection at any time.
	o  wstune.exe	 -- Data analysis utility for creating the packing list
			    from collected data.
	o  wstcat.exe	 -- Concatenation utility for multiple data files.
	o  penter.lib    -- An empty library containing a dummy WST entry point.
	                    This can be used instead of WST.lib to link with an
			    executable object module which was compiled with the
			    -Gh option, so the application can run without recompiling
                            and without any of the WST overheads.



3.  Using the Working Set Tuner Dll:
------------------------------------

	o  Create the WST directory in the root directory of C: drive. (c:\wst)

	o  Place WST.INI in the WST directory of C: drive and list all
	   the DLL/EXE images to be tuned as follows:

	   (Note:  WST.INI and all its three section headers must exist but the
	    sections could be left blank)

	   [EXES]
	   Name of applications to be tuned. Each name should be on a
	   new line.

	   [PATCH IMPORTS]
           List of DLLs/EXEs to be tuned for all of their imported entries.
           Each name should be on a new line.

	   [TIME INTERVAL]
	   Elapsed time in milliseconds between recording snapshots
	   (if left blank default time interval of 1000 is used)

	o  Sample WST.INI file:

	   [EXES]
	   myapp.exe

	   [PATCH IMPORTS]

	   [TIME INTERVAL]
	   1500

	o  Attach WST.DLL to the application process:

	   -  Recompile your EXE/DLL using the "-Gh" and "-Zd" compiler
	      options.  (NOTE - on Mips platform, use "-Od" to disable
              compiler optimization.)


	   -  Link it with WST.LIB using the "-debugtype:coff" and
	      "-debug:mapped,partial" linker options.

	   -  This method will cause all the C functions in the recompiled
	      sources to be accessible to WST.DLL.

           NOTE:-  The win32.mak file in the Win32 SDK will set these
           options correctly for your application if you build it with
           the tune=1 switch.  I.e.  "nmake -all tune=1".

           NOTE:-  If symbols have been removed from your exe
           or dll, Wst will try to locate the symbols files (DBG
           files) using the path as specified in the environment
           variable "_nt_symbol_path".
           E.G. if the DBG file of your exe is in c:\symbols\exe, set
           _nt_symbol_path to c:\symbols.

	o  Place WST.DLL in your SYSTEM directory (i.e. ..\nt\system32).

	o  If this is the only run that is to be considered for tuning, clear
	   any existing .TMI and .WSP files in C:\WST directory.

	o  Run your applications.

	o  Data will be collected for all the applications specified in the
	   [EXES] section of the WST.INI.

	o  Exit the application to dump the WST data, or run WstDump.exe
	   to dump the data.  See section 4 "WST Data" for details.

	o  If you have multiple TMI & WSP files, run WstCat.exe to concatenate
	   data from multiple runs.  See section 5 "Using WstCat" for details.

	o  Run WsTune.exe to generate the packing list (.prf file) based on
	   the collected WST data.  See section 6 "Using WsTune" for details.

	o  Use the packing list to direct the linker to order the modules
	   as specified in the packing list (.prf file).  See section 8
	   "Linking with the Packing List" for details.



4.  WST Data:
-------------

	o  WST data can be captured in two ways:

	   1)  Upon termination of the application WST data is dumped
	       automatically.

	   2)  Using the dump utility, WstDump.exe, WST data can be dumped
	       at any time.  See section 7 "Using WstDump" for details.


	o  Data files are created in C:\WST directory.

	o  WST data is dumped into data files using the application and its
	   DLLs names with .TMI & .WSP extensions.

	o  If TMI & WSP files exist in the c:\wst directory, new data files
           with .T?? and .W?? are created where ?? is a number between
           0x01-0xff.  The number indicates the run number.  All the data
           files can be concatenated (using WstCat.exe) to generate a single
           packing list from the multiple run data files.



5.  Using WstCat:
-----------------

	o  WstCat.exe can be used to concatenate multiple .WSP and .TMI files
	   (multiple files will be named *.T00 - *.Tff and *.W00 - *.Wff)
	   into a single file for analysis.  This allows the user to run
	   multiple scenarios, over time, and analyze them as a single run.
	   WST will also create multiple files if a scenario exceeds its 3200
	   snapshots limit.

	   Usage:  WstCat modulename

     		   modulename is the name of the DLL or EXE which is being
		   tuned and data has been collected for.

	   Note:  The original TMI & WSP files will be renamed to TXX & WXX
	          by WstCat.



6.  Using WsTune:
-----------------

	o  WsTune.exe is used to analyze the data created by WST.  WsTune
	   will also create the packing list, .PRF file, which is used by
	   the linker to pack your DLL or EXE.

	o  The DATA files created by wstune are:

	        -  .DT (Data Tuned) contains the analysis data/bitstrings for
		   all api's called in the "packing list" order.

		-  .DN (Data Not tuned) contains the api's called in
		   the "unpacked" order.

		-  .PRF contains the packing list to be used by the linker.

		-  .WSR is a worker index file created for internal use.
		

	   Usage:  WsTune [/O] [/D] [/N] [?] ModuleName.WSP

		   /O   Dump data to file (*.DT tuned & *.DN not tuned).
		   /D   Dump analysis data only (don't dump bitstrings data).
		   /N   Just analyze bitstring data, don't dump any data.
		   /?   Causes the usage message to be displayed.



7.  Using WstDump:
------------------

	o  WstDump.exe can be used to stop WST data collection and clear/dump
	   WST collected data for all the applications being tuned, at any time.

	o  The following options are available via WstDump.exe:

	      - Stop : Stops WST data collection (applications continue to run).

	      - Clear and Restart : Clears any existing WST data and
				    restarts data collection.

	      - Dump and Stop : Dumps any existing WST data and stops the
				data collection (applications continue to run).

	o  Data is dumped to C:\WST using the application and its DLLs names
           with .TMI & .WSP extensions.

	o  If TMI & WSP files exist in the C:\WST directory, new data files
           with .T?? and .W?? are created where ?? is a number between
           0x01-0xff.  The number indicates the run number.  All the data
           files can be concatenated (using WstCat.exe) to generate a single
           packing list from the multiple run data files.




8.  Linking with the Packing List:
----------------------------------

	o  Recompile your applications using the Microsoft C Compiler "-Gy"
	   option.  (Remove the "-Gh" option to avoid extra overhead.)

	o  Relink your applications using the link "-order:@filename" option
	   where filename is the name of your packing list (i.e. .prf file
	   generated by WsTune.exe).



9.  Caveats:
------------

	o  If symbols are not available in an EXE/DLL that is being tuned,
	   ??? is displayed as the function name in data and analysis files
	   (??? is not listed in the packing list, however.)

	o  WST data is *NOT* collected for functions in assembler language
	   programs/objects.



** END OF README **