[Haskell-cafe] idea for avoiding temporaries

David Roundy droundy at darcs.net
Thu Mar 8 18:56:55 EST 2007


Nothing is being done concurrently, so I don't see what STM would gain us.
What is it that you're thinking we could gain from STM?

David

On Thu, Mar 08, 2007 at 03:04:43PM -0800, Dan Weston wrote:
> Have you looked into using STM (Software Transactional Memory)? This 
> problem seems like some subset of concurrent programming.
> 
> Dan
> 
> David Roundy wrote:
> >Ah, I was missing your point, I've heard something called copy-on-write,
> >which wasn't what you describe (or I also misunderstood it when I heard it
> >before).
> >
> >I see.  But how would one manage these handles? What's to keep me from
> >accidentally copying a handle? It sounds like it'd require explicit memory
> >management, in order to avoid ever copying a handle, if I were to implment
> >this myself.
> >
> >Or are you suggesting that if the simons implemented a copy-on-write scheme
> >in ghc's RTS, then I'd be all set?
> >
> >In short, managing the reader count is exactly the problem that sounds
> >hard, and I still don't have any idea how one would go about it.
> >
> >David
> >
> >On Thu, Mar 08, 2007 at 01:31:19PM -0800, Dan Weston wrote:
> >>I might be missing the point, but I think you are missing mine.
> >>
> >>The copy-on-write I am talking about means that it's no longer "your 
> >>data", so you don't need any knowledge of who has access to it because 
> >>you don't own it or have a pointer to it. It is owned by some broker 
> >>from which you request a read-only or write access handle as needed. 
> >>Requested changes to underlying data already shared by others triggers a 
> >>copy and reassignment of pointers to it for your handle alone.
> >>
> >>The copy cost appears only when there is more than one handle to the 
> >>same data and one of them changes it.
> >>
> >>All this can be wrapped up and hidden away. If you want to escape this 
> >>broker business and steal back your data, just ask: the broker will 
> >>duplicate shared data needed by others, change their pointers to it, 
> >>then disown the pointer it returns to you.
> >>
> >>This is copying without writing (unnecessarily). Or am I missing 
> >>something?
> >>
> >>Dan
> >>
> >>David Roundy wrote:
> >>>I'm thinking you're missing the point.  The point is to copy without
> >>>writing, and that requires some knowledge (whether static or runtime) of
> >>>whether anyone else has a reference to my data--which copy-on-write won't
> >>>give me.
> >>>
> >>>David
> >>>
> >>>On Thu, Mar 08, 2007 at 11:15:25AM -0800, Dan Weston wrote:
> >>>>Or possibly more generally copy-on-write, which requires one more level 
> >>>>of indirection (handle instead of ptr). Since you are talking about 
> >>>>using ForeignPtr, this is already within your power to prototype, I 
> >>>>should think.
> >>>>
> >>>>Dan
> >>>>
> >>>>Dan Piponi wrote:
> >>>>>On 3/8/07, David Roundy <droundy at darcs.net> wrote:
> >>>>>
> >>>>>>I started wondering whether there's a solution that would allow us to
> >>>>>>write pretty high-level pure functional code, while the RTS can 
> >>>>>>realize
> >>>>>>at run-time that we have the only reference to the input argument and
> >>>>>>that it is therefore safe to consume it destructively.
> >>>>>I think you're talking about uniqueness typing which is supported by
> >>>>>the programming language Clean.


More information about the Haskell-Cafe mailing list