Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

283 lines
9.8 KiB

4 years ago
  1. Microsoft Windows NT Working Set Tuner README File
  2. September 04, 1994
  3. 1. Description:
  4. ----------------
  5. Windows NT (32-bit) Working Set Tuner (WST) for x86, Mips,
  6. Alpha, and PowerPC platforms.
  7. The working set of a program is a collection of those pages in the
  8. program's virtual address space which have recently been referenced.
  9. As the working set size decreases, memory demand decreases. Since
  10. it is advantageous to minimize the memory demand, the working set
  11. tuner DLL is developed to measure code working set, and produce an
  12. ordering of the functions (procedures) within the code which will be
  13. small, if not minimal, in a paging environment. In any practical case
  14. there are probably many optimal assignments of functions to pages.
  15. Although this method does not claim optimality, it will produce results
  16. at least as good as a programmer could achieve by hand in a reasonable
  17. amount of time. This method consists of two parts:
  18. 1) Data Collection:
  19. Data is collected in C programs by using the attributed
  20. profiling hook provided by the Microsoft C compiler (compiling with the
  21. "-Gh" option). Data is not collected in assembler language programs.
  22. A hook routine in the working set tuner DLL, WST.DLL, is called before
  23. each C functions is called. The hook examines its environment to
  24. determine the identity of the called function. A bit is set in a
  25. bitmap every time a function is called within the specified time segment.
  26. A new bitmap is used (new snapshot) for each new time segment: smaller
  27. time segments will cause higher frequency of snapshots which will
  28. produce better working set (with some diminishing point of return...).
  29. The collected WST data is dumped upon the program's termination or via
  30. WST's dump facility called WstDump.exe. Functions' symbols in the
  31. program's symbol table are used by the WST.dll to match function names
  32. to bits in the bitmap.
  33. 2) Data Reduction:
  34. Two post-processing tools, WstCat.exe & WsTune.exe, were
  35. developed to process the collected data and produce an ordering of the
  36. functions (packing list) which, when placed into pages, will result
  37. in a smaller working set of pages in memory compared to its original
  38. working set size for the activity measured. The packing list, created
  39. using an ordering algorithm, can be used by the linker to perform the
  40. actual packing within the executable's object modules.
  41. 2. WST Files:
  42. --------------
  43. o wst.ini -- WST initialization file.
  44. o wst.dll -- WST DLL.
  45. o wst.lib -- WST library file containing WST entry point.
  46. o wstdump.exe -- Dump utility for dumping/clearing wst data, and
  47. stopping data collection at any time.
  48. o wstune.exe -- Data analysis utility for creating the packing list
  49. from collected data.
  50. o wstcat.exe -- Concatenation utility for multiple data files.
  51. o penter.lib -- An empty library containing a dummy WST entry point.
  52. This can be used instead of WST.lib to link with an
  53. executable object module which was compiled with the
  54. -Gh option, so the application can run without recompiling
  55. and without any of the WST overheads.
  56. 3. Using the Working Set Tuner Dll:
  57. ------------------------------------
  58. o Create the WST directory in the root directory of C: drive. (c:\wst)
  59. o Place WST.INI in the WST directory of C: drive and list all
  60. the DLL/EXE images to be tuned as follows:
  61. (Note: WST.INI and all its three section headers must exist but the
  62. sections could be left blank)
  63. [EXES]
  64. Name of applications to be tuned. Each name should be on a
  65. new line.
  66. [PATCH IMPORTS]
  67. List of DLLs/EXEs to be tuned for all of their imported entries.
  68. Each name should be on a new line.
  69. [TIME INTERVAL]
  70. Elapsed time in milliseconds between recording snapshots
  71. (if left blank default time interval of 1000 is used)
  72. o Sample WST.INI file:
  73. [EXES]
  74. myapp.exe
  75. [PATCH IMPORTS]
  76. [TIME INTERVAL]
  77. 1500
  78. o Attach WST.DLL to the application process:
  79. - Recompile your EXE/DLL using the "-Gh" and "-Zd" compiler
  80. options. (NOTE - on Mips platform, use "-Od" to disable
  81. compiler optimization.)
  82. - Link it with WST.LIB using the "-debugtype:coff" and
  83. "-debug:mapped,partial" linker options.
  84. - This method will cause all the C functions in the recompiled
  85. sources to be accessible to WST.DLL.
  86. NOTE:- The win32.mak file in the Win32 SDK will set these
  87. options correctly for your application if you build it with
  88. the tune=1 switch. I.e. "nmake -all tune=1".
  89. NOTE:- If symbols have been removed from your exe
  90. or dll, Wst will try to locate the symbols files (DBG
  91. files) using the path as specified in the environment
  92. variable "_nt_symbol_path".
  93. E.G. if the DBG file of your exe is in c:\symbols\exe, set
  94. _nt_symbol_path to c:\symbols.
  95. o Place WST.DLL in your SYSTEM directory (i.e. ..\nt\system32).
  96. o If this is the only run that is to be considered for tuning, clear
  97. any existing .TMI and .WSP files in C:\WST directory.
  98. o Run your applications.
  99. o Data will be collected for all the applications specified in the
  100. [EXES] section of the WST.INI.
  101. o Exit the application to dump the WST data, or run WstDump.exe
  102. to dump the data. See section 4 "WST Data" for details.
  103. o If you have multiple TMI & WSP files, run WstCat.exe to concatenate
  104. data from multiple runs. See section 5 "Using WstCat" for details.
  105. o Run WsTune.exe to generate the packing list (.prf file) based on
  106. the collected WST data. See section 6 "Using WsTune" for details.
  107. o Use the packing list to direct the linker to order the modules
  108. as specified in the packing list (.prf file). See section 8
  109. "Linking with the Packing List" for details.
  110. 4. WST Data:
  111. -------------
  112. o WST data can be captured in two ways:
  113. 1) Upon termination of the application WST data is dumped
  114. automatically.
  115. 2) Using the dump utility, WstDump.exe, WST data can be dumped
  116. at any time. See section 7 "Using WstDump" for details.
  117. o Data files are created in C:\WST directory.
  118. o WST data is dumped into data files using the application and its
  119. DLLs names with .TMI & .WSP extensions.
  120. o If TMI & WSP files exist in the c:\wst directory, new data files
  121. with .T?? and .W?? are created where ?? is a number between
  122. 0x01-0xff. The number indicates the run number. All the data
  123. files can be concatenated (using WstCat.exe) to generate a single
  124. packing list from the multiple run data files.
  125. 5. Using WstCat:
  126. -----------------
  127. o WstCat.exe can be used to concatenate multiple .WSP and .TMI files
  128. (multiple files will be named *.T00 - *.Tff and *.W00 - *.Wff)
  129. into a single file for analysis. This allows the user to run
  130. multiple scenarios, over time, and analyze them as a single run.
  131. WST will also create multiple files if a scenario exceeds its 3200
  132. snapshots limit.
  133. Usage: WstCat modulename
  134. modulename is the name of the DLL or EXE which is being
  135. tuned and data has been collected for.
  136. Note: The original TMI & WSP files will be renamed to TXX & WXX
  137. by WstCat.
  138. 6. Using WsTune:
  139. -----------------
  140. o WsTune.exe is used to analyze the data created by WST. WsTune
  141. will also create the packing list, .PRF file, which is used by
  142. the linker to pack your DLL or EXE.
  143. o The DATA files created by wstune are:
  144. - .DT (Data Tuned) contains the analysis data/bitstrings for
  145. all api's called in the "packing list" order.
  146. - .DN (Data Not tuned) contains the api's called in
  147. the "unpacked" order.
  148. - .PRF contains the packing list to be used by the linker.
  149. - .WSR is a worker index file created for internal use.
  150. Usage: WsTune [/O] [/D] [/N] [?] ModuleName.WSP
  151. /O Dump data to file (*.DT tuned & *.DN not tuned).
  152. /D Dump analysis data only (don't dump bitstrings data).
  153. /N Just analyze bitstring data, don't dump any data.
  154. /? Causes the usage message to be displayed.
  155. 7. Using WstDump:
  156. ------------------
  157. o WstDump.exe can be used to stop WST data collection and clear/dump
  158. WST collected data for all the applications being tuned, at any time.
  159. o The following options are available via WstDump.exe:
  160. - Stop : Stops WST data collection (applications continue to run).
  161. - Clear and Restart : Clears any existing WST data and
  162. restarts data collection.
  163. - Dump and Stop : Dumps any existing WST data and stops the
  164. data collection (applications continue to run).
  165. o Data is dumped to C:\WST using the application and its DLLs names
  166. with .TMI & .WSP extensions.
  167. o If TMI & WSP files exist in the C:\WST directory, new data files
  168. with .T?? and .W?? are created where ?? is a number between
  169. 0x01-0xff. The number indicates the run number. All the data
  170. files can be concatenated (using WstCat.exe) to generate a single
  171. packing list from the multiple run data files.
  172. 8. Linking with the Packing List:
  173. ----------------------------------
  174. o Recompile your applications using the Microsoft C Compiler "-Gy"
  175. option. (Remove the "-Gh" option to avoid extra overhead.)
  176. o Relink your applications using the link "-order:@filename" option
  177. where filename is the name of your packing list (i.e. .prf file
  178. generated by WsTune.exe).
  179. 9. Caveats:
  180. ------------
  181. o If symbols are not available in an EXE/DLL that is being tuned,
  182. ??? is displayed as the function name in data and analysis files
  183. (??? is not listed in the packing list, however.)
  184. o WST data is *NOT* collected for functions in assembler language
  185. programs/objects.
  186. ** END OF README **