A Faster whatIs

Alastair Reid alastair@reid-consulting-uk.ltd.uk
30 Nov 2002 14:54:51 +0000


> Hello everyone: I made some changes to the Hugs sources which give
> small runtime speed gains.

I think you're the first person to look at optimizing Hugs in quite a
while.  Great stuff!

I toyed with changing whatIs a few years ago.  Instead of your
table-based approach, I was thinking of using a bitwise encoding.  My
idea was to use one bit to select int/not int and that everything else
would be interpreted as a triple of the form:

  (WhatisTag,ModuleId,Index)

Where, for example, the WhatisTag is 5 bits, the ModuleId is 10 bits
and the Index is 16 bits (the numbers will probably need tweaked
somewhat). So, each module would have its own set of tables for
storing names, types, etc.

There's a whole bunch of tags like BANG, COMP, ASPAT, etc. which don't
have any associated data - they'd be in a tuple of the form

  (WhatisTag,<unused>,MoreTag)

I figured this would be faster because most whatis tests could be
resolved just by looking at the tag.  I also figured it would lead to
a more flexible structure in Hugs because:

- We regularily overflow a bunch of hardwired limits in Hugs as we
  load bigger and bigger programs.  Programs are getting bigger not
  because modules are getting bigger but because we load more modules.
  This change would make those hardwired limits be per-module limits
  so Hugs ought to scale better.

- Hugs uses a stacklike method for loading modules.  If a module you
  loaded early changes, then all modules loaded after it have to be
  reloaded whether they depend on that module or not.  This change
  could lead the way to relaxing that constraint.

There's other ways to achieve both these goals - this just seemed like
a good way of killing 3 birds with one stone.


I wonder how the this change would stack up against your change?

--
Alastair

ps I'd really like to ask for your code so I can spend some time
looking at it but I have to spend more time on things that actually
pay me for the next few months so I doubt I'll manage it.  Sorry.