mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Faster chan_circid_entry_hash implementation
Since this is critical-path, let's tune the value we pass to csiphash a little so it fits into one whole round.
This commit is contained in:
parent
8127f4db30
commit
0ad607d604
@ -76,14 +76,15 @@ chan_circid_entries_eq_(chan_circid_circuit_map_t *a,
|
|||||||
static INLINE unsigned int
|
static INLINE unsigned int
|
||||||
chan_circid_entry_hash_(chan_circid_circuit_map_t *a)
|
chan_circid_entry_hash_(chan_circid_circuit_map_t *a)
|
||||||
{
|
{
|
||||||
struct {
|
/* Try to squeze the siphash input into 8 bytes to save any extra siphash
|
||||||
void *chan;
|
* rounds. This hash function is in the critical path. */
|
||||||
circid_t circid;
|
uintptr_t chan = (uintptr_t) (void*) a->chan;
|
||||||
} s;
|
uint32_t array[2];
|
||||||
memset(&s, 0, sizeof(s));
|
array[0] = a->circ_id;
|
||||||
s.chan = a->chan;
|
/* The low bits of the channel pointer are uninteresting, since the channel
|
||||||
s.circid = a->circ_id;
|
* is a pretty big structure. */
|
||||||
return (unsigned) siphash24g(&s, sizeof(s));
|
array[1] = (uint32_t) (chan >> 6);
|
||||||
|
return (unsigned) siphash24g(array, sizeof(array));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Map from [chan,circid] to circuit. */
|
/** Map from [chan,circid] to circuit. */
|
||||||
|
Loading…
Reference in New Issue
Block a user