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
|
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
|
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
-
-
+
+
+
+
|
struct, and that might have some performance benefit.
It is possible to still have evolution with open struct definitions, but it
requires significant effort to maintain all the necessary compatibilities.
The <b>Tcl_HashKeyType</b> struct possesses the first enabler of such
a scheme -- a version field, but there's been either no need or no ability
to revise that struct. In contrast, the <b>Tcl_HashEntry</b> struct
has effectively had its bucketPtr field replaced by a hash field and without
a version field in place, the illusion that we still support callers who want
to keep using the bucketPtr field is something of a cruel joke. The Tcl
library (and the tclHash.c file) gets built with <b>TCL_HASH_KEY_STORE_HASH</b>
has effectively had its bucketPtr field replaced by a hash field but without
a version field in place. So long as callers do not directly touch either of
these fields, but leave them solely for the Tcl routines to operate on, then
the Tcl build-time configurability to use either implementation by setting
of <b>TCL_HASH_KEY_STORE_HASH</b> to 1 or not continues to be an
either set to 1 or not. After that, the routines do what they do, and any caller
expecting the other setting is just going to be broken. What's in place is at
best a measure of source compatibility helpful only to those who lift Tcl's
source code and copy it into their own programs.
option. But that just underlines the point that these fields are functionally
meant to be private and accessed only by Tcl. Better to have form and
function in agreement.
The advantage of static Tcl_HashTable allocation by callers is diminished by
the fact that the routines in this module only function if thread isolation is
preserved. Any particular (Tcl_HashTable *) may only be passed into
these routines by one thread. This suggests HashTables belong in thread
specific memory, which already removes the static option of storage.
these routines by a single thread. This suggests HashTables belong in thread
specific memory, which already removes the static option of storage. Having
a routine to actually allocate the hash table makes it clear from the beginning
precisely which thread owns which table.
The customizable hash function is defined to return an unsigned int, so
only 2^32 distinct hashes can be used to sift data. According to the internal
logic of the hash table implementation, this means the existing architecture
is suitable for holding at most 3 * 2^32 entries. If we aim to store more than
that, the Tcl_HashKeyType will need to evolve.
|
80
81
82
83
84
85
86
87
88
|
82
83
84
85
86
87
88
89
90
|
-
+
|
has a record of performing very well, and having a large impact on overall
Tcl performance. Solutions that truly reduce the hazards of collision attacks
tend to be costly in performance. It has been difficult to generate evidence
to support the claims of any alternatives to simultaneously perform well and
offer protection.
Other hashing criticisms have been raised occasionally that on some input sets,
the existing hashes do not randomize into the full 32 bits of hash value as
the existing hashes do not randomize into the full 32 bits of hash value as well as
they should for best operations.
|