- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
serializable anonfun cost: 300K
Sat, 2009-11-28, 20:08
One thing I discovered when writing the abstract function classes is
that making anonymous functions serializable adds a lot of weight. The
only difference between these two builds is that the smaller one does
not make them serializable.
-rw-r--r-- 1 paulp admin 8538806 Nov 28 10:54 scala-compiler.jar
-rw-r--r-- 1 paulp admin 4846720 Nov 28 10:54 scala-library.jar
13385526 bytes
-rw-r--r-- 1 paulp admin 8303042 Nov 28 10:56 scala-compiler.jar
-rw-r--r-- 1 paulp admin 4768521 Nov 28 10:56 scala-library.jar
13071563 bytes
313K or 2.3% of the jars is going to this purpose. I never know how if
my own usage patterns are representative of much, but I have zero need
to serialize my $anonfuns. Is this something that has to be on by
default, and that the scala jars need to be built with? Could it perhaps
be put behind a -X fence?
Sat, 2009-11-28, 20:57
#2
Re: serializable anonfun cost: 300K
On Sat, Nov 28, 2009 at 11:31 AM, Ismael Juma wrote:
> On Sat, 2009-11-28 at 11:08 -0800, Paul Phillips wrote:
>> 313K or 2.3% of the jars is going to this purpose. I never know how if
>> my own usage patterns are representative of much, but I have zero need
>> to serialize my $anonfuns. Is this something that has to be on by
>> default, and that the scala jars need to be built with? Could it perhaps
>> be put behind a -X fence?
>
> As I understand, this is very useful for frameworks like Wicket. You can
> verify that by looking at a number of bugs filed by Jan Kriesten in the
> area.
I've used this feature when I wrote a wrapper for Hadoop. In practice
though, the constraints on when anonfuns can be made serializable are
so stringent that you need a compiler plugin to force more things to
be serializable anyway. (Specifically, there's a requirement that the
static type of all elements in the closure be serializable, which adds
no type safety but a lot of pain...)
So, a -X fence is fine by me. Especially if said -X fence would make
*all* anonfuns serializable, and not just a few. (Or maybe if it had a
switch?)
Anyway, if it interests anyone, here's a discussion on a ticket I
filed way back from 2.7.2 days:
https://lampsvn.epfl.ch/trac/scala/ticket/1116
Mon, 2009-11-30, 05:27
#3
Re: serializable anonfun cost: 300K
Serialization of functions is hyper-important to Lift.
On Sat, Nov 28, 2009 at 11:08 AM, Paul Phillips <paulp@improving.org> wrote:
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
On Sat, Nov 28, 2009 at 11:08 AM, Paul Phillips <paulp@improving.org> wrote:
One thing I discovered when writing the abstract function classes is
that making anonymous functions serializable adds a lot of weight. The
only difference between these two builds is that the smaller one does
not make them serializable.
-rw-r--r-- 1 paulp admin 8538806 Nov 28 10:54 scala-compiler.jar
-rw-r--r-- 1 paulp admin 4846720 Nov 28 10:54 scala-library.jar
13385526 bytes
-rw-r--r-- 1 paulp admin 8303042 Nov 28 10:56 scala-compiler.jar
-rw-r--r-- 1 paulp admin 4768521 Nov 28 10:56 scala-library.jar
13071563 bytes
313K or 2.3% of the jars is going to this purpose. I never know how if
my own usage patterns are representative of much, but I have zero need
to serialize my $anonfuns. Is this something that has to be on by
default, and that the scala jars need to be built with? Could it perhaps
be put behind a -X fence?
--
Paul Phillips | Every normal man must be tempted at times
Analgesic | to spit on his hands, hoist the black flag,
Empiricist | and begin to slit throats.
ha! spill, pupil | -- H. L. Mencken
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
Mon, 2009-11-30, 09:37
#4
Re: serializable anonfun cost: 300K
Hi Paul,
Given the number of tickets and grieve we had in the area I would only
touch this with a very long pole.
On Sat, 2009-11-28 at 11:08 -0800, Paul Phillips wrote:
> 313K or 2.3% of the jars is going to this purpose. I never know how if
> my own usage patterns are representative of much, but I have zero need
> to serialize my $anonfuns. Is this something that has to be on by
> default, and that the scala jars need to be built with? Could it perhaps
> be put behind a -X fence?
As I understand, this is very useful for frameworks like Wicket. You can
verify that by looking at a number of bugs filed by Jan Kriesten in the
area.
Best,
Ismael