Is there a way to make lazy vals use custom synchronization scheme?

68 views
Skip to first unread message

Eugene Burmako

unread,
Feb 7, 2013, 4:31:12 AM2/7/13
to scala-internals, hubert.pl...@epfl.ch
synchronized(this) implicitly emitted by lazy val codegen provides an
excellent opportunity for deadlocks.

Eugene Burmako

unread,
Feb 7, 2013, 4:32:32 AM2/7/13
to scala-internals
The same questions goes to local objects.

Eugene Burmako

unread,
Feb 7, 2013, 4:42:55 AM2/7/13
to scala-internals
So far I have only one idea - explicitly force initialization of all
lazy stuff in JavaUniverse.init. Very tedious, but at least that will
make deadlocks impossible.

Hubert Plociniczak

unread,
Feb 7, 2013, 5:27:46 AM2/7/13
to scala-internals
... I realize I didn't reply to internals.

On 02/07/2013 11:06 AM, Hubert Plociniczak wrote:
On 02/07/2013 10:31 AM, Eugene Burmako wrote:
synchronized(this) implicitly emitted by lazy val codegen provides an
excellent opportunity for deadlocks.

Hubert Plociniczak

unread,
Feb 7, 2013, 5:30:18 AM2/7/13
to scala-i...@googlegroups.com
I don't know much what's going on in JavaUniverse but won't you have the
same problems like in Definitions?
I think Paul or someone else wanted to do s/lazy val/def there and failed.

Eugene Burmako

unread,
Feb 7, 2013, 5:34:49 AM2/7/13
to <scala-internals@googlegroups.com>
Yes, definitions are the part of the problem. Do you remember why exactly he failed?



--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-internals+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Hubert Plociniczak

unread,
Feb 7, 2013, 6:17:38 AM2/7/13
to scala-i...@googlegroups.com
On 02/07/2013 11:34 AM, Eugene Burmako wrote:
Yes, definitions are the part of the problem. Do you remember why exactly he failed?

Sorry, I don't recall the details now. Must be somewhere on the mailing list (try old -devel one).



On 7 February 2013 11:30, Hubert Plociniczak <hubert.pl...@epfl.ch> wrote:
I don't know much what's going on in JavaUniverse but won't you have the same problems like in Definitions?
I think Paul or someone else wanted to do s/lazy val/def there and failed.

On 02/07/2013 10:42 AM, Eugene Burmako wrote:
So far I have only one idea - explicitly force initialization of all
lazy stuff in JavaUniverse.init. Very tedious, but at least that will
make deadlocks impossible.

On Feb 7, 10:32 am, Eugene Burmako <eugene.burm...@epfl.ch> wrote:
The same questions goes to local objects.

On Feb 7, 10:31 am, Eugene Burmako <eugene.burm...@epfl.ch> wrote:







synchronized(this) implicitly emitted by lazy val codegen provides an
excellent opportunity for deadlocks.

--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.

Paul Phillips

unread,
Feb 7, 2013, 12:23:20 PM2/7/13
to scala-i...@googlegroups.com

On Thu, Feb 7, 2013 at 2:30 AM, Hubert Plociniczak <hubert.pl...@epfl.ch> wrote:
I think Paul or someone else wanted to do s/lazy val/def there and failed.

It was s/lazy // which I tried, because all those lazies are only to get the initialization order right, not because you actually care about deferring the computation. But it was too difficult. What I left as a future ambition is to have a means to write "locally lazy" vals - lazy in terms of what order they unroll during the initialization method, but after init is over they are all regular eager vals, i.e. no synchronization.

Paul Phillips

unread,
Feb 7, 2013, 12:27:42 PM2/7/13
to scala-i...@googlegroups.com
Oh, I just noticed the subject line of this thread, "Is there a way to make lazy vals use custom synchronization scheme?" It's something I've wanted to do for a long time, but no. See


possibly among others. My idea was to do it something like the pattern matcher uses MatchStrategy: if a __lazy in scope defines all the particulars of what the "lazy" means in "lazy val". But that idea predates macros, and macro annotations are probably a better way.

√iktor Ҡlang

unread,
Feb 7, 2013, 3:01:18 PM2/7/13
to scala-i...@googlegroups.com
On Thu, Feb 7, 2013 at 10:42 AM, Eugene Burmako <eugene....@epfl.ch> wrote:
So far I have only one idea - explicitly force initialization of all
lazy stuff in JavaUniverse.init. Very tedious, but at least that will
make deadlocks impossible.

Maybe a dumb question, but what's the point of making them lazy vals then?

Cheers,
 

On Feb 7, 10:32 am, Eugene Burmako <eugene.burm...@epfl.ch> wrote:
> The same questions goes to local objects.
>
> On Feb 7, 10:31 am, Eugene Burmako <eugene.burm...@epfl.ch> wrote:
>
>
>
>
>
>
>
> > synchronized(this) implicitly emitted by lazy val codegen provides an
> > excellent opportunity for deadlocks.

--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
Viktor Klang
Director of Engineering

Typesafe - The software stack for applications that scale
Twitter: @viktorklang

Eugene Burmako

unread,
Feb 7, 2013, 3:07:12 PM2/7/13
to <scala-internals@googlegroups.com>
Mostly initialization order issues, since they are a part of a big cake with non-linear initialization control flow. Definitions in Definitions.scala are lazy probably because of symbol initialization issues.

√iktor Ҡlang

unread,
Feb 7, 2013, 3:13:26 PM2/7/13
to scala-i...@googlegroups.com
On Thu, Feb 7, 2013 at 9:07 PM, Eugene Burmako <eugene....@epfl.ch> wrote:
Mostly initialization order issues, since they are a part of a big cake with non-linear initialization control flow. Definitions in Definitions.scala are lazy probably because of symbol initialization issues.

In my experience, interdependicies between lazy vals is a deadlock waiting to wreak havoc in production.
There has to be another way.
Reply all
Reply to author
Forward
0 new messages