Skip to content

A few thoughts #1

@Genbox

Description

@Genbox

Hi hypervis0r and Jeff,

Interesting blogpost from you guys. A few things came to mind while reading it. Hope you don't mind me dumping a few of them here.

  • Hashing is tricky. It is a tradeoff between performance and entropy. DJB2 hash is great for its simplicity, but you can get a lot more speed out of a modern CPU with another equally well-randomized hash function. Checkout SMhasher for inspiration. The trick in your case would be to hash more data at the same time.
  • If your hash table is bounded by an upper bound, such as your case when you pre-generate a hash table at compile-time, it is possible to generate a hash function that would not only be faster but map directly from X to Y without using a general-purpose hash function. Such a hash is called a "perfect hash". It maps distinct items of a set to an offset in an array at the cost of overhead in memory. There are also minimal perfect hash functions that take longer to construct but have no overhead. Check out the CMPH project.
  • PE export tables also support lookup by ordinal. You better be sure it is exported when calling it, but it does make for some interesting optimizations both with hash tables and binary search since sorting/hashing integers is much faster.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions