Leaked source code of windows server 2003
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.

267 lines
11 KiB

  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  2. <html>
  3. <head>
  4. <title>What's new in this release of LKRhash?</title>
  5. <link rel=Stylesheet type="text/css" media=all href="./docs/lkr.css">
  6. </head>
  7. <body>
  8. <h1>What's new in this release of LKRhash?</h1>
  9. <ul>
  10. <li> <a href="#dec2000"> December 2000</a></li>
  11. <li> <a href="#2000-07-31"> 2000/07/31</a></li>
  12. <li> <a href="#2000-04-24"> 2000/04/24</a></li>
  13. <li> <a href="#2000-03-22"> 2000/03/22</a></li>
  14. <li> <a href="#1999-11-04"> 1999/11/04</a></li>
  15. </ul>
  16. <a name="dec2000">
  17. <h2>December 2000</h2>
  18. </a>
  19. <ul>
  20. <li> Refactored the code.</li>
  21. <li> Public API.</li>
  22. <li> C API.</li>
  23. <li> Kernel-mode support.</li>
  24. <li> Fixed a deadlock bug in the table lock. If you explicitly
  25. call <code>Table::ReadLock</code> and
  26. <code>Table::WriteLock</code>, you <strong>need</strong> this fix,
  27. or you will deadlock under stress.</li>
  28. <li> Fixed a bug in table compaction: until now, the table
  29. never actually compacted after elements were deleted, as
  30. the test for compaction always evaluated to `false'.</li>
  31. <li> Changed the name of <code>EqualKeys</code> to
  32. <code>CompareKeys</code>, which now returns an
  33. <code>int</code> instead of a <code>bool</code>. This is
  34. needed for multikeys support.
  35. <li> Changed the signature of <code>AddRefRecord</code>. The
  36. second parameter is now an <code>LK_ADDREF_REASON</code>,
  37. instead of an <code>int</code> whose value is
  38. <code>+1</code>&nbsp;or&nbsp;<code>-1</code>. The reason code
  39. aids in debugging refcount leaks. If its value is negative, the
  40. refcount should be decremented; otherwise the refcount
  41. should be incremented. Also, <code>AddRefRecord</code>
  42. now returns <code>LONG</code> instead of
  43. <code>void</code>: the new value of the reference count.</li>
  44. <li> Changed behavior of <code>ApplyIf</code> locking: now
  45. locks one subtable at a time, instead of all
  46. subtables. Can use <code>Table::ReadLock</code> or
  47. <code>Table::WriteLock</code> to retain old behavior.</li>
  48. <li> Changed names and signatures of
  49. <code>void LKRHashTableInit()</code> and
  50. <code>void LKRHashTableUninit()</code>, to
  51. <code>BOOL LKR_Initialize(DWORD)</code> and
  52. <code>void LKR_Terminate()</code>, respectively.</li>
  53. <li> Fixed <code>iterator::operator*()</code> and
  54. <code>iterator::operator->()</code>.</li>
  55. </ul>
  56. <a name="2000-07-31">
  57. <h2>2000/07/31</h2>
  58. </a>
  59. <ul>
  60. <li> <strong>Really</strong> fixed the bug in <code>Clear</code> that left
  61. certain internal state variables in an inconsistent state. If
  62. you later inserted/deleted enough new records, LKRhash would
  63. AV. (The fix in the 2000/03/22 release did not work in all
  64. cases.)</li>
  65. </ul>
  66. <a name="2000-04-24">
  67. <h2>2000/04/24</h2>
  68. </a>
  69. <ul>
  70. <li> I added support for STL-style iterators
  71. <ul>
  72. <li> New iterators <strong>do not lock</strong> the table or
  73. a bucket chain. In a multithreaded situation, it is
  74. <strong>your</strong> responsibility to call
  75. <code>WriteLock</code> (or <code>ReadLock</code>) on the
  76. table before initializing any iterators, and to call
  77. <code>WriteUnlock</code> (or <code>ReadUnlock</code>)
  78. when you are finished.</li>
  79. <li> The table provides <code>begin()</code> and
  80. <code>end()</code> methods. As the compiler isn't quite
  81. smart enough to realize that <code>end()</code> always
  82. returns a trivial empty iterator, a loop such as
  83. <pre>
  84. MyTable::iterator iter;
  85. for (iter = pTbl->begin(); iter != pTbl->end(); ++iter) ...
  86. </pre>
  87. is more efficiently expressed as
  88. <pre>
  89. MyTable::iterator iter;
  90. MyTable::iterator iterEnd = pTbl->end();
  91. for (iter = pTbl->begin(); iter != iterEnd; ++iter) ...
  92. </pre></li>
  93. <li> iterators can be pre- and post-incremented; i.e.:
  94. <code>++iter</code> and <code>iter++</code>.
  95. Pre-increment is more efficient than post-increment.</li>
  96. <li> Table provides a constructor that accepts a range of
  97. iterators into another container.</li>
  98. <li> Provides an <code>Insert</code> method that returns an iterator,
  99. pointing to the newly inserted record, or <code>end()</code> on
  100. failure.</li>
  101. <li> Provides a <code>Find</code> method that returns an iterator
  102. pointing to the record with the passed-in key, or
  103. <code>end()</code> on failure.</li>
  104. <li> Provides an <code>EqualRange</code> method that returns
  105. two iterators describing the range that contain all the
  106. records whose keys match the passed-in key. Until full
  107. support for multiple, identical keys is added, the range
  108. will contain either zero or one record(s).</li>
  109. <li> Provides an <code>Erase</code> method that deletes the
  110. record pointed to by the iterator. Updates the iterator to
  111. point to the next record in the table.</li>
  112. <li> Provides an <code>Erase</code> method that takes two
  113. iterators, which will delete all the records in the range
  114. described by the two iterators.</li>
  115. <li> Unlike the old, deprecated iterators (<code>CIterator</code>),
  116. more than one iterator can be active at a time. It is
  117. best not to call the non-iterator insert/delete methods
  118. (<code>InsertRecord</code>, <code>DeleteRecord</code>,
  119. <code>DeleteKey</code>) while iterators are open, as the
  120. non-iterator methods can rebalance bucket chains,
  121. leading to invalid iterators, undercounting, and/or
  122. overcounting. This is true even if the table was
  123. WriteLocked, before the iterators were initialized. It
  124. is best to use the iterator <code>Insert</code> or
  125. <code>Erase</code> methods in such a case.</li>
  126. <li> The iterators are reference-counted.</li>
  127. </ul>
  128. </li>
  129. <li> I have provided an NTSD/CDB debugger extension, <i>lkrdbg.dll</i>,
  130. with one method, <code>!lkrdbg.lkrhash</code>:
  131. <ul>
  132. <li> <code>!lkrhash -l[0-2] <i>addr</i></code> will dump the
  133. hashtable at <code><i>addr</i></code> at verbosity level
  134. <code>l</code> (default 0).</li>
  135. <li> <code>!lkrhash -g[0-2]</code> will dump ALL hashtables
  136. at at verbosity level <code>l</code> (default 0).</li>
  137. <li> I have provided an easy-to-use customization mechanism in
  138. <i>lkrcust.h</i> to provide custom dumps for different
  139. hashtables. It's keyed off the <code>pszName</code> parameter
  140. used in the hashtable constructor. You can provide a custom dump
  141. routine for the table (to dump whatever other fields you
  142. might have added), as well as a custom dump routine for
  143. the record class stored by the hashtable. Provided three
  144. examples of customization, based on the samples.</li>
  145. </ul>
  146. </li>
  147. <li> Fixed various build issues
  148. <ul>
  149. <li> All debug code is now bracketed with <code>#ifdef
  150. IRTLDEBUG</code> (instead of <code>#ifdef _DEBUG</code>).
  151. Currently equivalent, but you can control this in
  152. <i>irtldbg.h</i></li>
  153. <li> Fix all Unicode build issues. Code is now TCHAR-aware.</li>
  154. <li> Added <i>lkrhash.rc</i> to provide a version resource</li>
  155. </ul>
  156. </li>
  157. <li> Turned on <code>LKRhash</code> and <code>HashFn</code>
  158. namespaces by default. See <i>readme.txt</i>.</li>
  159. <li> Reorganized the samples into their own subtree.</li>
  160. <li> Removed more old code that used to be present so that I could
  161. test some changes (e.g., stuff bracketed by
  162. <code>LKR_OLD_SEGMENT</code>, <code>LKR_SIGS_NODES</code>,
  163. etc).</li>
  164. <li> Bucket Lock is once again <code>CSmallSpinLock</code>, unless
  165. <code>LKR_DEPRECATED_ITERATORS</code> is defined (off by
  166. default).</li>
  167. <li> Moved a lot of nested classes out of the table classes, to be
  168. top-level classes.</li>
  169. <li> Better compile-time and run-time assertions.</li>
  170. </ul>
  171. <a name="2000-03-22">
  172. <h2>2000/03/22</h2>
  173. </a>
  174. <ul>
  175. <li> Fixed a bug in <code>Clear</code> that left certain
  176. internal state variables in an inconsistent state. If you
  177. later inserted/deleted enough new records, LKRhash would AV.</li>
  178. <li> Changed <code>BucketLock</code> to <code>CReaderWriterLock3</code>
  179. (recursive MRSW lock) to support certain scenarios, such as
  180. being able to call <code>FindKey</code> while enumerating
  181. with an old-style iterator. Slightly slower, but the speed
  182. improvements below more than compensate.</li>
  183. <li> Removed the 300-line example from the end of lkrhash.h. Now in
  184. hashtest.cpp, bracketed by <code>SAMPLE_LKRHASH_TESTCLASS</code>.</li>
  185. <li> Replaced <code>TRACE</code> macro with
  186. <code>IRTLTRACE</code> so as not to interfere with other
  187. <code>TRACE</code> macros (e.g., MFC's).</li>
  188. <li> Added <i>dirs</i> and <i>sources</i> files so that you
  189. can build LKRhash with the NT build environment.</li>
  190. <li> Added <code>STATIC_ASSERT</code> macro for compile-time
  191. assertions. The <code>IRTLASSERT</code> macro is still used
  192. for run-time assertions.</li>
  193. <li> Removed old code that used to be present so that I could test
  194. some changes (e.g., stuff bracketed by
  195. <code>LKR_NEWCODE</code>, <code>LKR_MASK</code>,
  196. <code>LKR_SUBTABLE</code>,
  197. <code>LKR_COMPACT_DELETE</code>, etc).</li>
  198. <li> Upped <code>LK_DFLT_MAXLOAD</code> to 6
  199. (<code>NODES_PER_CLUMP</code>) to get better memory usage.</li>
  200. <li> Added support for RockAll (not enabled by default)</li></li>
  201. <li> Turned <code>CSegment</code> into a concrete base
  202. class. Somewhat hacky but faster.</li>
  203. <li> Made the locks a little faster, esp.
  204. <code>CReaderWriterLock3::IsWriteLocked</code>.</li>
  205. <li> Experimented with countdown loops (turned out to be slightly
  206. slower).</li>
  207. <li> Experimented with bitwise scrambling for subtable index
  208. calculation. Faster.</li>
  209. <li> Experimented with using a bitwise mask for subtable index
  210. calculation. Faster.</li>
  211. <li> Removed some inlines from <i>lkrhash.h</i> to improve modularity.</li>
  212. <li> Removed unimplemented <code>Print</code> methods.</li>
  213. <li> Bracketed global lists of hashtables with
  214. <code>LKR_NO_GLOBAL_LIST</code>.</li>
  215. <li> Reduced number of subtables to min(1, #CPUs) for
  216. <code>LK_SMALL_TABLESIZE</code> Was min(2, #CPUs). Max number
  217. of subtables is now 64.</li>
  218. </ul>
  219. <a name="1999-11-04">
  220. <h2>1999/11/04</h2>
  221. </a>
  222. <ul>
  223. <li> New reader-writer locks.</li>
  224. <li> Smarter, faster simple spinlocks.</li>
  225. <li> compact delete.</li>
  226. <li> debugging support.</li>
  227. <li> increased default load factor from 4.0 to 5.0 after
  228. reducing size of spinlock =&gt; reduced memory usage.</li>
  229. <li> deprecated CIterator.</li>
  230. <li> better error checking.</li>
  231. <li> Win64 clean.</li>
  232. <li> expose table locks => composition of operations.</li>
  233. <li> global list.</li>
  234. <li> faster hash scrambling function..</li>
  235. <li> won't fail messily in low-memory situations.</li>
  236. <li> fixed a race condition in some of the assertions.</li>
  237. <li> enhanced test program.</li>
  238. </ul>
  239. <hr>
  240. <address></address>
  241. <!-- hhmts start -->
  242. Last modified: Sat Nov 25 20:41:23 2000
  243. <!-- hhmts end -->
  244. </body>
  245. </html>