From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] st.c (st_numhash): mix float value
Date: Thu, 22 Jan 2015 00:49:46 +0000 [thread overview]
Message-ID: <1421887786-17454-1-git-send-email-e@80x24.org> (raw)
FLONUM_P appears to generate too many false positives
in real world usage, with too many integers becoming
-2.0 or 2.0
So mix it into the original value and follow the original
shuffling path.
Revised benchmark results from hash benchmarks:
Speedup ratio: compare with the result of `2.1.5' (greater is better)
name trunk built
hash_aref_flo 0.007 1.583
hash_aref_flo_ident 0.004 1.146
hash_aref_miss 1.192 1.179
hash_aref_str 1.214 1.211
hash_aref_sym 1.327 1.321
hash_aref_sym_long 1.319 1.295
hash_flatten 1.386 1.364
hash_ident_num 1.181 1.188
hash_ident_obj 1.219 1.248
hash_ident_str 1.211 1.211
hash_ident_sym 1.207 1.218
hash_keys 0.951 0.951
hash_shift 1.040 1.041
hash_values 0.959 0.960
loop_whileloop2 0.992 0.993
vm2_bighash* 1.338 1.316
---
st.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/st.c b/st.c
index 2ffa986..12f3156 100644
--- a/st.c
+++ b/st.c
@@ -1763,8 +1763,9 @@ st_numhash(st_data_t n)
* shifts and bitmask operations.
*/
#ifdef USE_FLONUM /* RUBY */
- if (FLONUM_P(n))
- return (st_index_t)rb_float_value(n);
+ if (FLONUM_P(n)) {
+ n ^= (st_data_t)rb_float_value(n);
+ }
#endif
return (st_index_t)((n>>(RUBY_SPECIAL_SHIFT+3)|(n<<3)) ^ (n>>3));
--
EW
reply other threads:[~2015-01-22 0:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421887786-17454-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).