9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] cheep improvement for rendezvous
@ 2015-02-08  3:40 erik quanstrom
  0 siblings, 0 replies; only message in thread
From: erik quanstrom @ 2015-02-08  3:40 UTC (permalink / raw)
  To: 9fans

i noticed this today by inspection.  the tag passed to rendezvous is usually
a naturally-aligned address.  for the same size rendhash, we can get shorter
hash chains for the usual case by dropping the low-order bits.

the "2" assumes 32 bits, and should really be replaced by log2ciel(sizeof(uintptr)).
but that's not constant.

/n/dump/2015/0207/sys/src/nix/port/portdat.h:489,495 - ../port/portdat.h:489,496
  	PGHLOG  =	9,
  	PGHSIZE	=	1<<PGHLOG,	/* Page hash for image lookup */
  };
- #define REND(p,s)	((p)->rendhash[(s)&((1<<RENDLOG)-1)])
+ /*
+  * assume natural alignment for minimum sized pointer
+  * 2 is a stand in for log2ciel(sizeof(uintptr))
+  */
+ #define REND(p,s)	((p)->rendhash[((s)>>2)&((1<<RENDLOG)-1)])
  #define MOUNTH(p,qid)	((p)->mnthash[(qid).path&((1<<MNTLOG)-1)])

  struct Pgrp


- erik



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-02-08  3:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-08  3:40 [9fans] cheep improvement for rendezvous erik quanstrom

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 NNTP newsgroup(s).