![]() A mutable hash table only uses the lower few bits of a hash code, because it masks the hash code by [one less than] the power-of-two size of the bucket array. That truncation interacts badly with the hashing function for fixnums, which is the identity function; if the the lower several bits of the fixnum stay the same for many keys and the upper bits change, then there are many hash collisions --- and that's a relatively likely distribution. Fix the mutable hash-table implementations by mixing the hash code to let higher bits influence the lower bits: xor the high half of the bits with the lower half (which doesn't lose information, because xoring again would recover the original number), then do the same for the high one-fourth of bits in the low half, and then (on a 64-bit platform) the high one-eighth of the low one-fourth of the bits. Instead if blaming the way the mutable hash-table implementations only use the lower bits of a hash code, we could blame the hash function on fixnums for not performing this kind of mixing. In this patch, though, we take the view that the hash function's job is to map variation in its domain to variation in the fixnum hash code, and then the hash table's job is to use that fixnum effectively. That separation of responsibilities is now documented with `gen:equal+hash`. There are also improvements here to the hashing function for bignums in CS and to the secondary hashung function for fixnums and bignums in BC. Thanks to Alex Harsanyi for reporting the problem. |
||
---|---|---|
.github | ||
pkgs | ||
racket | ||
.gitattributes | ||
.gitignore | ||
.lgtm.yml | ||
.mailmap | ||
.makefile | ||
build.md | ||
LICENSE | ||
Makefile | ||
README.md |
Racket is a general-purpose programming language and an ecosystem for language-oriented programming.
This repository holds the source code for the core of Racket plus some related packages. The rest of the Racket distribution source code is in other repositories, mostly under the Racket GitHub organization.
Quick Start
Pre-built versions of Racket for a variety of operating systems and architectures, as well as convenient source distributions are available at
https://download.racket-lang.org
Racket comes with extensive documentation, including several tutorials. You can read all of this documentation, as well as documentation for third-party packages at
Building from Source
For information on building Racket from this repository, see the Build Guide.
Contributing
Contribute to Racket by submitting a pull request, joining the development mailing list, or visiting the IRC or Slack channels.
By making a contribution, you are agreeing that your contribution is licensed under the LGPLv3, Apache 2.0, and MIT licenses. Those licenses are available in this repository in the files racket/src/LICENSE-LGPL.txt, racket/src/LICENSE-APACHE.txt, and racket/src/LICENSE-MIT.txt.
See the Racket Build Guide for more guidance on contributing.
The Friendly Environment Policy contains guidelines on expected behavior within the Racket community.
License
Racket is free software; see LICENSE for more details.