unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* weak hash tables
@ 2011-10-24 17:19 Andy Wingo
  2011-10-28  9:02 ` Andy Wingo
  2011-11-11 20:30 ` Ludovic Courtès
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Wingo @ 2011-10-24 17:19 UTC (permalink / raw)
  To: guile-devel

Hi,

While doing the recent retagging work I realized that I really wanted to
kill weak pairs.  They look like pairs but you can't actually access
their fields using car and cdr -- terrible things.  To do that I had to
reimplement the weak hash tables, to make them not use them.  I did
that, reimplementing them as open-addressed hash tables, with robin hood
linear probing on collision.  It seems to work well.  Besides the
performance improvement you get with just scanning linearly through
memory, open-addressed hash tables aren't structurally perturbed by the
disappearing links.  It's a lot less messy, and uses less memory, and we
have space to encode the actual hash values in the table.  (However I
don't think our current hash functions are very good.)

The one nasty thing there was adapting to the old interfaces.  In
particular the hashx interface expects to be able to assoc down a list,
but there are no assoc lists in the new weak tables.  Guess what I do?
That's right, for weak hashx tables I make new association lists in the
equal? handler, then pass that alist to the user's assoc function.
Gross.

Currently the new weak tables are only accessible under the old API.  I
don't know whether to publicise the new API, or make a different API, or
what.  If we hadn't coded the handle API into our hash tables I would
replace the regular (strong) hash table implementation too.  I might
still do that but it's not pressing.

Anyway, thoughts on the API are welcome.

Regards,

Andy

ps.  The new weak tables are thread-safe.  Yay.
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-15 21:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-24 17:19 weak hash tables Andy Wingo
2011-10-28  9:02 ` Andy Wingo
2011-11-11 20:30 ` Ludovic Courtès
2011-11-15 21:33   ` Andy Wingo

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).