Skip Menu |

This queue is for tickets about the CHI CPAN distribution.

Report information
The Basics
Id: 78536
Status: open
Priority: 0/
Queue: CHI

People
Owner: Nobody in particular
Requestors: NHORNE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.55
Fixed in: (no value)



Subject: Use refs
To save putting large amounts of data on the stack (which is wasteful of CPU and memory) it would be great if set could take a reference to the data). You could easily do it with something like my $data = shift; if(ref($data) eq 'SCALAR')) { $data = $$data; } or something like that.
The third line will end up making a copy anyway, right? Can you explain why it's especially bad for the copy to be in a passed variable as opposed to a lexical variable? Thanks - Jon On Mon Jul 23 09:39:27 2012, NHORNE wrote: Show quoted text
> To save putting large amounts of data on the stack (which is wasteful of > CPU and memory) it would be great if set could take a reference to the > data). > > You could easily do it with something like > my $data = shift; > if(ref($data) eq 'SCALAR')) { > $data = $$data; > } > > or something like that.
CC: NHORNE [...] cpan.org
Subject: Re: [rt.cpan.org #78536] Use refs
Date: Sun, 26 Aug 2012 09:28:12 +0100
To: bug-CHI [...] rt.cpan.org
From: Nigel Horne <njh [...] bandsman.co.uk>
On 26/08/12 00:48, Jonathan Swartz via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=78536> > > The third line will end up making a copy anyway, right? Can you explain > why it's especially bad for the copy to be in a passed variable as > opposed to a lexical variable? Thanks - Jon
There would be only one copy, whereas at the moment there is also a copy on the stack. So the saving comes from copying onto and off the stack (speed improvement) and the copy on the stack (memory improvement). I've done plenty of investigations into this concept and found it really does help. -Nigel
Subject: Re: [rt.cpan.org #78536] Use refs
Date: Sun, 2 Sep 2012 07:11:01 -0700
To: bug-CHI [...] rt.cpan.org
From: Jonathan Swartz <swartz [...] pobox.com>
On Aug 26, 2012, at 1:28 AM, njh@bandsman.co.uk via RT wrote: Show quoted text
> Queue: CHI > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=78536 > > > On 26/08/12 00:48, Jonathan Swartz via RT wrote:
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=78536> >> >> The third line will end up making a copy anyway, right? Can you explain >> why it's especially bad for the copy to be in a passed variable as >> opposed to a lexical variable? Thanks - Jon
> > There would be only one copy, whereas at the moment there is also a copy > on the stack. So the saving comes from copying onto and off the stack > (speed improvement) and the copy on the stack (memory improvement). > I've done plenty of investigations into this concept and found it really > does help.
Ok, but this is only for set(), which hopefully is the uncommon case if you have a cache with a decent hit rate. Is there a way to reduce the copies for get()? e.g. by passing a reference where the value should be stored? Still not convinced I want to do this, just wondering… :) Thanks Jon
Subject: Re: [rt.cpan.org #78536] Use refs
Date: Mon, 10 Sep 2012 16:11:30 +0100
To: bug-CHI [...] rt.cpan.org
From: Nigel Horne <njh [...] bandsman.co.uk>
Show quoted text
> > Ok, but this is only for set(), which hopefully is the uncommon case if you have a cache with a decent hit rate. Is there a way to reduce the copies for get()? e.g. by passing a reference where the value should be stored?
You mean use the same method that Template->process() uses? That could work fine. -Nigel
Subject: Re: [rt.cpan.org #78536] Use refs
Date: Tue, 11 Sep 2012 07:28:36 -0400
To: bug-CHI [...] rt.cpan.org
From: Jonathan Swartz <swartz [...] pobox.com>
Show quoted text
>
>> >> Ok, but this is only for set(), which hopefully is the uncommon case if you have a cache with a decent hit rate. Is there a way to reduce the copies for get()? e.g. by passing a reference where the value should be stored?
> > You mean use the same method that Template->process() uses? That could > work fine.
Not familiar with that but ok. This will unfortunately complicate any roles or subclasses that override get() or set(); they'll have to handle the alternate reference passing API. It is already hard enough keeping all of these working together. That's one of the main reasons I'm reluctant to do this despite believing your claim of the performance benefit. Will have to think about it…