Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6789153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:34:11+00:00 2026-05-26T17:34:11+00:00

Gperf consistently underperforms a Judy array in my environment, and I’m wondering if there

  • 0

Gperf consistently underperforms a Judy array in my environment, and I’m wondering if there is another perfect hash library out there built specifically for integer keys. I know the set of keys beforehand, and I would like to leverage that into a performance/size advantage.

There are ~1000 keys, and retrievals are not in sequential order. Key pairs are both integers. Keys are 32-bit, and retrieved values are 8-bit. Size is the most important factor.

If there is a way to tweak Gperf for integer keys, or just another approach in general, I’m all ears, too. 🙂

(Sidenote: …While typing out this question, I realized a binary search probably takes the cake and I’ve just over-thought the problem. I’d still like to hear any thoughts you may have for the sake of learning, though!)

Edit: Keys are not evenly distributed. Most are randomly clustered throughout the entire possible range.

Edit 2: Worst-case binary searches were too slow for my taste, so I ended up playing with the keys until I found 8 bits to use from each to make 256 well-distributed buckets. I held the min & max of each bucket (24 bits for each bucket entry), and made one big struct array for the key-pairs. On-par/faster and smaller than everything else I tested with for my particular case, so I guess I’m going with that for now. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:34:11+00:00Added an answer on May 26, 2026 at 5:34 pm

    Keep your keys sorted, and use an M-tree to retrieve any key.

    An M-tree has M entry per node, instead of 2 for binaries.
    It will help tremendously for performance.
    Use a cache line size as the basis of your node size, hence 64 Bytes.
    You can store 16 32bits values in this size.

    Since you have 1000 values, 3 levels will be enough to retrieve the right key (as opposed to 10 levels for a binary tree).

    Another idea would be to hash your keys into a small hash-table, such as 12-bits one (4K entries), and solve the potential collisions with a simple chain. You are very likely to get most of your keys in a single search.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I want to build a perfect hash table for looking up an
I'm now considering using gperf generated hash function to replace our old one, but
I'm attempting to hash the values 10, 100, 32, 45, 58, 126, 3, 29,
When compiling GCC it is possible to get very far in the build process
I am trying to develop an android module for titanium mobile 1.8.1. Here are
I'm having problems compiling an open source C++ project on Fedora. When I download
While reading the pigeonhole principle on Wikipedia, I come across - collisions are inevitable
I have a list of about a hundreds unique strings in C++, I need
I simply want to install MySQL on my Mac (running Mac OS X 10.6.5 (Snow Leopard)) for
I'm going to be using a key:value store and would like to create non-collidable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.