cs: improve eq? hashing

Use the fixnum-mixing idea of dc82685ce0 on pointers, too.

This change provides a significant improvement on the "hash-mem.rkt"
benchmark, for example, because the allocated objects have a size that
triggers a repeating pattern in the low bits of the allocated address.
This commit is contained in:
Matthew Flatt 2020-11-22 09:11:11 -07:00
parent f07c2fea71
commit 5ca183a710
10 changed files with 25 additions and 31 deletions

View File

@ -338,7 +338,7 @@ RACKET_FOR_BOOTFILES = $(RACKET)
RACKET_FOR_BUILD = $(RACKET)
# This branch name changes each time the pb boot files are updated:
PB_BRANCH == circa-7.9.0.6-1
PB_BRANCH == circa-7.9.0.8-1
PB_REPO = https://github.com/racket/pb
# Alternative source for Chez Scheme boot files, normally set by

View File

@ -47,7 +47,7 @@ RACKETCS_SUFFIX =
RACKET =
RACKET_FOR_BOOTFILES = $(RACKET)
RACKET_FOR_BUILD = $(RACKET)
PB_BRANCH = circa-7.9.0.6-1
PB_BRANCH = circa-7.9.0.8-1
PB_REPO = https://github.com/racket/pb
EXTRA_REPOS_BASE =
CS_CROSS_SUFFIX =
@ -306,14 +306,14 @@ maybe-fetch-pb-as-is:
echo done
fetch-pb-from:
mkdir -p racket/src/ChezScheme/boot
if [ ! -d racket/src/ChezScheme/boot/pb ] ; then git clone -q -b circa-7.9.0.6-1 $(PB_REPO) racket/src/ChezScheme/boot/pb ; else cd racket/src/ChezScheme/boot/pb && git fetch -q origin circa-7.9.0.6-1:remotes/origin/circa-7.9.0.6-1 ; fi
cd racket/src/ChezScheme/boot/pb && git checkout -q circa-7.9.0.6-1
if [ ! -d racket/src/ChezScheme/boot/pb ] ; then git clone -q -b circa-7.9.0.8-1 $(PB_REPO) racket/src/ChezScheme/boot/pb ; else cd racket/src/ChezScheme/boot/pb && git fetch -q origin circa-7.9.0.8-1:remotes/origin/circa-7.9.0.8-1 ; fi
cd racket/src/ChezScheme/boot/pb && git checkout -q circa-7.9.0.8-1
pb-stage:
cd racket/src/ChezScheme/boot/pb && git branch circa-7.9.0.6-1
cd racket/src/ChezScheme/boot/pb && git checkout circa-7.9.0.6-1
cd racket/src/ChezScheme/boot/pb && git branch circa-7.9.0.8-1
cd racket/src/ChezScheme/boot/pb && git checkout circa-7.9.0.8-1
cd racket/src/ChezScheme/boot/pb && git add . && git commit --amend -m "new build"
pb-push:
cd racket/src/ChezScheme/boot/pb && git push -u origin circa-7.9.0.6-1
cd racket/src/ChezScheme/boot/pb && git push -u origin circa-7.9.0.8-1
win-cs-base:
IF "$(RACKET_FOR_BUILD)" == "" $(MAKE) win-bc-then-cs-base SETUP_BOOT_MODE=--boot WIN32_BUILD_LEVEL=bc PLAIN_RACKET=racket\racketbc DISABLE_STATIC_LIBS="$(DISABLE_STATIC_LIBS)" EXTRA_REPOS_BASE="$(EXTRA_REPOS_BASE)" JOB_OPTIONS="$(JOB_OPTIONS)" PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" RACKETBC_SUFFIX="$(RACKETBC_SUFFIX)" RACKETCS_SUFFIX="$(RACKETCS_SUFFIX)"
IF not "$(RACKET_FOR_BUILD)" == "" $(MAKE) win-just-cs-base SETUP_BOOT_MODE=--chain DISABLE_STATIC_LIBS="$(DISABLE_STATIC_LIBS)" EXTRA_REPOS_BASE="$(EXTRA_REPOS_BASE)" JOB_OPTIONS="$(JOB_OPTIONS)" PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" RACKETCS_SUFFIX="$(RACKETCS_SUFFIX)" RACKET_FOR_BUILD="$(RACKET_FOR_BUILD)"

View File

@ -14,7 +14,7 @@
;; In the Racket source repo, this version should change only when
;; "racket_version.h" changes:
(define version "7.9.0.7")
(define version "7.9.0.8")
(define deps `("racket-lib"
["racket" #:version ,version]))

View File

@ -47,4 +47,4 @@
(module+ test
(module config info
(define timeout 400)))
(define timeout 200)))

View File

@ -85,19 +85,15 @@ FORCEINLINE seginfo *MaybeSegInfo(uptr i) {
#define SegmentGeneration(i) (SegInfo(i)->generation)
#define SegmentOldSpace(i) (SegInfo(i)->old_space)
/* Must be consistent with `eq-hash` in "../s/library.ss" */
FORCEINLINE uptr eq_hash(ptr key) {
if (Sfixnump(key)) {
uptr x = UNFIX(key);
uptr x = (uptr)key >> primary_type_bits;
#if (ptr_bits == 64)
uptr x1 = x ^ ((x >> 32) & (uptr)0xFFFFFFFF);
uptr x1 = x ^ ((x >> 32) & (uptr)0xFFFFFFFF);
#else
uptr x1 = x;
uptr x1 = x;
#endif
uptr x2 = x1 ^ ((x1 >> 16) & (uptr)0xFFFF);
uptr x3 = x2 ^ ((x2 >> 8) & (uptr)0xFF);
return x3;
} else
return (uptr)key >> primary_type_bits;
uptr x2 = x1 ^ ((x1 >> 16) & (uptr)0xFFFF);
uptr x3 = x2 ^ ((x2 >> 8) & (uptr)0xFF);
return x3;
}

View File

@ -62,7 +62,7 @@ InstallLZ4Target=
# no changes should be needed below this point #
###############################################################################
Version=csv9.5.3.50
Version=csv9.5.3.51
Include=boot/$m
PetiteBoot=boot/$m/petite.boot
SchemeBoot=boot/$m/scheme.boot

View File

@ -357,7 +357,7 @@
;; ---------------------------------------------------------------------
;; Version and machine types:
(define-constant scheme-version #x09050332)
(define-constant scheme-version #x09050333)
(define-syntax define-machine-types
(lambda (x)
@ -2152,10 +2152,10 @@
;; a copy of this conversion for rehashing in "segment.h".
(let* ([x x-expr]
[x1 (constant-case ptr-bits
[(64) (fxxor x (fxand (fxsra x 32) #xFFFFFFFF))]
[(64) (fxxor x (fxand (fxsrl x 32) #xFFFFFFFF))]
[else x])]
[x2 (fxxor x1 (fxand (fxsra x1 16) #xFFFF))]
[x3 (fxxor x2 (fxand (fxsra x2 8) #xFF))])
[x2 (fxxor x1 (fxand (fxsrl x1 16) #xFFFF))]
[x3 (fxxor x2 (fxand (fxsrl x2 8) #xFF))])
x3)]))
; keep in sync with make-date

View File

@ -1544,12 +1544,10 @@
(adjust! h vec n n2)
(loop n2)))))))]))
;; Must be consistent with `eq_hash` in "../c/segment.h"
(define-syntax eq-hash
(syntax-rules ()
[(_ v-expr) (let ([v v-expr])
(if (fixnum? v)
(fixmix v)
($fxaddress v)))]))
[(_ v-expr) (fixmix ($fxaddress v-expr))]))
(define adjust!
(lambda (h vec1 n1 n2)

View File

@ -2,7 +2,7 @@
;; Check to make we're using a build of Chez Scheme
;; that has all the features we need.
(define-values (need-maj need-min need-sub need-dev)
(values 9 5 3 50))
(values 9 5 3 51))
(unless (guard (x [else #f]) (eval 'scheme-fork-version-number))
(error 'compile-file

View File

@ -16,7 +16,7 @@
#define MZSCHEME_VERSION_X 7
#define MZSCHEME_VERSION_Y 9
#define MZSCHEME_VERSION_Z 0
#define MZSCHEME_VERSION_W 7
#define MZSCHEME_VERSION_W 8
/* A level of indirection makes `#` work as needed: */
#define AS_a_STR_HELPER(x) #x