Object Storage Model: has anybody real-world experience?
Raffaello Giulietti
raffaello.giulietti at supsi.ch
Wed Mar 16 18:16:50 UTC 2016
On 2016-03-16 15:07, Stefan Marr wrote:
> Hi Raffaello:
>
>
>> On 16 Mar 2016, at 14:21, Raffaello Giulietti <raffaello.giulietti at supsi.ch> wrote:
>>
>> More generally, to implement large contiguous heterogeneous collections in dynamically typed languages the OSM does not seem to be of great help: for the elements, one either has to resort to boxed primitives here and there or has to maintain two equally sized (large) Java arrays, one for potential primitives and one for potential objects. Or implement more complex and slower “strategies" to maintain mixed-mode cases.
>
> What you describe sounds very similar to the Storage Strategy work of the PyPy guys [1,2].
> This optimization is not provided by the Truffle object model since it is orthogonal to objects.
>
> However, TruffleSOM, SOMns, JRuby+Truffle and other Truffle-based languages use it as well.
> So, it might be useful to push that as something reusable into the framework. Don’t think anyone looked into making that happening specifically though.
>
> In TruffleSOM, you can have a look at SArray [3] and the #at: primitive [4] to get a basic impression of how it works.
>
OK, thanks.
>>> In SOMns, i.e., Newspeak, I did not implement the Truffle object model yet, because I got a very similar custom object model (still from my SOM Smalltalk), and in Newspeak, I actually need another version of it for not objects, but classes, because of the inner class semantics.
>>>
>>
>> As far as I remember, classes in Newspeak are very light-weight objects of predictable shape: not sure if they need the flexibility of the OSM. (Many years ago, long before Graal/Truffle, I tried to implement Newspeak on the JVM with the then upcoming invokedynamic instruction on early-access JDK7 platforms but had to gave up to preserve my nerves.)
>
> The problem with classes in Newspeak is that you essentially need to decouple their identity and their structure, otherwise you won’t get good results with optimization.
> If you see many different class objects, which is typically the case with inner classes in Newspeak, you would normally abort optimizing/go to a megamorphic case.
> If you decouple the identity and the structure, you can still optimize nicely for the same structure.
> SOMns does just that and thereby Newspeak is among the fastest Truffle languages.
>
I think I don't get your point: my remembrances are that NS classes are
simple triples holding a reference to the superclass, a reference to the
enclosing object and a reference to the metadata info (ivars, methods +
other ancillary data), all "finals" in Java jargon. Is this what you
mean by decoupling identity and structure?
> Bye the way, are you working on a Truffle language?
>
Yes, I'm experimenting with Smalltalk in my spare time. However, the
environment I'm trying to build is not the classical Smalltalk image
model but something more akin to Gemstone, i.e., with a persistence
engine built-in and a snapshot isolation model for transactional processing.
Greetings
Raffaello
More information about the graal-dev
mailing list