Skip Menu |

This queue is for tickets about the Method-Signatures CPAN distribution.

Report information
The Basics
Id: 84020
Status: resolved
Priority: 0/
Queue: Method-Signatures

People
Owner: Nobody in particular
Requestors: fritz.zaucker [...] oetiker.ch
Cc:
AdminCc:

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



Subject: Make Moose optional
Date: Mon, 18 Mar 2013 09:14:55 +0100 (CET)
To: bug-Method-Signatures [...] rt.cpan.org
From: Fritz Zaucker <fritz.zaucker [...] oetiker.ch>
Hi, for some (web) applications the memory foot-print of Method::Signatures is rather heavy. It also depends on many none-core modules which can be a problem in some (restrictive) environments. As far as I know Moose is only needed for type checking. Would it be possible to factor this out, so that Method::Signatures can be used without it (and thus with fewer dependencies and a smaller foot-print)? Thanks for the cool module and best regards, Fritz -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch
Fritz, Show quoted text
> As far as I know Moose is only needed for type checking. Would it be > possible to factor this out, so that Method::Signatures can be used
without Show quoted text
> it (and thus with fewer dependencies and a smaller foot-print)?
Moose is never loaded by Method::Signatures. It will load _Mouse_, but only if you use types in your signatures. So Method::Signatures can easily be used without Moose, and even without Mouse (if you don't do any type-checking at all). According to my perlbloat script, MS adds about 18.2Mb (on my machine with my version of Perl). Of that, I'm guessing the bulk of it is from PPI (which perlbloat tells me weighs in at 13.8Mb). Using PPI is how we avoid many whitespace-dependent bugs, make sure that comments in the signatures don't cause weird bugs, and properly parse things like code blocks. I think it would be prohibitively expensive to try to do without it, but I'm open to ideas. In fact, if you have any specific ideas for reducing the memory footprint of MS, please let us know. We're always open to doing that. :-) Take care.
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Thu, 21 Mar 2013 09:15:52 +0100 (CET)
To: Buddy Burden via RT <bug-Method-Signatures [...] rt.cpan.org>
From: Fritz Zaucker <zaucker [...] oetiker.ch>
Hi Buddy, On Mon, 18 Mar 2013, Buddy Burden via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=84020 > >
>> As far as I know Moose is only needed for type checking. Would it be >> possible to factor this out, so that Method::Signatures can be used >> without it (and thus with fewer dependencies and a smaller foot-print)?
> > Moose is never loaded by Method::Signatures. It will load _Mouse_, but > only if you use types in your signatures. So Method::Signatures can > easily be used without Moose, and even without Mouse (if you don't do any > type-checking at all).
cool, then this point is already taken care of. Show quoted text
> According to my perlbloat script, MS adds about 18.2Mb (on my machine with > my version of Perl). Of that, I'm guessing the bulk of it is from PPI > (which perlbloat tells me weighs in at 13.8Mb). Using PPI is how we avoid > many whitespace-dependent bugs, make sure that comments in the signatures > don't cause weird bugs, and properly parse things like code blocks. I > think it would be prohibitively expensive to try to do without it, but I'm > open to ideas.
The only idea I have (and that would probably work in my context) is to have an option to disable those checks. This would allow to have the checks during development and testing, but have a smaller foot print on the production system. But this might be difficult to implement and probably be a bit against the spirit of the module ... Show quoted text
> In fact, if you have any specific ideas for reducing the memory > footprint of MS, please let us know. We're always open to doing that. :-)
Integrate it into the Perl core ... ;-) Thanks for your fast answer anyway. Take care, Fritz -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Thu, 21 Mar 2013 16:18:30 -0700
To: bug-Method-Signatures [...] rt.cpan.org
From: "Michael G. Schwern" <schwern [...] pobox.com>
On 3/18/13 12:08 PM, Buddy Burden via RT wrote: Show quoted text
>> As far as I know Moose is only needed for type checking. Would it be >> possible to factor this out, so that Method::Signatures can be used
> without
>> it (and thus with fewer dependencies and a smaller foot-print)?
> > Moose is never loaded by Method::Signatures. It will load _Mouse_, but > only if you use types in your signatures. So Method::Signatures can > easily be used without Moose, and even without Mouse (if you don't do > any type-checking at all).
Method::Signatures is currently using Any::Moose, so it will only use Moose if it's already loaded. MS will never load Moose itself. We're working on changing that behavior so Method::Signatures will pick the proper type system depending on what the current class is using. https://github.com/schwern/method-signatures/issues/34
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Thu, 21 Mar 2013 16:22:26 -0700
To: bug-Method-Signatures [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On Thu, Mar 21, 2013 at 1:16 AM, Fritz Zaucker via RT <bug-Method-Signatures@rt.cpan.org> wrote: Show quoted text
> The only idea I have (and that would probably work in my context) is to have > an option to disable those checks. This would allow to have the checks > during development and testing, but have a smaller foot print on the > production system. But this might be difficult to implement and probably be > a bit against the spirit of the module ...
I know Buddy and I were talking about this, but I can't find it in a Github issue. We talked about having an environment variable to turn off types, but had to be careful of coercion. Buddy, do you remember? Show quoted text
> Integrate it into the Perl core ... ;-)
I wish. And it has been floated with some core folks.
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Fri, 22 Mar 2013 08:24:28 +0100 (CET)
To: Michael G Schwern via RT <bug-Method-Signatures [...] rt.cpan.org>
From: Fritz Zaucker <zaucker [...] oetiker.ch>
On Thu, 21 Mar 2013, Michael G Schwern via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=84020 > > > On 3/18/13 12:08 PM, Buddy Burden via RT wrote:
>>> As far as I know Moose is only needed for type checking. Would it be >>> possible to factor this out, so that Method::Signatures can be used
>> without
>>> it (and thus with fewer dependencies and a smaller foot-print)?
>> >> Moose is never loaded by Method::Signatures. It will load _Mouse_, but >> only if you use types in your signatures. So Method::Signatures can >> easily be used without Moose, and even without Mouse (if you don't do >> any type-checking at all).
> > Method::Signatures is currently using Any::Moose, so it will only use > Moose if it's already loaded. MS will never load Moose itself.
Thanks for the clarification ... Show quoted text
> We're working on changing that behavior so Method::Signatures will pick > the proper type system depending on what the current class is using. > https://github.com/schwern/method-signatures/issues/34
... and the additional info. Cheers, Fritz -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Fri, 22 Mar 2013 08:28:14 +0100 (CET)
To: Michael G Schwern via RT <bug-Method-Signatures [...] rt.cpan.org>
From: Fritz Zaucker <zaucker [...] oetiker.ch>
On Thu, 21 Mar 2013, Michael G Schwern via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=84020 > > > On Thu, Mar 21, 2013 at 1:16 AM, Fritz Zaucker via RT > <bug-Method-Signatures@rt.cpan.org> wrote:
>> >> The only idea I have (and that would probably work in my context) is to have >> an option to disable those checks. This would allow to have the checks >> during development and testing, but have a smaller foot print on the >> production system. But this might be difficult to implement and probably be >> a bit against the spirit of the module ...
> > I know Buddy and I were talking about this, but I can't find it in a > Github issue. We talked about having an environment variable to turn > off types, but had to be careful of coercion.
I was actually talking about the checks using PPI, as this seems to be the biggest module being used in MS. But that might be a completely insane idea ... Show quoted text
> Buddy, do you remember? >
>> Integrate it into the Perl core ... ;-)
> > I wish. And it has been floated with some core folks.
Hopes die last ... ;-) -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Fri, 22 Mar 2013 13:26:00 -0700
To: bug-Method-Signatures [...] rt.cpan.org
From: "Michael G. Schwern" <schwern [...] pobox.com>
On 3/22/13 12:28 AM, Fritz Zaucker via RT wrote: Show quoted text
> I was actually talking about the checks using PPI, as this seems to be the > biggest module being used in MS. > > But that might be a completely insane idea ...
Alas. We have to use PPI to properly support interesting expressions and data as default parameters and constraints. For example... func foo( $stuff = ["foo, bar", 2, 3], $other ) { ... } even something that simple is difficult to get right without PPI. For a larger example... https://github.com/schwern/method-signatures/blob/master/t/examples/silly.t If you're very clever you might be able to write a simpler parser which works so long as there's no defaults and decide whether to use that or the PPI one with something as simple as /=|where|when/. OTOH you could speed up the load time of PPI.
Fritz, Show quoted text
> The only idea I have (and that would probably work in my context) is to have > an option to disable those checks. This would allow to have the checks > during development and testing, but have a smaller foot print on the > production system. But this might be difficult to implement and probably be > a bit against the spirit of the module ...
No, not at all. In fact, it's something we've discussed often. But note that while this would buy you quite a bit of extra speed at run-time, I don't think it's going to buy you any memory, which is what I understood that you were trying to optimize for. -- Buddy
schwern, Show quoted text
> I know Buddy and I were talking about this, but I can't find it in a > Github issue. We talked about having an environment variable to turn > off types, but had to be careful of coercion. > > Buddy, do you remember?
We brought it up recently in email, but of course it's been in the POD (where it's described as a "go really fast" switch :-D ) forever. But, yeah, I went scrambling for a GitHub issue to link to as well, and was just as surprised as you to find there isn't one. I'll take the info we tossed around in email and condense that to a new issue--I should have time this weekend, now that I've done my PerlMongers presentation (on Method::Signatures, as it happens). I'll link it back here once I've created it. Show quoted text
>> Integrate it into the Perl core ... ;-)
Show quoted text
> I wish. And it has been floated with some core folks.
Funny, but that's exactly what my local PerlMongers asked me when I called for questions. :-) Maybe if it keeps on gaining popularity ... who knows? -- Buddy
Fritz, Show quoted text
> I was actually talking about the checks using PPI, as this seems to be > the > biggest module being used in MS.
As schwern says, I think I wasn't clear enough in my first email. We don't use PPI for any validation checks. We use it to parse the signature in the first place. Without PPI, we can't generate the code to unpack @_, much less generate the validation checks. Now, schwern mentions that it might conceivably be possible to parse the sig without PPI, and that's true, but for just one simple example of how valuable PPI is: One of the very first bugs I ever discovered in MS was that comments inside signatures (e.g. if your signature spanned multiple lines) would throw off the parsing. I contacted schwern about it, and he said "well, we're using PPI; just use that to fix it." One quick head-slap later, I spent ten minutes reading the PPI docs, added a *single* line of code, and the bug was fixed. That's the kind of flexibility I would really hate to give up by abandoning PPI.
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Mon, 25 Mar 2013 08:40:08 +0100 (CET)
To: Buddy Burden via RT <bug-Method-Signatures [...] rt.cpan.org>
From: Fritz Zaucker <zaucker [...] oetiker.ch>
On Sat, 23 Mar 2013, Buddy Burden via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=84020 > >
>> The only idea I have (and that would probably work in my context) is to have >> an option to disable those checks. This would allow to have the checks >> during development and testing, but have a smaller foot print on the >> production system. But this might be difficult to implement and probably be >> a bit against the spirit of the module ...
> > No, not at all. In fact, it's something we've discussed often. But note > that while this would buy you quite a bit of extra speed at run-time, I > don't think it's going to buy you any memory, which is what I understood > that you were trying to optimize for.
Hmm, true enough. My main concern ist startup time, as I am talking about a web application. On the other hand, I should probably do some benchmarking first, before worrying ... Fritz -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Mon, 25 Mar 2013 08:44:41 +0100 (CET)
To: Buddy Burden via RT <bug-Method-Signatures [...] rt.cpan.org>
From: Fritz Zaucker <zaucker [...] oetiker.ch>
On Sat, 23 Mar 2013, Buddy Burden via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=84020 > > > Fritz, >
>> I was actually talking about the checks using PPI, as this seems to be >> the biggest module being used in MS.
> > As schwern says, I think I wasn't clear enough in my first email. We > don't use PPI for any validation checks. We use it to parse the signature > in the first place. Without PPI, we can't generate the code to unpack @_, > much less generate the validation checks. Now, schwern mentions that it > might conceivably be possible to parse the sig without PPI, and that's > true, but for just one simple example of how valuable PPI is: > > One of the very first bugs I ever discovered in MS was that comments > inside signatures (e.g. if your signature spanned multiple lines) would > throw off the parsing. I contacted schwern about it, and he said "well, > we're using PPI; just use that to fix it." One quick head-slap later, I > spent ten minutes reading the PPI docs, added a *single* line of code, and > the bug was fixed. > > That's the kind of flexibility I would really hate to give up by > abandoning PPI.
I can very well understand that reasoning, especially with the flexibility MS gives. As far as I am concerned you're welcome to close that "bug"-report. Cheers, Fritz -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch
Subject: Re: [rt.cpan.org #84020] Make Moose optional
Date: Mon, 25 Mar 2013 09:08:34 +0100 (CET)
To: Michael G Schwern via RT <bug-Method-Signatures [...] rt.cpan.org>
From: Fritz Zaucker <zaucker [...] oetiker.ch>
On Fri, 22 Mar 2013, Michael G Schwern via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=84020 > > > On 3/22/13 12:28 AM, Fritz Zaucker via RT wrote:
>> I was actually talking about the checks using PPI, as this seems to be the >> biggest module being used in MS. >> >> But that might be a completely insane idea ...
> > Alas. We have to use PPI to properly support interesting expressions > and data as default parameters and constraints. For example... > > func foo( $stuff = ["foo, bar", 2, 3], $other ) { ... } > > even something that simple is difficult to get right without PPI.
Looks like the typical case where a simple minded approach will fail badly very quickly ... Show quoted text
:-) Show quoted text
> If you're very clever you might be able to write a simpler parser which > works so long as there's no defaults and decide whether to use that or > the PPI one with something as simple as /=|where|when/. > > OTOH you could speed up the load time of PPI.
I guess if I were very clever ... ;-) As I said to Buddy, as far as I am concerned you may well close this "bug" report. Thanks for your time answering (and every thing else) and take care, Fritz -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch
Show quoted text
> We brought it up recently in email, but of course it's been in the POD > (where it's described as a "go really fast" switch :-D ) forever. > But, yeah, I went scrambling for a GitHub issue to link to as well, > and was just as surprised as you to find there isn't one. I'll > take the info we tossed around in email and condense that to a new > issue--I should have time this weekend, now that I've done my > PerlMongers presentation (on Method::Signatures, as it happens). > I'll link it back here once I've created it.
Created as GitHub #73. https://github.com/schwern/method-signatures/issues/73 Just noting this here for posterity.