[ANN] Pharo bootstrap

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
43 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

Brad Selfridge
Has anyone looked at the VASmalltalk Envy Packager. It let's one decide whether you want to package a headless or UI image. It then allows one to define packaging instructions, that are saved with the new application), that get fed into the packager. The instructions define prerequisite apps, un-referenced methods, etc. When one defines a new application (package), one can define prerequisite applications that have to be installed before the current application is installed. This prerequisite chain is used in loading the application from Envy and in packaging. Seems to work fairly well. Doesn't take too long to package an app and give the developer pretty fine control over the packaging and loading process.
Brad Selfridge
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Pharo bootstrap

Pharo Smalltalk Developers mailing list
In reply to this post by philippeback
On 20 January 2016 at 16:36, [hidden email] <[hidden email]> wrote:

>
>
> On Wed, Jan 20, 2016 at 4:19 PM, Peter H. Meadows via Pharo-dev
> <[hidden email]> wrote:
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: "Peter H. Meadows" <[hidden email]>
>> To: Pharo Development List <[hidden email]>
>> Cc:
>> Date: Wed, 20 Jan 2016 15:17:59 +0000
>> Subject: Re: [Pharo-dev] [ANN] Pharo bootstrap
>> Cool. Any chance someone can explain for beginners to understand
>> what's going on here?
>> Why is cleaning the image not as simple as running it and deleting any
>> object that wasn't used?
>
>
> The point is not to clean but to start with an empty object engine and fill
> it in with the minimum required core.

But why should this not end up with the same end result?
One way is to start with nothing, and only add stuff we need to make
it run/boot, and the other way is to start with what we have, and
remove anything that is not needed to make it run/boot. In both cases
don't you end up with the same thing?


> Currently, the image is the result of an evolutionary process and rebuilding
> it from zero was not possible.

I wonder if they thought about this when they created the first image.
Didn't they think 'hey, we should really have a way for anyone to
create new images from nothing'? Or was it just that they didn't get
around to making this tool?

> This maes it possible to audit the whole build process, create different
> base image for various purposes (very small, headless with no UI objects at
> all, using the object engine in a completely different way that is used
> today).
>
> That makes the image the result of a fully reproducible process, from a file
> of zero bytes, to a file with a working image.
>
> That would make us master the whole chain. Today, there is still black magic
> in the image, due to the history.
>
> That's an exciting development. For example, in C, one compiles all files,
> and links, giving the exe. All that from a file of zero size. We will be
> able to do the same kind of thing at the image level.
>
> Also, this allows to experiment with new low level mechanisms. This is
> currently not possible since it makes us like performing surgery on our own
> brain. Also, the Oz-inspired system will help in exploring other image
> memories (small or large) and manipulate them as entities. At this point,
> this is also not common pratice.
>
> HTH
> Phil, wishing to master the mitosis competency...
>>
>>
>> (Thanks in advance)
>>
>> On 20 January 2016 at 12:52, Guillermo Polito <[hidden email]>
>> wrote:
>> > Well, there is no formal specification… But I could summarize the
>> > features
>> > as follows (and as Christophe points mostly out)
>> >
>> > OzVM supports having two images in logically separated spaces. This
>> > separation is achieved by using the free bit in the object header. Thus
>> > we
>> > support only two spaces by now.
>> >
>> > - The main addition is actually a new primitive:
>> > #resumeFromSpecialObjectsArray that receives an special objects array as
>> > argument and:
>> >     - resumes the execution from the active process of such array
>> >     - on context switch, if the VM is running from a second special
>> > objects
>> > array, it will return to the first one instead.
>> >
>> > - fixes to primitives/bytecodes that assume a single special objects
>> > array.
>> > e.g.,
>> >    - #someObject and #nextObject should only iterate objects from the
>> > correct “space”
>> >    - #isNil comparisons should take the correct nil
>> >    - the GC should set the correct nil object on Weak containers
>> >
>> > The extensions I made are about 20 overrides to StackPrimitive and
>> > NewObjectMemory methods.
>> >
>> > The rest is implemented completely on image side. We use mirror
>> > primitives
>> > to manipulate objects from other space (as each image/space has it’s own
>> > selector table).
>> >
>> > I have in my long TODO list see if the "clever hack” I did can be
>> > supported
>> > in a nice manner on top of Spur’s segmented memory. However, I should
>> > stop
>> > commencing new projects and start finishing them :P.
>> >
>> > On 20 ene 2016, at 9:03 a.m., Christophe Demarey
>> > <[hidden email]> wrote:
>> >
>> > Hi Eliot,
>> >
>> > Le 19 janv. 2016 à 19:29, Eliot Miranda a écrit :
>> >
>> > Hi All,
>> >
>> >     great news!  Where can I read a specification of the Oz VM
>> > facilities?
>> >
>> >
>> > I do not know all the details of the Oz VM but basically, it is a
>> > standard
>> > stack interpreter vm specialized to be able to run 2 images at the same
>> > time
>> > on top of it.
>> > Guillermo made it possible by using one available bit in the object
>> > header
>> > of objects to mark the ownership of an object (e.g. is my object from
>> > image1
>> > or image2?). Then, he mainly had to specialize VM primitives dealing
>> > with
>> > objects retrieval from memory. By example, he had to modify the garbage
>> > collector to set the right nil instance (yes, we have 2 images so 2 nil
>> > instances. we need to take the one of the active image) when an object
>> > is
>> > garbage collected; the primitive someObject has to return an object from
>> > the
>> > active image, etc.
>> > There is also a way to switch execution from an image to the other just
>> > by
>> > switching the special objects array reference.
>> >
>> > You can find some information in:
>> > https://guillep.github.io/files/publications/Poli15Thesis.pdf.
>> > The Oz code is in http://smalltalkhub.com/#!/~Guille/ObjectSpace and in
>> > https://github.com/guillep/OzVM
>> > The current implementation uses Cog  6.6.1and OzVM-GuillermoPolito.22.
>> > I do not know if Guille has a more formal specification of the Oz VM.
>> >
>> > If you have advices on what is the best way to handle two distinct
>> > object
>> > (memory) spaces in Spur, they will be welcomed :)
>> >
>> > Cheers,
>> > Christophe
>> >
>> >
>> > _,,,^..^,,,_ (phone)
>> >
>> > On Jan 19, 2016, at 6:29 AM, Christophe Demarey
>> > <[hidden email]> wrote:
>> >
>> > Hi all,
>> >
>> > In case you do not know, we work on bootstrapping Pharo, i.e. create a
>> > Pharo
>> > image from sources, not based on a previous image (well, we use a pharo
>> > image to produce it but no code / state from it).
>> >
>> > This process will allow to define a minimal Pharo kernel (currently 52
>> > packages but we could have it far smaller) and to modularize the whole
>> > image
>> > (currently packages have too much dependencies on packages already
>> > loaded
>> > into the image).
>> > The bootstrap process also allows to write down the recipe to initialize
>> > a
>> > new image from scratch (some code is missing in the image or is wrong).
>> > In
>> > addition, I think we will clean a lot of historical objects that are not
>> > used anymore.
>> >
>> > With the amazing work done by Guillermo Polito during his Phd (around
>> > Espell, Oz):
>> > https://guillep.github.io/files/publications/Poli15Thesis.pdf,
>> > we succeeded to get a first prototype of a bootstraped Pharo 5 image
>> > (from
>> > 5.392).
>> > This prototype is able to run an eval command line handler and to log
>> > output
>> > / errors. Not all classes are yet initialized and you cannot yet save /
>> > restart this image but it is a big step forward.
>> > It is a 4 mb image (could be half the size without unicode data). You
>> > can
>> > download it at:
>> >
>> > http://chercheurs.lille.inria.fr/~demarey/pmwiki/pub/pharo-bootstrap/pharo-bootstrap.zip.
>> >
>> > Next steps are to have a bootstrapped image fully working, then to load
>> > packages on top of it (like network, sunit) to produce a minimal image.
>> > Then, we need to implement an Oz VM on top of Spur.
>> > After that, we need to work on a reliable way to build the bootstrap
>> > (not
>> > too sensitive to changes in the image).
>> >
>> > Christophe.
>> >
>> > -------
>> > demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
>> > ../pharo
>> > bootstrap.image --no-default-preferences eval "1 + 1"
>> > 2
>> > demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
>> > ../pharo
>> > bootstrap.image --no-default-preferences eval "'a' , 'b'"
>> > 'ab'
>> > demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
>> > ../pharo
>> > bootstrap.image --no-default-preferences eval "1 / 0"
>> > ZeroDivide
>> > SmallInteger>>/
>> > UndefinedObject>>DoIt
>> > OpalCompiler>>evaluate
>> > OpalCompiler(AbstractCompiler)>>evaluate:
>> > SmalltalkImage>>evaluate:
>> >
>> > EvaluateCommandLineHandler>>no (source is Undeclared)
>> > no source in EvaluateCommandLineHandler>>evaluate: in Block: no source
>> > BlockClosure>>on:do:
>> > EvaluateCommandLineHandler>>evaluate:
>> > EvaluateCommandLineHandler>>evaluateArguments
>> > EvaluateCommandLineHandler>>activate
>> > EvaluateCommandLineHandler class(CommandLineHandler
>> > class)>>activateWith:
>> >
>> > BasicCommandLineHandler>>no (source is Undeclared)
>> > no source in
>> > PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand: in
>> > Block: no source
>> > BlockClosure>>on:do:
>> > PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand:
>> > PharoCommandLineHandler(BasicCommandLineHandler)>>handleSubcommand
>> > PharoCommandLineHandler(BasicCommandLineHandler)>>handleArgument:
>> >
>> > BasicCommandLineHandler>>no (source is Undeclared)
>> > no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activate
>> > in
>> > Block: no source
>> > BlockClosure>>on:do:
>> > PharoCommandLineHandler(BasicCommandLineHandler)>>activate
>> > PharoCommandLineHandler>>activate
>> > PharoCommandLineHandler class(CommandLineHandler class)>>activateWith:
>> >
>> > PharoCommandLineHandler class>>no (source is Undeclared)
>> > no source in PharoCommandLineHandler class>>activateWith: in Block: no
>> > source
>> > NonInteractiveUIManager(UIManager)>>defer:
>> > PharoCommandLineHandler class>>activateWith:
>> > no source in BasicCommandLineHandler>>activateSubCommand: in Block: no
>> > source
>> > BlockClosure>>on:do:
>> > BasicCommandLineHandler>>activateSubCommand:
>> > BasicCommandLineHandler>>handleSubcommand
>> > BasicCommandLineHandler>>handleArgument:
>> > no source in BasicCommandLineHandler>>activate in Block: no source
>> >
>> > SmallInteger>>no (source is Undeclared)
>> >
>> > UndefinedObject>>no (source is Undeclared)
>> >
>> > AbstractCompiler>>no (source is Undeclared)
>> >
>> > SmalltalkImage>>no (source is Undeclared)
>> >
>> > BlockClosure>>no (source is Undeclared)
>> >
>> > EvaluateCommandLineHandler>>no (source is Undeclared)
>> >
>> > EvaluateCommandLineHandler>>no (source is Undeclared)
>> >
>> > CommandLineHandler class>>no (source is Undeclared)
>> >
>> > BasicCommandLineHandler>>no (source is Undeclared)
>> >
>> > BasicCommandLineHandler>>no (source is Undeclared)
>> >
>> > PharoCommandLineHandler>>no (source is Undeclared)
>> >
>> > UIManager>>no (source is Undeclared)
>> >
>> > UndefinedObject>>no (source is Undeclared)
>> >
>> > CommandLineUIManager>>no (source is Undeclared)
>> >
>> > SmalltalkImage>>no (source is Undeclared)
>> >
>> > DelayMicrosecondScheduler>>no (source is Undeclared)
>> >
>> > BlockClosure>>no (source is Undeclared)
>> >
>> > SmalltalkImage>>no (source is Undeclared)
>> >
>> > WeakArray class>>no (source is Undeclared)
>> >
>> >
>> > ps: source cannot be displayed because there is no formatter available
>> > in
>> > the bootstrap
>> >
>> >
>> >
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Pharo bootstrap

demarey
Hi Peter,

Le 21 janv. 2016 à 09:49, Peter H. Meadows via Pharo-dev a écrit :


De : "Peter H. Meadows" <[hidden email]>
Date : 21 janvier 2016 09:48:23 HNEC
À : Pharo Development List <[hidden email]>
Objet : Rép : [Pharo-dev] [ANN] Pharo bootstrap


On 20 January 2016 at 16:36, [hidden email] <[hidden email]> wrote:


On Wed, Jan 20, 2016 at 4:19 PM, Peter H. Meadows via Pharo-dev
<[hidden email]> wrote:



---------- Forwarded message ----------
From: "Peter H. Meadows" <[hidden email]>
To: Pharo Development List <[hidden email]>
Cc:
Date: Wed, 20 Jan 2016 15:17:59 +0000
Subject: Re: [Pharo-dev] [ANN] Pharo bootstrap
Cool. Any chance someone can explain for beginners to understand
what's going on here?
Why is cleaning the image not as simple as running it and deleting any
object that wasn't used?


The point is not to clean but to start with an empty object engine and fill
it in with the minimum required core.

But why should this not end up with the same end result?
One way is to start with nothing, and only add stuff we need to make
it run/boot, and the other way is to start with what we have, and
remove anything that is not needed to make it run/boot. In both cases
don't you end up with the same thing?

in theory but in practice it is more difficult to clean, especially when you are not aware of what needs to be cleaned.
Also, you have in a current image objects that have been modified by scripts that are not (anymore) available in the image. How do you reach the same state? The bootstrap forces you to have all the code to produce this state. It also checks some initialization code that has been run a couple of times, maybe years ago, and that does not work anymore.


Currently, the image is the result of an evolutionary process and rebuilding
it from zero was not possible.

I wonder if they thought about this when they created the first image.
Didn't they think 'hey, we should really have a way for anyone to
create new images from nothing'? Or was it just that they didn't get
around to making this tool?

This maes it possible to audit the whole build process, create different
base image for various purposes (very small, headless with no UI objects at
all, using the object engine in a completely different way that is used
today).

yes, it will enforce a lot modularity of Pharo. By example, you could have a version of Pharo without Traits or with a different kind of collections.

That makes the image the result of a fully reproducible process, from a file
of zero bytes, to a file with a working image.

That would make us master the whole chain. Today, there is still black magic
in the image, due to the history.

That's an exciting development. For example, in C, one compiles all files,
and links, giving the exe. All that from a file of zero size. We will be
able to do the same kind of thing at the image level.

Also, this allows to experiment with new low level mechanisms. This is
currently not possible since it makes us like performing surgery on our own
brain. Also, the Oz-inspired system will help in exploring other image
memories (small or large) and manipulate them as entities. At this point,
this is also not common pratice.

HTH
Phil, wishing to master the mitosis competency...


(Thanks in advance)

On 20 January 2016 at 12:52, Guillermo Polito <[hidden email]>
wrote:
Well, there is no formal specification… But I could summarize the
features
as follows (and as Christophe points mostly out)

OzVM supports having two images in logically separated spaces. This
separation is achieved by using the free bit in the object header. Thus
we
support only two spaces by now.

- The main addition is actually a new primitive:
#resumeFromSpecialObjectsArray that receives an special objects array as
argument and:
   - resumes the execution from the active process of such array
   - on context switch, if the VM is running from a second special
objects
array, it will return to the first one instead.

- fixes to primitives/bytecodes that assume a single special objects
array.
e.g.,
  - #someObject and #nextObject should only iterate objects from the
correct “space”
  - #isNil comparisons should take the correct nil
  - the GC should set the correct nil object on Weak containers

The extensions I made are about 20 overrides to StackPrimitive and
NewObjectMemory methods.

The rest is implemented completely on image side. We use mirror
primitives
to manipulate objects from other space (as each image/space has it’s own
selector table).

I have in my long TODO list see if the "clever hack” I did can be
supported
in a nice manner on top of Spur’s segmented memory. However, I should
stop
commencing new projects and start finishing them :P.

On 20 ene 2016, at 9:03 a.m., Christophe Demarey
<[hidden email]> wrote:

Hi Eliot,

Le 19 janv. 2016 à 19:29, Eliot Miranda a écrit :

Hi All,

   great news!  Where can I read a specification of the Oz VM
facilities?


I do not know all the details of the Oz VM but basically, it is a
standard
stack interpreter vm specialized to be able to run 2 images at the same
time
on top of it.
Guillermo made it possible by using one available bit in the object
header
of objects to mark the ownership of an object (e.g. is my object from
image1
or image2?). Then, he mainly had to specialize VM primitives dealing
with
objects retrieval from memory. By example, he had to modify the garbage
collector to set the right nil instance (yes, we have 2 images so 2 nil
instances. we need to take the one of the active image) when an object
is
garbage collected; the primitive someObject has to return an object from
the
active image, etc.
There is also a way to switch execution from an image to the other just
by
switching the special objects array reference.

You can find some information in:
https://guillep.github.io/files/publications/Poli15Thesis.pdf.
The Oz code is in http://smalltalkhub.com/#!/~Guille/ObjectSpace and in
https://github.com/guillep/OzVM
The current implementation uses Cog  6.6.1and OzVM-GuillermoPolito.22.
I do not know if Guille has a more formal specification of the Oz VM.

If you have advices on what is the best way to handle two distinct
object
(memory) spaces in Spur, they will be welcomed :)

Cheers,
Christophe


_,,,^..^,,,_ (phone)

On Jan 19, 2016, at 6:29 AM, Christophe Demarey
<[hidden email]> wrote:

Hi all,

In case you do not know, we work on bootstrapping Pharo, i.e. create a
Pharo
image from sources, not based on a previous image (well, we use a pharo
image to produce it but no code / state from it).

This process will allow to define a minimal Pharo kernel (currently 52
packages but we could have it far smaller) and to modularize the whole
image
(currently packages have too much dependencies on packages already
loaded
into the image).
The bootstrap process also allows to write down the recipe to initialize
a
new image from scratch (some code is missing in the image or is wrong).
In
addition, I think we will clean a lot of historical objects that are not
used anymore.

With the amazing work done by Guillermo Polito during his Phd (around
Espell, Oz):
https://guillep.github.io/files/publications/Poli15Thesis.pdf,
we succeeded to get a first prototype of a bootstraped Pharo 5 image
(from
5.392).
This prototype is able to run an eval command line handler and to log
output
/ errors. Not all classes are yet initialized and you cannot yet save /
restart this image but it is a big step forward.
It is a 4 mb image (could be half the size without unicode data). You
can
download it at:

http://chercheurs.lille.inria.fr/~demarey/pmwiki/pub/pharo-bootstrap/pharo-bootstrap.zip.

Next steps are to have a bootstrapped image fully working, then to load
packages on top of it (like network, sunit) to produce a minimal image.
Then, we need to implement an Oz VM on top of Spur.
After that, we need to work on a reliable way to build the bootstrap
(not
too sensitive to changes in the image).

Christophe.

-------
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
../pharo
bootstrap.image --no-default-preferences eval "1 + 1"
2
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
../pharo
bootstrap.image --no-default-preferences eval "'a' , 'b'"
'ab'
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
../pharo
bootstrap.image --no-default-preferences eval "1 / 0"
ZeroDivide
SmallInteger>>/
UndefinedObject>>DoIt
OpalCompiler>>evaluate
OpalCompiler(AbstractCompiler)>>evaluate:
SmalltalkImage>>evaluate:

EvaluateCommandLineHandler>>no (source is Undeclared)
no source in EvaluateCommandLineHandler>>evaluate: in Block: no source
BlockClosure>>on:do:
EvaluateCommandLineHandler>>evaluate:
EvaluateCommandLineHandler>>evaluateArguments
EvaluateCommandLineHandler>>activate
EvaluateCommandLineHandler class(CommandLineHandler
class)>>activateWith:

BasicCommandLineHandler>>no (source is Undeclared)
no source in
PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand: in
Block: no source
BlockClosure>>on:do:
PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand:
PharoCommandLineHandler(BasicCommandLineHandler)>>handleSubcommand
PharoCommandLineHandler(BasicCommandLineHandler)>>handleArgument:

BasicCommandLineHandler>>no (source is Undeclared)
no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activate
in
Block: no source
BlockClosure>>on:do:
PharoCommandLineHandler(BasicCommandLineHandler)>>activate
PharoCommandLineHandler>>activate
PharoCommandLineHandler class(CommandLineHandler class)>>activateWith:

PharoCommandLineHandler class>>no (source is Undeclared)
no source in PharoCommandLineHandler class>>activateWith: in Block: no
source
NonInteractiveUIManager(UIManager)>>defer:
PharoCommandLineHandler class>>activateWith:
no source in BasicCommandLineHandler>>activateSubCommand: in Block: no
source
BlockClosure>>on:do:
BasicCommandLineHandler>>activateSubCommand:
BasicCommandLineHandler>>handleSubcommand
BasicCommandLineHandler>>handleArgument:
no source in BasicCommandLineHandler>>activate in Block: no source

SmallInteger>>no (source is Undeclared)

UndefinedObject>>no (source is Undeclared)

AbstractCompiler>>no (source is Undeclared)

SmalltalkImage>>no (source is Undeclared)

BlockClosure>>no (source is Undeclared)

EvaluateCommandLineHandler>>no (source is Undeclared)

EvaluateCommandLineHandler>>no (source is Undeclared)

CommandLineHandler class>>no (source is Undeclared)

BasicCommandLineHandler>>no (source is Undeclared)

BasicCommandLineHandler>>no (source is Undeclared)

PharoCommandLineHandler>>no (source is Undeclared)

UIManager>>no (source is Undeclared)

UndefinedObject>>no (source is Undeclared)

CommandLineUIManager>>no (source is Undeclared)

SmalltalkImage>>no (source is Undeclared)

DelayMicrosecondScheduler>>no (source is Undeclared)

BlockClosure>>no (source is Undeclared)

SmalltalkImage>>no (source is Undeclared)

WeakArray class>>no (source is Undeclared)


ps: source cannot be displayed because there is no formatter available
in
the bootstrap











smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Pharo bootstrap

Sven Van Caekenberghe-2
In reply to this post by Pharo Smalltalk Developers mailing list
This is a much more complex and challenging subject that you might think.

There has been a lot of work done on this for many years, many approaches have been tried.

I am pretty sure that the people behind the Pharo Bootstrap project are aware of the existing literature.

> On 21 Jan 2016, at 09:49, Peter H. Meadows via Pharo-dev <[hidden email]> wrote:
>
>
> From: "Peter H. Meadows" <[hidden email]>
> Subject: Re: [Pharo-dev] [ANN] Pharo bootstrap
> Date: 21 January 2016 at 09:48:23 GMT+1
> To: Pharo Development List <[hidden email]>
>
>
> On 20 January 2016 at 16:36, [hidden email] <[hidden email]> wrote:
>>
>>
>> On Wed, Jan 20, 2016 at 4:19 PM, Peter H. Meadows via Pharo-dev
>> <[hidden email]> wrote:
>>>
>>>
>>>
>>> ---------- Forwarded message ----------
>>> From: "Peter H. Meadows" <[hidden email]>
>>> To: Pharo Development List <[hidden email]>
>>> Cc:
>>> Date: Wed, 20 Jan 2016 15:17:59 +0000
>>> Subject: Re: [Pharo-dev] [ANN] Pharo bootstrap
>>> Cool. Any chance someone can explain for beginners to understand
>>> what's going on here?
>>> Why is cleaning the image not as simple as running it and deleting any
>>> object that wasn't used?
>>
>>
>> The point is not to clean but to start with an empty object engine and fill
>> it in with the minimum required core.
>
> But why should this not end up with the same end result?
> One way is to start with nothing, and only add stuff we need to make
> it run/boot, and the other way is to start with what we have, and
> remove anything that is not needed to make it run/boot. In both cases
> don't you end up with the same thing?
>
>
>> Currently, the image is the result of an evolutionary process and rebuilding
>> it from zero was not possible.
>
> I wonder if they thought about this when they created the first image.
> Didn't they think 'hey, we should really have a way for anyone to
> create new images from nothing'? Or was it just that they didn't get
> around to making this tool?
>
>> This maes it possible to audit the whole build process, create different
>> base image for various purposes (very small, headless with no UI objects at
>> all, using the object engine in a completely different way that is used
>> today).
>>
>> That makes the image the result of a fully reproducible process, from a file
>> of zero bytes, to a file with a working image.
>>
>> That would make us master the whole chain. Today, there is still black magic
>> in the image, due to the history.
>>
>> That's an exciting development. For example, in C, one compiles all files,
>> and links, giving the exe. All that from a file of zero size. We will be
>> able to do the same kind of thing at the image level.
>>
>> Also, this allows to experiment with new low level mechanisms. This is
>> currently not possible since it makes us like performing surgery on our own
>> brain. Also, the Oz-inspired system will help in exploring other image
>> memories (small or large) and manipulate them as entities. At this point,
>> this is also not common pratice.
>>
>> HTH
>> Phil, wishing to master the mitosis competency...
>>>
>>>
>>> (Thanks in advance)
>>>
>>> On 20 January 2016 at 12:52, Guillermo Polito <[hidden email]>
>>> wrote:
>>>> Well, there is no formal specification… But I could summarize the
>>>> features
>>>> as follows (and as Christophe points mostly out)
>>>>
>>>> OzVM supports having two images in logically separated spaces. This
>>>> separation is achieved by using the free bit in the object header. Thus
>>>> we
>>>> support only two spaces by now.
>>>>
>>>> - The main addition is actually a new primitive:
>>>> #resumeFromSpecialObjectsArray that receives an special objects array as
>>>> argument and:
>>>>    - resumes the execution from the active process of such array
>>>>    - on context switch, if the VM is running from a second special
>>>> objects
>>>> array, it will return to the first one instead.
>>>>
>>>> - fixes to primitives/bytecodes that assume a single special objects
>>>> array.
>>>> e.g.,
>>>>   - #someObject and #nextObject should only iterate objects from the
>>>> correct “space”
>>>>   - #isNil comparisons should take the correct nil
>>>>   - the GC should set the correct nil object on Weak containers
>>>>
>>>> The extensions I made are about 20 overrides to StackPrimitive and
>>>> NewObjectMemory methods.
>>>>
>>>> The rest is implemented completely on image side. We use mirror
>>>> primitives
>>>> to manipulate objects from other space (as each image/space has it’s own
>>>> selector table).
>>>>
>>>> I have in my long TODO list see if the "clever hack” I did can be
>>>> supported
>>>> in a nice manner on top of Spur’s segmented memory. However, I should
>>>> stop
>>>> commencing new projects and start finishing them :P.
>>>>
>>>> On 20 ene 2016, at 9:03 a.m., Christophe Demarey
>>>> <[hidden email]> wrote:
>>>>
>>>> Hi Eliot,
>>>>
>>>> Le 19 janv. 2016 à 19:29, Eliot Miranda a écrit :
>>>>
>>>> Hi All,
>>>>
>>>>    great news!  Where can I read a specification of the Oz VM
>>>> facilities?
>>>>
>>>>
>>>> I do not know all the details of the Oz VM but basically, it is a
>>>> standard
>>>> stack interpreter vm specialized to be able to run 2 images at the same
>>>> time
>>>> on top of it.
>>>> Guillermo made it possible by using one available bit in the object
>>>> header
>>>> of objects to mark the ownership of an object (e.g. is my object from
>>>> image1
>>>> or image2?). Then, he mainly had to specialize VM primitives dealing
>>>> with
>>>> objects retrieval from memory. By example, he had to modify the garbage
>>>> collector to set the right nil instance (yes, we have 2 images so 2 nil
>>>> instances. we need to take the one of the active image) when an object
>>>> is
>>>> garbage collected; the primitive someObject has to return an object from
>>>> the
>>>> active image, etc.
>>>> There is also a way to switch execution from an image to the other just
>>>> by
>>>> switching the special objects array reference.
>>>>
>>>> You can find some information in:
>>>> https://guillep.github.io/files/publications/Poli15Thesis.pdf.
>>>> The Oz code is in http://smalltalkhub.com/#!/~Guille/ObjectSpace and in
>>>> https://github.com/guillep/OzVM
>>>> The current implementation uses Cog  6.6.1and OzVM-GuillermoPolito.22.
>>>> I do not know if Guille has a more formal specification of the Oz VM.
>>>>
>>>> If you have advices on what is the best way to handle two distinct
>>>> object
>>>> (memory) spaces in Spur, they will be welcomed :)
>>>>
>>>> Cheers,
>>>> Christophe
>>>>
>>>>
>>>> _,,,^..^,,,_ (phone)
>>>>
>>>> On Jan 19, 2016, at 6:29 AM, Christophe Demarey
>>>> <[hidden email]> wrote:
>>>>
>>>> Hi all,
>>>>
>>>> In case you do not know, we work on bootstrapping Pharo, i.e. create a
>>>> Pharo
>>>> image from sources, not based on a previous image (well, we use a pharo
>>>> image to produce it but no code / state from it).
>>>>
>>>> This process will allow to define a minimal Pharo kernel (currently 52
>>>> packages but we could have it far smaller) and to modularize the whole
>>>> image
>>>> (currently packages have too much dependencies on packages already
>>>> loaded
>>>> into the image).
>>>> The bootstrap process also allows to write down the recipe to initialize
>>>> a
>>>> new image from scratch (some code is missing in the image or is wrong).
>>>> In
>>>> addition, I think we will clean a lot of historical objects that are not
>>>> used anymore.
>>>>
>>>> With the amazing work done by Guillermo Polito during his Phd (around
>>>> Espell, Oz):
>>>> https://guillep.github.io/files/publications/Poli15Thesis.pdf,
>>>> we succeeded to get a first prototype of a bootstraped Pharo 5 image
>>>> (from
>>>> 5.392).
>>>> This prototype is able to run an eval command line handler and to log
>>>> output
>>>> / errors. Not all classes are yet initialized and you cannot yet save /
>>>> restart this image but it is a big step forward.
>>>> It is a 4 mb image (could be half the size without unicode data). You
>>>> can
>>>> download it at:
>>>>
>>>> http://chercheurs.lille.inria.fr/~demarey/pmwiki/pub/pharo-bootstrap/pharo-bootstrap.zip.
>>>>
>>>> Next steps are to have a bootstrapped image fully working, then to load
>>>> packages on top of it (like network, sunit) to produce a minimal image.
>>>> Then, we need to implement an Oz VM on top of Spur.
>>>> After that, we need to work on a reliable way to build the bootstrap
>>>> (not
>>>> too sensitive to changes in the image).
>>>>
>>>> Christophe.
>>>>
>>>> -------
>>>> demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
>>>> ../pharo
>>>> bootstrap.image --no-default-preferences eval "1 + 1"
>>>> 2
>>>> demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
>>>> ../pharo
>>>> bootstrap.image --no-default-preferences eval "'a' , 'b'"
>>>> 'ab'
>>>> demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$
>>>> ../pharo
>>>> bootstrap.image --no-default-preferences eval "1 / 0"
>>>> ZeroDivide
>>>> SmallInteger>>/
>>>> UndefinedObject>>DoIt
>>>> OpalCompiler>>evaluate
>>>> OpalCompiler(AbstractCompiler)>>evaluate:
>>>> SmalltalkImage>>evaluate:
>>>>
>>>> EvaluateCommandLineHandler>>no (source is Undeclared)
>>>> no source in EvaluateCommandLineHandler>>evaluate: in Block: no source
>>>> BlockClosure>>on:do:
>>>> EvaluateCommandLineHandler>>evaluate:
>>>> EvaluateCommandLineHandler>>evaluateArguments
>>>> EvaluateCommandLineHandler>>activate
>>>> EvaluateCommandLineHandler class(CommandLineHandler
>>>> class)>>activateWith:
>>>>
>>>> BasicCommandLineHandler>>no (source is Undeclared)
>>>> no source in
>>>> PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand: in
>>>> Block: no source
>>>> BlockClosure>>on:do:
>>>> PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand:
>>>> PharoCommandLineHandler(BasicCommandLineHandler)>>handleSubcommand
>>>> PharoCommandLineHandler(BasicCommandLineHandler)>>handleArgument:
>>>>
>>>> BasicCommandLineHandler>>no (source is Undeclared)
>>>> no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activate
>>>> in
>>>> Block: no source
>>>> BlockClosure>>on:do:
>>>> PharoCommandLineHandler(BasicCommandLineHandler)>>activate
>>>> PharoCommandLineHandler>>activate
>>>> PharoCommandLineHandler class(CommandLineHandler class)>>activateWith:
>>>>
>>>> PharoCommandLineHandler class>>no (source is Undeclared)
>>>> no source in PharoCommandLineHandler class>>activateWith: in Block: no
>>>> source
>>>> NonInteractiveUIManager(UIManager)>>defer:
>>>> PharoCommandLineHandler class>>activateWith:
>>>> no source in BasicCommandLineHandler>>activateSubCommand: in Block: no
>>>> source
>>>> BlockClosure>>on:do:
>>>> BasicCommandLineHandler>>activateSubCommand:
>>>> BasicCommandLineHandler>>handleSubcommand
>>>> BasicCommandLineHandler>>handleArgument:
>>>> no source in BasicCommandLineHandler>>activate in Block: no source
>>>>
>>>> SmallInteger>>no (source is Undeclared)
>>>>
>>>> UndefinedObject>>no (source is Undeclared)
>>>>
>>>> AbstractCompiler>>no (source is Undeclared)
>>>>
>>>> SmalltalkImage>>no (source is Undeclared)
>>>>
>>>> BlockClosure>>no (source is Undeclared)
>>>>
>>>> EvaluateCommandLineHandler>>no (source is Undeclared)
>>>>
>>>> EvaluateCommandLineHandler>>no (source is Undeclared)
>>>>
>>>> CommandLineHandler class>>no (source is Undeclared)
>>>>
>>>> BasicCommandLineHandler>>no (source is Undeclared)
>>>>
>>>> BasicCommandLineHandler>>no (source is Undeclared)
>>>>
>>>> PharoCommandLineHandler>>no (source is Undeclared)
>>>>
>>>> UIManager>>no (source is Undeclared)
>>>>
>>>> UndefinedObject>>no (source is Undeclared)
>>>>
>>>> CommandLineUIManager>>no (source is Undeclared)
>>>>
>>>> SmalltalkImage>>no (source is Undeclared)
>>>>
>>>> DelayMicrosecondScheduler>>no (source is Undeclared)
>>>>
>>>> BlockClosure>>no (source is Undeclared)
>>>>
>>>> SmalltalkImage>>no (source is Undeclared)
>>>>
>>>> WeakArray class>>no (source is Undeclared)
>>>>
>>>>
>>>> ps: source cannot be displayed because there is no formatter available
>>>> in
>>>> the bootstrap


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Pharo bootstrap

demarey
In reply to this post by Ben Coman
Hi Ben,

Le 19 janv. 2016 à 17:35, Ben Coman a écrit :

> On Tue, Jan 19, 2016 at 10:29 PM, Christophe Demarey
> <[hidden email]> wrote:
>> Hi all,
>>
>> In case you do not know, we work on bootstrapping Pharo, i.e. create a Pharo
>> image from sources, not based on a previous image (well, we use a pharo
>> image to produce it but no code / state from it).
>>
>> This process will allow to define a minimal Pharo kernel (currently 52
>> packages but we could have it far smaller) and to modularize the whole image
>> (currently packages have too much dependencies on packages already loaded
>> into the image).
>> The bootstrap process also allows to write down the recipe to initialize a
>> new image from scratch (some code is missing in the image or is wrong). In
>> addition, I think we will clean a lot of historical objects that are not
>> used anymore.
>>
>> With the amazing work done by Guillermo Polito during his Phd (around
>> Espell, Oz): https://guillep.github.io/files/publications/Poli15Thesis.pdf,
>> we succeeded to get a first prototype of a bootstraped Pharo 5 image (from
>> 5.392).
>> This prototype is able to run an eval command line handler and to log output
>> / errors. Not all classes are yet initialized and you cannot yet save /
>> restart this image but it is a big step forward.
>> It is a 4 mb image (could be half the size without unicode data). You can
>> download it at:
>> http://chercheurs.lille.inria.fr/~demarey/pmwiki/pub/pharo-bootstrap/pharo-bootstrap.zip.
>>
>> Next steps are to have a bootstrapped image fully working, then to load
>> packages on top of it (like network, sunit) to produce a minimal image.
>> Then, we need to implement an Oz VM on top of Spur.
>> After that, we need to work on a reliable way to build the bootstrap (not
>> too sensitive to changes in the image).
>
> Great work guys.  Now what stops me feeling compelled to really look
> deep into this is having a class browser / senders / implementers
> interface.  I guess this is what Oz would facilitate for peeking into
> the bootstrap image from another image ??
what we have with Espell, are mirrors pointing to the object space we created for the bootstrap.
The idea would be to use mirrors in Pharo for all reflective operations to not mix pre-coccupations. Guillermo created this project: http://smalltalkhub.com/#!/~Pharo/Mirrors wit this perspective. Then tools like browser, inspectors, debugger should use these mirrors.
Denis is also working to enable remote mirrors (a proxy to a local mirror).
With this infrastructure in place, you will be able to browse code from another object space or another image.
The bootstrap is a perfect use case to test the work of Denis on remote browsing / debugging.

Cheers,
Christophe

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

demarey
In reply to this post by ccrraaiigg

Le 20 janv. 2016 à 20:09, Craig Latta a écrit :


Hi all--

    Phil writes:

The point is not to clean but to start with an empty object engine and
fill it in with the minimum required core. Currently, the image is
the result of an evolutionary process and rebuilding it from zero was
not possible.

    Another approach is to modify the virtual machine so that it marks
methods as they are run, and modify the garbage collector to reclaim
methods that haven't been run. Then you can create systems that consist
of only what is necessary to run unit tests, effectively imprinting the
unit tests. You can interact with the target system from completely
independent one over a remote messaging network connection, so your unit
tests need not include graphics support, etc.[1] This seems much simpler
to me than making a virtual machine that can run multiple object
memories, and distributed object memories have several other important
uses too.


Guillermo also implemented this kind of approach with Tornado. 
"Tornado, a technique to dynamically tailor applications to only embed code (classes and methods) they use. Tornado uses a run-fail-grow approach to prepare an application for deployment. It launches minimal version of an application and installs a minimal set of statements that will start the user's application. This ap- plication is run and these statements are executed. When the application fails because there are classes or methods missing, the necessary code is installed. 
Extended results of Tornado: A Run-Fail-Grow approach for Dynamic Application Tayloring (PDF Download Available). Available from: https://www.researchgate.net/publication/278629977_Extended_results_of_Tornado_A_Run-Fail-Grow_approach_for_Dynamic_Application_Tayloring [accessed Jan 21, 2016]."

But is not so easy ...


This makes it possible to audit the whole build process, create
different base image for various purposes (very small, headless with
no UI objects at all, using the object engine in a completely
different way that is used today).

That makes the image the result of a fully reproducible process, from
a file of zero bytes, to a file with a working image.

    You can do all of these things with imprinted unit tests as well.

Also, this allows to experiment with new low level mechanisms. This is
currently not possible since it makes us like performing surgery on
our own brain.

    With remote messaging, which has been around for many years, you
can perform this surgery from afar.

Also, the Oz-inspired system will help in exploring other image
memories (small or large) and manipulate them as entities. At this
point, this is also not common pratice.

    This has been common practice since the introduction of the virtual
machine simulator in 1996. The remote facilities I mentioned all work
under simulation, too.

    There's a lot of prior art here.


-C

[1] http://netjam.org/context

--
Craig Latta
netjam.org
+31   6 2757 7177 (SMS ok)
+ 1 415  287 3547 (no SMS)




smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

ccrraaiigg

Hi Christophe--

> > Another approach is to modify the virtual machine so that it marks
> > methods as they are run, and modify the garbage collector to reclaim
> > methods that haven't been run. Then you can create systems that
> > consist of only what is necessary to run unit tests, effectively
> > imprinting the unit tests. You can interact with the target system
> > from completely independent one over a remote messaging network
> > connection, so your unit tests need not include graphics support,
> > etc.[1] This seems much simpler to me than making a virtual machine
> > that can run multiple object memories, and distributed object
> > memories have several other important uses too.
>
> Guillermo also implemented this kind of approach with Tornado.

     Right, I read that in his PhD thesis. That's why I mentioned my
earlier work, when others claimed there was a precedent being set.

> But is not so easy...

     Sure, I learned that first-hand when I did it. One important thing
I learned is that it's easier and more accurate to install code as a
side-effect of actually running it live, and not through analysis. It's
also useful to have the option of faulting code in when it's missing
from a running target, or pushing it in from a running source.


-C

[1] http://netjam.org/context

--
Craig Latta
netjam.org
+31   6 2757 7177 (SMS ok)
+ 1 415  287 3547 (no SMS)


Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

Guillermo Polito
Peter,

The point is that “cleaning the image” is

 - not reproducible. A cleanup script may work with today’s image but may not work with tomorrow’s one.
 - It’s not only about cleaning. Imagine you observe that the tables keeping Unicode mappings are wrong. And there is no code to reproduce them.
 - it does not scale when it starts to become circular. For example, you want to refactor a part of morphic => but you are use morphic while the refactor is performed. We do that all the time, but at the cost of splitting and staging changes that require to be atomic, which adds more complexity to the process.


Craig,

Yes, Spoon was indeed an inspiration. However, some notes on top of your comments:

- Oz/Espell's existing implementation works by introducing two object memories in the same VM, yes. However, the goal was to abstract Espell’s user from such detail and have other implementations such as a remote image one. For example, I wrote a prototype of Espell that manipulated an image loaded in the simulator. The result is that you had a high-level API provided by mirrors to manipulate an image without requiring a VM change. However it was also much slower, and required adapting the VM simulator to initialize it with an empty object memory, and being able to call primitives from outside the simulator while keeping the stack coherent. I dropped this prototype because it required a lot of engineering effort and at the same time Spur advanced really quickly, so I did not want to spend time in code that would soon be deprecated. I could however check if I can recover the code.

- Also, I would not say that distributed object memories "are simpler" than keeping co-existing object memories, or not at least without exploring it’s flaws also :). A distributed object memory forces you to include in every peer that may receive code a distribution layer (at least sockets, class builder, compiler or serializer + dependencies). And we wanted to go further. We wanted to be able to easily manipulate an image that does not have those features.

- The main point was to use the same infrastructure to build an image in an explicit manner (the bootstrap) as well as in an implicit on-demand manner (tornado). And I believe that the bootstrap is a more transparent process where we can control what happens.

Guille

> On 21 ene 2016, at 2:34 p.m., Craig Latta <[hidden email]> wrote:
>
>
> Hi Christophe--
>
>>> Another approach is to modify the virtual machine so that it marks
>>> methods as they are run, and modify the garbage collector to reclaim
>>> methods that haven't been run. Then you can create systems that
>>> consist of only what is necessary to run unit tests, effectively
>>> imprinting the unit tests. You can interact with the target system
>>> from completely independent one over a remote messaging network
>>> connection, so your unit tests need not include graphics support,
>>> etc.[1] This seems much simpler to me than making a virtual machine
>>> that can run multiple object memories, and distributed object
>>> memories have several other important uses too.
>>
>> Guillermo also implemented this kind of approach with Tornado.
>
>     Right, I read that in his PhD thesis. That's why I mentioned my
> earlier work, when others claimed there was a precedent being set.
>
>> But is not so easy...
>
>     Sure, I learned that first-hand when I did it. One important thing
> I learned is that it's easier and more accurate to install code as a
> side-effect of actually running it live, and not through analysis. It's
> also useful to have the option of faulting code in when it's missing
> from a running target, or pushing it in from a running source.
>
>
> -C
>
> [1] http://netjam.org/context
>
> --
> Craig Latta
> netjam.org
> +31   6 2757 7177 (SMS ok)
> + 1 415  287 3547 (no SMS)
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

philippeback
In reply to this post by demarey


On Thu, Jan 21, 2016 at 10:33 AM, Christophe Demarey <[hidden email]> wrote:

Le 20 janv. 2016 à 20:09, Craig Latta a écrit :


Hi all--

    Phil writes:

The point is not to clean but to start with an empty object engine and
fill it in with the minimum required core. Currently, the image is
the result of an evolutionary process and rebuilding it from zero was
not possible.

    Another approach is to modify the virtual machine so that it marks
methods as they are run, and modify the garbage collector to reclaim
methods that haven't been run. Then you can create systems that consist
of only what is necessary to run unit tests, effectively imprinting the
unit tests. You can interact with the target system from completely
independent one over a remote messaging network connection, so your unit
tests need not include graphics support, etc.[1] This seems much simpler
to me than making a virtual machine that can run multiple object
memories, and distributed object memories have several other important
uses too.


Guillermo also implemented this kind of approach with Tornado. 
"Tornado, a technique to dynamically tailor applications to only embed code (classes and methods) they use. Tornado uses a run-fail-grow approach to prepare an application for deployment. It launches minimal version of an application and installs a minimal set of statements that will start the user's application. This ap- plication is run and these statements are executed. When the application fails because there are classes or methods missing, the necessary code is installed. 
Extended results of Tornado: A Run-Fail-Grow approach for Dynamic Application Tayloring (PDF Download Available). Available from: https://www.researchgate.net/publication/278629977_Extended_results_of_Tornado_A_Run-Fail-Grow_approach_for_Dynamic_Application_Tayloring [accessed Jan 21, 2016]."

But is not so easy ...


This makes it possible to audit the whole build process, create
different base image for various purposes (very small, headless with
no UI objects at all, using the object engine in a completely
different way that is used today).

That makes the image the result of a fully reproducible process, from
a file of zero bytes, to a file with a working image.

    You can do all of these things with imprinted unit tests as well.

Also, this allows to experiment with new low level mechanisms. This is
currently not possible since it makes us like performing surgery on
our own brain.

    With remote messaging, which has been around for many years, you
can perform this surgery from afar.
Not available in my Pharo environment. Which is what I use and care about. 

Also, the Oz-inspired system will help in exploring other image
memories (small or large) and manipulate them as entities. At this
point, this is also not common pratice.

    This has been common practice since the introduction of the virtual
machine simulator in 1996. The remote facilities I mentioned all work
under simulation, too.
Simulator not working under Pharo currently. Same issue. 

    There's a lot of prior art here.

Sure, but prior art is not running on my environment. So, it is irrelevant for my current activities.

Phil 

-C

[1] http://netjam.org/context

--
Craig Latta
netjam.org
+31   6 2757 7177 (SMS ok)
<a href="tel:%2B%201%20415%20%C2%A0287%203547" value="+14152873547" target="_blank">+ 1 415  287 3547 (no SMS)




Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

ccrraaiigg

Hi Phil--

> ...prior art is not running on my environment. So, it is irrelevant
> for my current activities.

     You weren't talking about your current activities before, you were
talking about some allegedly innovative capability.

     At any rate, I do have versions of Context for Pharo and other
Smalltalks, which I intend to release this year. I wanted to deal with
SqueakJS after Squeak, then Pharo, then VisualWorks, etc.


-C

--
Craig Latta
netjam.org
+31   6 2757 7177 (SMS ok)
+ 1 415  287 3547 (no SMS)


Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

ccrraaiigg
In reply to this post by Guillermo Polito

Hi Guille--

> The point is that “cleaning the image” is not reproducible. A cleanup
> script may work with today’s image but may not work with tomorrow’s.

     I consider this sort of cleaning something that gets done once per
preexisting Smalltalk implementation (Pharo, VisualWorks, etc.). After
it's done, I would build every release artifact up from the identified
essentials (minimal object memory). You need a good module system for
that, and I think one based on live remote messaging instead of source
code stored in files would be best (easiest to build and use, and most
accurate). With the knowledge of those essentials, I would create new
Smalltalk implementations from a system tracer informed by them.

     Cleaning isn't something I would expect to do routinely as an app
developer. It's primarily a research activity.

> [Cleaning] does not scale when it starts to become circular. For
> example, you want to refactor a part of morphic => but you are use
> morphic while the refactor is performed. We do that all the time, but
> at the cost of splitting and staging changes that require to be
> atomic, which adds more complexity to the process.

     Of course, this is another argument for using remote tools.

> ...I wrote a prototype of Espell that manipulated an image loaded in
> the simulator. The result is that you had a high-level API provided
> by mirrors to manipulate an image without requiring a VM change.

     I think that's definitely something you want to be able to do,
since there are some changes that can only be made when time is stopped
for the target image. And the simulator is simply the most pleasant tool
for it. The implementation of this that I did was especially useful for
making complimentary documentation, like the directed-graph movies at
[1]. True, the simulator is slow, and making movie frames with it is
glacial. :)

     We should never be afraid to change the virtual machine, though, in
the absence of any other constraint. :)

> A distributed object memory forces you to include in every peer that
> may receive code a distribution layer (at least sockets, class
> builder, compiler or serializer + dependencies). And we wanted to go
> further. We wanted to be able to easily manipulate an image that does
> not have those features.

     Right, I use the simulator stuff when I care about leaving those
things out (e.g. [2]). But all of the systems I actually want to deploy
do have those things, to the point that I do consider them to be as
fundamental as anything else. And they don't include the class builder
or compiler; the remote messaging protocol I wrote gets by with just
sockets, a few collection classes, and the reflection primitives that
the virtual machine needs anyway. There is never a need to compile
source code.

> The main point was to use the same infrastructure to build an image
> in an explicit manner (the bootstrap) as well as in an implicit
> on-demand manner (tornado). And I believe that the bootstrap is a
> more transparent process where we can control what happens.

     It seems to me that push imprinting, where methods are transferred
from one system to another as a side-effect of running them, is just as
transparent and controllable, and gives you tools that you want anyway
for other purposes.


     thanks,

-C

[1] http://netjam.org/context/viz
[2] http://netjam.org/context/smallest

--
Craig Latta
netjam.org
+31 6 2757 7177 (SMS ok)
+ 1 415 287 3547 (no SMS)



Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Pharo bootstrap

stepharo
In reply to this post by Sven Van Caekenberghe-2

> This is a much more complex and challenging subject that you might think.
>
> There has been a lot of work done on this for many years, many approaches have been tried.
>
> I am pretty sure that the people behind the Pharo Bootstrap project are aware of the existing literature.
oh yes and even of things that were not written in papers. :)


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Pharo bootstrap

stepharo
In reply to this post by demarey
reducing also the number of classes in the kernel could help.
But first it should work and then we start to optimize
Now this is true that 10 h is insane :)


Le 20/1/16 09:08, Christophe Demarey a écrit :
Hi Pavel,

Le 19 janv. 2016 à 19:53, Pavel Krivanek a écrit :

Hi,

amazing! Do you have any idea how to speed up it? The bootstrap process is now running on my machine about one and half hour and it is still far from finish. 

The process is indeed far too long (takes around 10 hours) on the CI server.
Reasons are:
- we use a stack interpreter VM
- we modified it and is a bit slower than a classical stack VM
- we use AST interpretation to build the bootstrap and it is very slow. Guille already did some speed improvements by avoiding to interpret loops by example.

I did not yet spend time on this point because I first wanted to have something working.
Definitely, this problem will be tackled when we will put in production the bootstrap.

Cheers,
Christophe


Cheers,
-- Pavel

2016-01-19 15:29 GMT+01:00 Christophe Demarey <[hidden email]>:
Hi all,

In case you do not know, we work on bootstrapping Pharo, i.e. create a Pharo image from sources, not based on a previous image (well, we use a pharo image to produce it but no code / state from it).

This process will allow to define a minimal Pharo kernel (currently 52 packages but we could have it far smaller) and to modularize the whole image (currently packages have too much dependencies on packages already loaded into the image).
The bootstrap process also allows to write down the recipe to initialize a new image from scratch (some code is missing in the image or is wrong). In addition, I think we will clean a lot of historical objects that are not used anymore.

With the amazing work done by Guillermo Polito during his Phd (around Espell, Oz): https://guillep.github.io/files/publications/Poli15Thesis.pdfwe succeeded to get a first prototype of a bootstraped Pharo 5 image (from 5.392).
This prototype is able to run an eval command line handler and to log output / errors. Not all classes are yet initialized and you cannot yet save / restart this image but it is a big step forward.
It is a 4 mb image (could be half the size without unicode data). You can download it at: http://chercheurs.lille.inria.fr/~demarey/pmwiki/pub/pharo-bootstrap/pharo-bootstrap.zip.

Next steps are to have a bootstrapped image fully working, then to load packages on top of it (like network, sunit) to produce a minimal image.
Then, we need to implement an Oz VM on top of Spur.
After that, we need to work on a reliable way to build the bootstrap (not too sensitive to changes in the image).

Christophe.

-------
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "1 + 1"
2
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "'a' , 'b'"
'ab'
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "1 / 0"
ZeroDivide
SmallInteger>>/
UndefinedObject>>DoIt
OpalCompiler>>evaluate
OpalCompiler(AbstractCompiler)>>evaluate:
SmalltalkImage>>evaluate:

EvaluateCommandLineHandler>>no (source is Undeclared) 
no source in EvaluateCommandLineHandler>>evaluate: in Block: no source
BlockClosure>>on:do:
EvaluateCommandLineHandler>>evaluate:
EvaluateCommandLineHandler>>evaluateArguments
EvaluateCommandLineHandler>>activate
EvaluateCommandLineHandler class(CommandLineHandler class)>>activateWith:

BasicCommandLineHandler>>no (source is Undeclared) 
no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand: in Block: no source
BlockClosure>>on:do:
PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand:
PharoCommandLineHandler(BasicCommandLineHandler)>>handleSubcommand
PharoCommandLineHandler(BasicCommandLineHandler)>>handleArgument:

BasicCommandLineHandler>>no (source is Undeclared) 
no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activate in Block: no source
BlockClosure>>on:do:
PharoCommandLineHandler(BasicCommandLineHandler)>>activate
PharoCommandLineHandler>>activate
PharoCommandLineHandler class(CommandLineHandler class)>>activateWith:

PharoCommandLineHandler class>>no (source is Undeclared) 
no source in PharoCommandLineHandler class>>activateWith: in Block: no source
NonInteractiveUIManager(UIManager)>>defer:
PharoCommandLineHandler class>>activateWith:
no source in BasicCommandLineHandler>>activateSubCommand: in Block: no source
BlockClosure>>on:do:
BasicCommandLineHandler>>activateSubCommand:
BasicCommandLineHandler>>handleSubcommand
BasicCommandLineHandler>>handleArgument:
no source in BasicCommandLineHandler>>activate in Block: no source

SmallInteger>>no (source is Undeclared) 

UndefinedObject>>no (source is Undeclared) 

AbstractCompiler>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

BlockClosure>>no (source is Undeclared) 

EvaluateCommandLineHandler>>no (source is Undeclared) 

EvaluateCommandLineHandler>>no (source is Undeclared) 

CommandLineHandler class>>no (source is Undeclared) 

BasicCommandLineHandler>>no (source is Undeclared) 

BasicCommandLineHandler>>no (source is Undeclared) 

PharoCommandLineHandler>>no (source is Undeclared) 

UIManager>>no (source is Undeclared) 

UndefinedObject>>no (source is Undeclared) 

CommandLineUIManager>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

DelayMicrosecondScheduler>>no (source is Undeclared) 

BlockClosure>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

WeakArray class>>no (source is Undeclared) 


ps: source cannot be displayed because there is no formatter available in the bootstrap




Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Pharo bootstrap

Tudor Girba-2
Hi,

> On Jan 21, 2016, at 9:48 PM, stepharo <[hidden email]> wrote:
>
> reducing also the number of classes in the kernel could help.
> But first it should work and then we start to optimize
> Now this is true that 10 h is insane :)

It’s not insane. It’s a first solution :)

Doru

>
> Le 20/1/16 09:08, Christophe Demarey a écrit :
>> Hi Pavel,
>>
>> Le 19 janv. 2016 à 19:53, Pavel Krivanek a écrit :
>>
>>> Hi,
>>>
>>> amazing! Do you have any idea how to speed up it? The bootstrap process is now running on my machine about one and half hour and it is still far from finish.
>>
>> The process is indeed far too long (takes around 10 hours) on the CI server.
>> Reasons are:
>> - we use a stack interpreter VM
>> - we modified it and is a bit slower than a classical stack VM
>> - we use AST interpretation to build the bootstrap and it is very slow. Guille already did some speed improvements by avoiding to interpret loops by example.
>>
>> I did not yet spend time on this point because I first wanted to have something working.
>> Definitely, this problem will be tackled when we will put in production the bootstrap.
>>
>> Cheers,
>> Christophe
>>
>>
>>> Cheers,
>>> -- Pavel
>>>
>>> 2016-01-19 15:29 GMT+01:00 Christophe Demarey <[hidden email]>:
>>> Hi all,
>>>
>>> In case you do not know, we work on bootstrapping Pharo, i.e. create a Pharo image from sources, not based on a previous image (well, we use a pharo image to produce it but no code / state from it).
>>>
>>> This process will allow to define a minimal Pharo kernel (currently 52 packages but we could have it far smaller) and to modularize the whole image (currently packages have too much dependencies on packages already loaded into the image).
>>> The bootstrap process also allows to write down the recipe to initialize a new image from scratch (some code is missing in the image or is wrong). In addition, I think we will clean a lot of historical objects that are not used anymore.
>>>
>>> With the amazing work done by Guillermo Polito during his Phd (around Espell, Oz): https://guillep.github.io/files/publications/Poli15Thesis.pdf, we succeeded to get a first prototype of a bootstraped Pharo 5 image (from 5.392).
>>> This prototype is able to run an eval command line handler and to log output / errors. Not all classes are yet initialized and you cannot yet save / restart this image but it is a big step forward.
>>> It is a 4 mb image (could be half the size without unicode data). You can download it at: http://chercheurs.lille.inria.fr/~demarey/pmwiki/pub/pharo-bootstrap/pharo-bootstrap.zip.
>>>
>>> Next steps are to have a bootstrapped image fully working, then to load packages on top of it (like network, sunit) to produce a minimal image.
>>> Then, we need to implement an Oz VM on top of Spur.
>>> After that, we need to work on a reliable way to build the bootstrap (not too sensitive to changes in the image).
>>>
>>> Christophe.
>>>
>>> -------
>>> demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "1 + 1"
>>> 2
>>> demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "'a' , 'b'"
>>> 'ab'
>>> demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "1 / 0"
>>> ZeroDivide
>>> SmallInteger>>/
>>> UndefinedObject>>DoIt
>>> OpalCompiler>>evaluate
>>> OpalCompiler(AbstractCompiler)>>evaluate:
>>> SmalltalkImage>>evaluate:
>>>
>>> EvaluateCommandLineHandler>>no (source is Undeclared)
>>> no source in EvaluateCommandLineHandler>>evaluate: in Block: no source
>>> BlockClosure>>on:do:
>>> EvaluateCommandLineHandler>>evaluate:
>>> EvaluateCommandLineHandler>>evaluateArguments
>>> EvaluateCommandLineHandler>>activate
>>> EvaluateCommandLineHandler class(CommandLineHandler class)>>activateWith:
>>>
>>> BasicCommandLineHandler>>no (source is Undeclared)
>>> no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand: in Block: no source
>>> BlockClosure>>on:do:
>>> PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand:
>>> PharoCommandLineHandler(BasicCommandLineHandler)>>handleSubcommand
>>> PharoCommandLineHandler(BasicCommandLineHandler)>>handleArgument:
>>>
>>> BasicCommandLineHandler>>no (source is Undeclared)
>>> no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activate in Block: no source
>>> BlockClosure>>on:do:
>>> PharoCommandLineHandler(BasicCommandLineHandler)>>activate
>>> PharoCommandLineHandler>>activate
>>> PharoCommandLineHandler class(CommandLineHandler class)>>activateWith:
>>>
>>> PharoCommandLineHandler class>>no (source is Undeclared)
>>> no source in PharoCommandLineHandler class>>activateWith: in Block: no source
>>> NonInteractiveUIManager(UIManager)>>defer:
>>> PharoCommandLineHandler class>>activateWith:
>>> no source in BasicCommandLineHandler>>activateSubCommand: in Block: no source
>>> BlockClosure>>on:do:
>>> BasicCommandLineHandler>>activateSubCommand:
>>> BasicCommandLineHandler>>handleSubcommand
>>> BasicCommandLineHandler>>handleArgument:
>>> no source in BasicCommandLineHandler>>activate in Block: no source
>>>
>>> SmallInteger>>no (source is Undeclared)
>>>
>>> UndefinedObject>>no (source is Undeclared)
>>>
>>> AbstractCompiler>>no (source is Undeclared)
>>>
>>> SmalltalkImage>>no (source is Undeclared)
>>>
>>> BlockClosure>>no (source is Undeclared)
>>>
>>> EvaluateCommandLineHandler>>no (source is Undeclared)
>>>
>>> EvaluateCommandLineHandler>>no (source is Undeclared)
>>>
>>> CommandLineHandler class>>no (source is Undeclared)
>>>
>>> BasicCommandLineHandler>>no (source is Undeclared)
>>>
>>> BasicCommandLineHandler>>no (source is Undeclared)
>>>
>>> PharoCommandLineHandler>>no (source is Undeclared)
>>>
>>> UIManager>>no (source is Undeclared)
>>>
>>> UndefinedObject>>no (source is Undeclared)
>>>
>>> CommandLineUIManager>>no (source is Undeclared)
>>>
>>> SmalltalkImage>>no (source is Undeclared)
>>>
>>> DelayMicrosecondScheduler>>no (source is Undeclared)
>>>
>>> BlockClosure>>no (source is Undeclared)
>>>
>>> SmalltalkImage>>no (source is Undeclared)
>>>
>>> WeakArray class>>no (source is Undeclared)
>>>
>>>
>>> ps: source cannot be displayed because there is no formatter available in the bootstrap
>>>
>>>
>>
>

--
www.tudorgirba.com
www.feenk.com

"Not knowing how to do something is not an argument for how it cannot be done."


Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

ccrraaiigg
In reply to this post by stepharo

> > I am pretty sure that the people behind the Pharo Bootstrap project
> > are aware of the existing literature.
>
> oh yes and even of things that were not written in papers. :)

     Papers are no longer the only way to publish, and paper-writers are
still obligated to cite prior work however they become acquainted with it.


-C

--
Craig Latta
netjam.org
+31   6 2757 7177 (SMS ok)
+ 1 415  287 3547 (no SMS)


Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

philippeback
In reply to this post by ccrraaiigg
Craig,

Apologies for being blunt, but supercool stuff that I know about but am not able to use is not of any use to me.

From my perspective, I am very frustrated to not be able to use:

- Context in Pharo
- Your remote running of tiny images in my Pharo browser (including the sonar ping sound when messages are landing remotely) 
- Using WebDav for looking into my images using your WebDav component

That's a hell of a lot of super great tech that hasn't seen the light of day in the Pharo community (think being able to explore the image as a filesystem, edit the methods in Vim in a terminal [yes, this is actually cool to me], drag and drop binaries in these folders to import/export binary resources into the image).

It is frustrating to see that what could turn into a superb capability of the tooling is running on your box but is not available for use by us (me) the common people.

It is your code, you do what you want.  I'd live to see it running (even super badly, which I don't think would be the case) on Pharo.

Peace,
Phil

On Thu, Jan 21, 2016 at 7:39 PM, Craig Latta <[hidden email]> wrote:

Hi Phil--

> ...prior art is not running on my environment. So, it is irrelevant
> for my current activities.

     You weren't talking about your current activities before, you were
talking about some allegedly innovative capability.

     At any rate, I do have versions of Context for Pharo and other
Smalltalks, which I intend to release this year. I wanted to deal with
SqueakJS after Squeak, then Pharo, then VisualWorks, etc.


-C

--
Craig Latta
netjam.org
<a href="tel:%2B31%20%20%206%202757%207177" value="+31627577177">+31 6 2757 7177 (SMS ok)
<a href="tel:%2B%201%20415%20%20287%203547" value="+14152873547">+ 1 415 287 3547 (no SMS)



Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

ccrraaiigg

> From my perspective, I am very frustrated to not be able to use:
>
> - Context in Pharo
> - Your remote running of tiny images in my Pharo browser (including
>   the sonar ping sound when messages are landing remotely)
> - Using WebDav for looking into my images using your WebDav component

     Cool, that's all planned for this year (in reverse order).


     thanks,

-C

--
Craig Latta
netjam.org
+31   6 2757 7177 (SMS ok)
+ 1 415  287 3547 (no SMS)


Reply | Threaded
Open this post in threaded view
|

Re: Pharo bootstrap

demarey
In reply to this post by Brad Selfridge
Hi Brad,

Envy is a package manager. It does not define the minimal kernel you need to install packages needed for your application.
The goal of a bootstrap is to set up an environment from a know state. In the same time, this exercise forces us to define the minimal kernel needed to run Pharo (because you do not want to bootstrap the full system).
Currently, we miss both the minimal kernel and a bootstrapped image of Pharo.

Le 20 janv. 2016 à 20:17, Brad Selfridge a écrit :

> Has anyone looked at the VASmalltalk Envy Packager. It let's one decide
> whether you want to package a headless or UI image. It then allows one to
> define packaging instructions, that are saved with the new application),
> that get fed into the packager. The instructions define prerequisite apps,
> un-referenced methods, etc. When one defines a new application (package),
> one can define prerequisite applications that have to be installed before
> the current application is installed. This prerequisite chain is used in
> loading the application from Envy and in packaging. Seems to work fairly
> well. Doesn't take too long to package an app and give the developer pretty
> fine control over the packaging and loading process.
>
>
>
> -----
> Brad Selfridge
> --
> View this message in context: http://forum.world.st/ANN-Pharo-bootstrap-tp4872633p4872989.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>


smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Pharo bootstrap

Eliot Miranda-2
In reply to this post by Guillermo Polito
Hi Gille,

   I'll respond to the two object spaces message next, but saw the point about AST interprretation and I have a suggestion

On Wed, Jan 20, 2016 at 4:29 AM, Guillermo Polito <[hidden email]> wrote:

On 20 ene 2016, at 9:08 a.m., Christophe Demarey <[hidden email]> wrote:

Hi Pavel,

Le 19 janv. 2016 à 19:53, Pavel Krivanek a écrit :

Hi,

amazing! Do you have any idea how to speed up it? The bootstrap process is now running on my machine about one and half hour and it is still far from finish. 

The process is indeed far too long (takes around 10 hours) on the CI server.
Reasons are:
- we use a stack interpreter VM
- we modified it and is a bit slower than a classical stack VM

Not quite so. My measurements did not show that… But I can understand the feeling as the StackVM is in general half as fast as the CogVM, which is the VM we are used to use since years.

- we use AST interpretation to build the bootstrap and it is very slow. Guille already did some speed improvements by avoiding to interpret loops by example.

I did not yet spend time on this point because I first wanted to have something working.
Definitely, this problem will be tackled when we will put in production the bootstrap.

We should really measure because I see three main aspects:

1) class creation (executes the class builder using AST interpretation)
2) method compilation
3) method installation  (using AST interpretation to respect trait copying)

My feeling (from what I observe only) is that most of the time is consumed in 2) and 3), and that specially it is in 3).

The AST interpretation seems to me easily replaced by bytecode interpretation that should be much faster.  If you added a subclass of Context, say OzInstallationInterpreter, this could override all methods that make direct inst var access, such as  

Context methods for instruction decoding
pushReceiverVariable: offset 
"Simulate the action of bytecode that pushes the contents of the receiver's 
instance variable whose index is the argument, index, on the top of the 
stack."

self push: (self object: self receiver instVarAt: offset + 1)

with ones that map back from inst var offsets to inst var names, e.g.

OzInstallationInterpreter methods for instruction decoding
pushReceiverVariable: offset 
"Simulate the action of bytecode that pushes the contents of the receiver's 
instance variable whose index is the argument, index, on the top of the 
stack.  Override to ensure that the offset of the named inst var is used."

self push: (self object: self receiver instVarNamed: (self mapInstVarOffsetToName: offset + 1))

You might even be able to do this just in object:instVarAt:.

But if you move away from AST interpretation you save both the overhead of interpreting the AST /and/ the cost of parsing the method to the AST, which I presume is significant, and can simply use the methods extant in the system.


And I particularly want to see how the growing of collections perform.


Cheers,
Christophe


Cheers,
-- Pavel

2016-01-19 15:29 GMT+01:00 Christophe Demarey <[hidden email]>:
Hi all,

In case you do not know, we work on bootstrapping Pharo, i.e. create a Pharo image from sources, not based on a previous image (well, we use a pharo image to produce it but no code / state from it).

This process will allow to define a minimal Pharo kernel (currently 52 packages but we could have it far smaller) and to modularize the whole image (currently packages have too much dependencies on packages already loaded into the image).
The bootstrap process also allows to write down the recipe to initialize a new image from scratch (some code is missing in the image or is wrong). In addition, I think we will clean a lot of historical objects that are not used anymore.

With the amazing work done by Guillermo Polito during his Phd (around Espell, Oz): https://guillep.github.io/files/publications/Poli15Thesis.pdfwe succeeded to get a first prototype of a bootstraped Pharo 5 image (from 5.392).
This prototype is able to run an eval command line handler and to log output / errors. Not all classes are yet initialized and you cannot yet save / restart this image but it is a big step forward.
It is a 4 mb image (could be half the size without unicode data). You can download it at: http://chercheurs.lille.inria.fr/~demarey/pmwiki/pub/pharo-bootstrap/pharo-bootstrap.zip.

Next steps are to have a bootstrapped image fully working, then to load packages on top of it (like network, sunit) to produce a minimal image.
Then, we need to implement an Oz VM on top of Spur.
After that, we need to work on a reliable way to build the bootstrap (not too sensitive to changes in the image).

Christophe.

-------
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "1 + 1"
2
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "'a' , 'b'"
'ab'
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "1 / 0"
ZeroDivide
SmallInteger>>/
UndefinedObject>>DoIt
OpalCompiler>>evaluate
OpalCompiler(AbstractCompiler)>>evaluate:
SmalltalkImage>>evaluate:

EvaluateCommandLineHandler>>no (source is Undeclared) 
no source in EvaluateCommandLineHandler>>evaluate: in Block: no source
BlockClosure>>on:do:
EvaluateCommandLineHandler>>evaluate:
EvaluateCommandLineHandler>>evaluateArguments
EvaluateCommandLineHandler>>activate
EvaluateCommandLineHandler class(CommandLineHandler class)>>activateWith:

BasicCommandLineHandler>>no (source is Undeclared) 
no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand: in Block: no source
BlockClosure>>on:do:
PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand:
PharoCommandLineHandler(BasicCommandLineHandler)>>handleSubcommand
PharoCommandLineHandler(BasicCommandLineHandler)>>handleArgument:

BasicCommandLineHandler>>no (source is Undeclared) 
no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activate in Block: no source
BlockClosure>>on:do:
PharoCommandLineHandler(BasicCommandLineHandler)>>activate
PharoCommandLineHandler>>activate
PharoCommandLineHandler class(CommandLineHandler class)>>activateWith:

PharoCommandLineHandler class>>no (source is Undeclared) 
no source in PharoCommandLineHandler class>>activateWith: in Block: no source
NonInteractiveUIManager(UIManager)>>defer:
PharoCommandLineHandler class>>activateWith:
no source in BasicCommandLineHandler>>activateSubCommand: in Block: no source
BlockClosure>>on:do:
BasicCommandLineHandler>>activateSubCommand:
BasicCommandLineHandler>>handleSubcommand
BasicCommandLineHandler>>handleArgument:
no source in BasicCommandLineHandler>>activate in Block: no source

SmallInteger>>no (source is Undeclared) 

UndefinedObject>>no (source is Undeclared) 

AbstractCompiler>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

BlockClosure>>no (source is Undeclared) 

EvaluateCommandLineHandler>>no (source is Undeclared) 

EvaluateCommandLineHandler>>no (source is Undeclared) 

CommandLineHandler class>>no (source is Undeclared) 

BasicCommandLineHandler>>no (source is Undeclared) 

BasicCommandLineHandler>>no (source is Undeclared) 

PharoCommandLineHandler>>no (source is Undeclared) 

UIManager>>no (source is Undeclared) 

UndefinedObject>>no (source is Undeclared) 

CommandLineUIManager>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

DelayMicrosecondScheduler>>no (source is Undeclared) 

BlockClosure>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

WeakArray class>>no (source is Undeclared) 


ps: source cannot be displayed because there is no formatter available in the bootstrap







--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: [Vm-dev] Re: [ANN] Pharo bootstrap

Eliot Miranda-2
In reply to this post by Guillermo Polito
Hi Guille,

On Wed, Jan 20, 2016 at 4:52 AM, Guillermo Polito <[hidden email]> wrote:
 
Well, there is no formal specification… But I could summarize the features as follows (and as Christophe points mostly out)

OzVM supports having two images in logically separated spaces. This separation is achieved by using the free bit in the object header. Thus we support only two spaces by now.

- The main addition is actually a new primitive: #resumeFromSpecialObjectsArray that receives an special objects array as argument and:
    - resumes the execution from the active process of such array
    - on context switch, if the VM is running from a second special objects array, it will return to the first one instead.

- fixes to primitives/bytecodes that assume a single special objects array. e.g.,
   - #someObject and #nextObject should only iterate objects from the correct “space”
   - #isNil comparisons should take the correct nil
   - the GC should set the correct nil object on Weak containers

The extensions I made are about 20 overrides to StackPrimitive and NewObjectMemory methods.

The rest is implemented completely on image side. We use mirror primitives to manipulate objects from other space (as each image/space has it’s own selector table).

I have in my long TODO list see if the "clever hack” I did can be supported in a nice manner on top of Spur’s segmented memory. However, I should stop commencing new projects and start finishing them :P.

Indeed, I can join you in wanting things to work first :-).

I want to respond to both sketch how you could port the architecture to Spur, but also suggest what I think is a much more attractive alternative.

First, how to support two spaces under Spur or Cog Spur.  Spur's memory map looks like a low segment, followed by any number of segments higher in memory.  The first segment is composed of several spaces and is allocated at startup.  Subsequent segments are obtained by mmap and the only requirement is that they be at higher addresses than the first segment, so star-up goes to some effort to obtain a suitably sized chunk of memory at as low as possible an address.

In Cog Spur the first segment looks like this, from low to high:

1. a code zone holding the jit's machine code, any size up to 16Mb, but 1Mb by default.
2. an object zone holding Spur's new space, an eden and two small survivor spaces for a classical generation scavenger.  It can be of any size up to 1Gb but is 4Mb by default, with eden being 5/7th and each survivor space being 1/7th of the space.
3. the object zone holding the first old space segment.  This is big enough to hold the loaded image plus a free chunk from which new old space objects (e.g. objects tenured from new space) are allocated.

The Spur interpreter simply omits the code zone.

Now the placing of eden beneath the first old space segment is "baked in".  The store check checks for new objects being stored into old objects, since the old objects must be added to the remembered table (which lives in old space).  The first object in the first old space segment is nil, and the store check checks for objects less than nil being stored into objects greater than or equal to nil.  Inside the Spur memory manager nilObject, the variable that holds onto nil, is a variable, not a constant, and so can be changed, e.g. when switching between two sets of spaces.  Inside machine code, nil is a constant, referred to directly from machine code.

So in having two object spaces one approach that seems feasible is to have two initial segments, each with distinct code zones, edens, and first old space segments:

low: code zone for space 1; new space for space 1; first old space segment for space 1; code zone for space 2; new space for space 2; first old space segment for space 2; high

which would be very easy to switch between, but would cause problems for the store check since objects in new space for space 2 appear greater than space 1's nil.

So a refinement would be to organize the space like this:

low: code zone for space 1; code zone for space 2; new space for space 1; new space for space 2; first old space segment for space 1; first old space segment for space 2; high

and always use space 1's nil for the store check.

You still need to consult both remembered sets during scavenging to find all the roots, but it would seem feasible.  The VM would need two CogMethodZones, and your swap primitive would need to exchange them.  The segment manager could mark old space segments as belonging to either space 1 or space 2, and you could add a snapshot primitive that would snapshot only space 2. I'm sure there are lots of other problems but I expect you could make this work.

However, I think there's a /much/ nicer architecture, and I use it myself for the Spur bootstrap both from the V3 memory manager you're working with (NewObjectMemory) to Spur 32-bit, and from Spur 32-bit to Spur 64-bit.  And that is to use the VM simulator and mirrors.

In the VM simulator one has either a JIT or the Stack Interpreter.  But we can eliminate the JIT because simularting machine code is slower than the Stack Interpreter, so the fastest execution engine in the simulator is the StackInterpreter.  And please suspend your disbelief as to this simulator being fast enough for work.  I will address that later on.  First let's look at the architecture.

In the simulator, the heap is represented by a single ByteArray "memory", but I'll call "heapMemory" to avoid confusion.  So in a Spur StackInterpreter the start of heapMemory is new space, followed immediately by the first old space segment, whose first object is nil.  When the simulator grows memory by adding new segments it grows heapMemory, and leaves a gap between the end of what was the last segment and the new highest last segment.  So through heapMemory one can access any object in the space.

The simulator contains a limited set of mirror objects right now, but these can be extended.  But currently, for example, there are mirror objects that can be attached to "methods" in heapArray (which are actually just sequences of bytes) and these mirrors make those sequences of bytes appear to be real CompiledMethod instances in the host and hence allow the host to e.g. decompile them or print their bytecodes.  For example, this is SmalltalkImage>>at:ifAbsent: in a Squeak image in the simulator's heap pretty printed by the hosts's InstructionPrinter:
17 <00> pushRcvr: 0
18 <10> pushTemp: 0
19 <11> pushTemp: 1
20 <F0> send: a VMObjectProxy for #at:ifAbsent: (2 args)
21 <7C> returnTop

So with suitable mirrors one can access the sequences of bytes in heapMemory as if they were objects.  The reverse would be possible, where a special kind of proxy in heapMemory would cause the simulator to escape back out to the host and send messages to the host system, but I've not done this.  [The other kind of proxy I use is one that takes a host object and makes it appear to be a sequence of bytes.  This allows for example, the Cogit to JIT a method in the host system to heapMemory to test the Cogit compiler without having to start the simulator. But that's not useful to you.]

An example of the use of the simulator for bootstrapping is in converting a V3 image to a Spur image.  Two simulators are created, one for the V3 image and one, initially empty, for the Spur image.  A conversion pass is run which clones the relevant objects from the V3 heap to the Spur heap.  Not all objects get cloned; for example Character objects in V3 get replaced by immediate Character objects in Spur.

Interesting things happen when moving methods.  In V3 a method's primitive number is embedded in the header, but in Spur there is a one but flag that identifies methods with a primitive, and the first bytecode is a 3-byte CallPrimitive bytecode if there is a primitive.  So cloning methods with primitives requires allocating three extra bytes and inserting the CallPrimitive bytecode at the start of the method.  That's an example of a simple transformation.  But a number of methods in Spur, for object allocation, object enumeration (allObjects, allInstances, etc) and indeed compiled methods, are different and so we need to compile the correct code for these methods since they don't, indeed can't exist in V3, because they're incompatible with V3.  So what we do is 

a) compile from source in the host to a CompiledMethod in the host
b) use the disassembler I wrote as part of my MethodMassage assembler I wrote to generate assembly (a sequence of Message objects, one per bytecode with the same signatures used in Context's interpretation messages such as pushReceiverVariable: etc, but you could use Marcus' assembler too)
c) process the set of literals to map them into proxies for objects in the Spur heapMemory.
d) use the assembler in MethodMassage to generate a new CompiledMethod
e) clone this into the Spur heapMemory

Up until now we haven't needed to run /any/ code in the Spur image.  But in cloning, given that Spur has a 22-bit per-object identityHash and V3 has only an 11-bit identityHash we at least need to rehash all hashed collections.  To make this convenient the simulator is extended to provide a perform:-like abstraction that allows us to send messages to specific objects in the heap and have them executed.  The simulator provides object:perform:withArguments: and uses its bytecode interpreter to execute methods.  If we wanted to evaluate arbitrary expressions we could compile a doit to a CompiledMethod, clone the method into heapMemory and provide e.g. object:withArgs:executeMethod:.

So with this approach
- the host is given god-like powers to reach inside the target heap and alter whatever it likes.  the target system doesn't have to be complete, or capable of execution.
- the target can still self-organise, being able to execute using the simulator's StackInterpreter
- no special VM support is needed; you get to use a normal Cog (or Spur Cog) VM for the host running at full speed
- you can deal with 64-bits from 32-bits or 32-bits from 64-bits; there is no relationship between word size in the host and word size in the target, beyond the fact that bytecode pcs are affected by the width of literals, so in a one literal method (methods also have a one word header) the first pc is 8 in 32-bits and 16 in 64-bits.

Now, the simulator is slooooooow.  Even so (IIRC) the V3 to Spur bootstrap takes about 10 minutes and the 32-bit Spur to 64-bit Spur bootstrap takes about 2 minutes.  But the StackInterpreter is slow because all of the code is full of expensive error-checking asserts.  I bet you could speed up the StackInterpreter simulator by at least an order of magnitude by using a special version of the bytecode compiler (e.g. Opal) that recompiled all of StackInterpreter, SpurMemoryManager et al to eliminate these asserts.   Earlier you've claimed that the difference between the StackInterpreter and Cog is about a factor of two.  That's a big under estimate.  While the ration doers depend on how much work is being done in Smalltalk vs how much work is done external to the system (since Cog only speeds up Smalltalk code) if you're talking about pure Smalltalk code the difference is more like 5 to 15 times faster.  So I think if you use Cog Spur and recompile without asserts you've be able to get a simulated StackInterpreter that was, say, a hundred to ten times sower than the (non-Oz) Stack VM, and depending on how much computation needs to be done in the host, you'd find performance was /better/ in this architecture than in the Oz multiple spaces VM.

Remember that Clément is stabilizing Sista and that will give us another factor of 3 performance boost for pure Smalltalk from Cog Spur.  Sista is well suited to optimizing the kinds of loops that exist in the simulator's StackInterpreter, so that code should be well-optimized, so if my estimate was correct that would mean three to thirty times slower than the Stack VM.  And it means you get out of the "hack and maintain a VM" business and focus on the bootstrap.


When you focus on the bootstrap using the above architecture
- the target system *doesn't even have to have a compiler*, since the host can be used to compile all source, or /any/ tools at all
- the target system *doesn't have to have a complete implementation of self reflection*.  While it still needs classes CompiledMethod, Behavior, ClassDescription, MethodDictionary, etc, these don't have to provide development-time methods such as CompiledMethod class>>newBytes:trailerBytes:nArgs:nTemps:nStack:nLits:primitive:, or ClassDescription>>addSelector:withMethod:notifying:.  The target only needs to support what the target needs to do.  If all you want is Transcript show: 'Hello world' a lot can be left out, and images below 1Mb are feasible.


Let me ask you to at least think about this before you respond and dismiss it.  I've been using it for a couple of years now as it was key to the V3 to Spur transition, and I like it and can see that with the right mirrors it can be very powerful.  Doru, Clement and I are intrigued by the possibilities of combining mirrors with GT ti provide really good tools for visualizing and manipulating objects in heapMemory. There could be real synergy of the Oz bootstrap took a similar approach.  I think you lose a lot of complexity and maintainance activity and gain a lot of power.  Worth thinking about.

HTH
On 20 ene 2016, at 9:03 a.m., Christophe Demarey <[hidden email]> wrote:

Hi Eliot,

Le 19 janv. 2016 à 19:29, Eliot Miranda a écrit :

Hi All,

    great news!  Where can I read a specification of the Oz VM facilities?

I do not know all the details of the Oz VM but basically, it is a standard stack interpreter vm specialized to be able to run 2 images at the same time on top of it. 
Guillermo made it possible by using one available bit in the object header of objects to mark the ownership of an object (e.g. is my object from image1 or image2?). Then, he mainly had to specialize VM primitives dealing with objects retrieval from memory. By example, he had to modify the garbage collector to set the right nil instance (yes, we have 2 images so 2 nil instances. we need to take the one of the active image) when an object is garbage collected; the primitive someObject has to return an object from the active image, etc.
There is also a way to switch execution from an image to the other just by switching the special objects array reference. 

The current implementation uses Cog  6.6.1and OzVM-GuillermoPolito.22.
I do not know if Guille has a more formal specification of the Oz VM.

If you have advices on what is the best way to handle two distinct object (memory) spaces in Spur, they will be welcomed :)

Cheers,
Christophe


_,,,^..^,,,_ (phone)

On Jan 19, 2016, at 6:29 AM, Christophe Demarey <[hidden email]> wrote:

Hi all,

In case you do not know, we work on bootstrapping Pharo, i.e. create a Pharo image from sources, not based on a previous image (well, we use a pharo image to produce it but no code / state from it).

This process will allow to define a minimal Pharo kernel (currently 52 packages but we could have it far smaller) and to modularize the whole image (currently packages have too much dependencies on packages already loaded into the image).
The bootstrap process also allows to write down the recipe to initialize a new image from scratch (some code is missing in the image or is wrong). In addition, I think we will clean a lot of historical objects that are not used anymore.

With the amazing work done by Guillermo Polito during his Phd (around Espell, Oz): https://guillep.github.io/files/publications/Poli15Thesis.pdfwe succeeded to get a first prototype of a bootstraped Pharo 5 image (from 5.392).
This prototype is able to run an eval command line handler and to log output / errors. Not all classes are yet initialized and you cannot yet save / restart this image but it is a big step forward.
It is a 4 mb image (could be half the size without unicode data). You can download it at: http://chercheurs.lille.inria.fr/~demarey/pmwiki/pub/pharo-bootstrap/pharo-bootstrap.zip.

Next steps are to have a bootstrapped image fully working, then to load packages on top of it (like network, sunit) to produce a minimal image.
Then, we need to implement an Oz VM on top of Spur.
After that, we need to work on a reliable way to build the bootstrap (not too sensitive to changes in the image).

Christophe.

-------
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "1 + 1"
2
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "'a' , 'b'"
'ab'
demarey@193-51-236-143:~/dev/rmod/bootstrap/bootstrap-2016-01-19$ ../pharo bootstrap.image --no-default-preferences eval "1 / 0"
ZeroDivide
SmallInteger>>/
UndefinedObject>>DoIt
OpalCompiler>>evaluate
OpalCompiler(AbstractCompiler)>>evaluate:
SmalltalkImage>>evaluate:

EvaluateCommandLineHandler>>no (source is Undeclared) 
no source in EvaluateCommandLineHandler>>evaluate: in Block: no source
BlockClosure>>on:do:
EvaluateCommandLineHandler>>evaluate:
EvaluateCommandLineHandler>>evaluateArguments
EvaluateCommandLineHandler>>activate
EvaluateCommandLineHandler class(CommandLineHandler class)>>activateWith:

BasicCommandLineHandler>>no (source is Undeclared) 
no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand: in Block: no source
BlockClosure>>on:do:
PharoCommandLineHandler(BasicCommandLineHandler)>>activateSubCommand:
PharoCommandLineHandler(BasicCommandLineHandler)>>handleSubcommand
PharoCommandLineHandler(BasicCommandLineHandler)>>handleArgument:

BasicCommandLineHandler>>no (source is Undeclared) 
no source in PharoCommandLineHandler(BasicCommandLineHandler)>>activate in Block: no source
BlockClosure>>on:do:
PharoCommandLineHandler(BasicCommandLineHandler)>>activate
PharoCommandLineHandler>>activate
PharoCommandLineHandler class(CommandLineHandler class)>>activateWith:

PharoCommandLineHandler class>>no (source is Undeclared) 
no source in PharoCommandLineHandler class>>activateWith: in Block: no source
NonInteractiveUIManager(UIManager)>>defer:
PharoCommandLineHandler class>>activateWith:
no source in BasicCommandLineHandler>>activateSubCommand: in Block: no source
BlockClosure>>on:do:
BasicCommandLineHandler>>activateSubCommand:
BasicCommandLineHandler>>handleSubcommand
BasicCommandLineHandler>>handleArgument:
no source in BasicCommandLineHandler>>activate in Block: no source

SmallInteger>>no (source is Undeclared) 

UndefinedObject>>no (source is Undeclared) 

AbstractCompiler>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

BlockClosure>>no (source is Undeclared) 

EvaluateCommandLineHandler>>no (source is Undeclared) 

EvaluateCommandLineHandler>>no (source is Undeclared) 

CommandLineHandler class>>no (source is Undeclared) 

BasicCommandLineHandler>>no (source is Undeclared) 

BasicCommandLineHandler>>no (source is Undeclared) 

PharoCommandLineHandler>>no (source is Undeclared) 

UIManager>>no (source is Undeclared) 

UndefinedObject>>no (source is Undeclared) 

CommandLineUIManager>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

DelayMicrosecondScheduler>>no (source is Undeclared) 

BlockClosure>>no (source is Undeclared) 

SmalltalkImage>>no (source is Undeclared) 

WeakArray class>>no (source is Undeclared) 


ps: source cannot be displayed because there is no formatter available in the bootstrap
_,,,^..^,,,_
best, Eliot
123