This page is no longer maintained — Please continue to the home page at www.scala-lang.org

serializable anonfun cost: 300K

4 replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

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?

ijuma
Joined: 2008-08-20,
User offline. Last seen 22 weeks 2 days ago.
Re: serializable anonfun cost: 300K

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

David Hall 4
Joined: 2009-08-21,
User offline. Last seen 42 years 45 weeks ago.
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

David Pollak
Joined: 2008-12-16,
User offline. Last seen 42 years 45 weeks ago.
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:
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
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
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.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland