[GHC] #15642: Improve the worst case performance of weak pointers
GHC
ghc-devs at haskell.org
Fri Sep 14 07:05:00 UTC 2018
#15642: Improve the worst case performance of weak pointers
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: 8.8.1
Component: Runtime System | Version: 8.6.1-beta1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by osa1):
Somehow marking keys and being able map keys to weaks would be nice. As
you say
the mapping should be able to map a key to multiple weaks because an
object may
be key to multiple weaks.
Out of curiosity, did you measure how long weak collection takes? I'd
guess
because we scan all weaks in collected gens repeatedly (until we stop
evacuating things) the worst case performance (when we have a ton of
weaks)
would be pretty bad, but I haven't benchmarked this case myself.
> This is the weakest link: if we don't have a spare bit there, or don't
want
> to use one, then I think this whole idea is sunk.
I think in theory it is possible to use a bit in info pointer. We already
do
this to create forwarding pointers in GC, we could use a different bit to
indicate that the objects is a weak key. This however requires changes in
mutator code as mutators will have to untag info ptr before entering (in
addition to untagging the pointer to the object itself in some cases).
That's
probably not great as we end up generating more code and probably making
things
slightly slower (one more instruction to enter -- not sure if measurable
difference though) to be able to collect weaks faster, and a lot of
programs
don't have a lot of weaks.
I wonder how other languages with weaks (Python, Java, Lua ...) do this.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15642#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list