On 31 mai 2010, at 15:26, Mariano Martinez Peck wrote:
I answer above.
On Tue, May 25, 2010 at 2:35 PM, Simon Denier <simon.denier(a)inria.fr> wrote:
On 25 mai 2010, at 14:06, Mariano Martinez Peck wrote:
Hi Moosers. I am doing little experiments to
export/serialize big graph of objects using ImageSegment. I though that MooseModel was a
good candidate. And I even remember Simon's wishes for copying them. But I have a
couple of questions:
1) Which is the bigger autogenerated MooseModel I can get to test? For the moment I am
evaluating "MooseModel installDefaultModels". and then I export
"MooseModel root". Is there a bigger one I can use? how ?
Take a look at the MooseScripts class, class-side. There are a number of methods to
create moose models from the image itself. In order of importance: Network << Moose
<< Pharo
With network, you won't have any problem. With a model of Moose itself, it's fast
enough to do lots of test yet you can still improve things. Then a Pharo model is
certainly a good scalability test.
This was very helpful. Thanks
2) How is the root or any other MooseModel normally exported? Which methods? which
technology ? Can you give me an example of the standard way to export/serialize/copy a
MooseModel ? The only thing I saw is MooseModel class >> export: aModel to:
aStream
I just open a file and send it as Stream?
Depends...
- File persistency is done in the MSE format and using Fame to serialize entities in
MSE.
Just take a look at MooseModel>>exportToMSEStream:
- To clone a model, just use MooseModelCopier>>copyModel: (this was a simple
experiment to make practical copies of large MooseModels. Or rather to show that simple
copy did not scale well on large MooseModel right now).
Here I have a couple of questions.
MooseModelCopier new timedCopyModel: MooseModel root -> 123
MooseModelCopier new timedCopyModel: MooseModel root first -> 3076
I don't understand how copying the root can be less than that copying an element of
the root.
Shouldn't copy the whole graph in case I want to copy the root? I was doing all my
benchmarks with the root but in the method timedCopyModel: I saw the example in comment:
self new timedCopyModel: MooseModel root second
Another question, you said "Or rather to show that simple copy did not scale well on
large MooseModel right now"
Which is the simple copy you meant? Just aMooseModel copy ? deepCopy? clone ?
I want to compare for example the time with that simple way and with your copier.
I will try to answer all of the above in two single statements to clarify:
1) MooseModelCopier is the "simple" copy. It copies elements by traversing all
of them, while using a custom traversal strategy to avoid traversing the whole graph. So
it's a reasonable implementation of deepCopy.
2) It was written very quickly to do an experiment and show that even this simple (but not
so naive) strategy did not work for large models. So it was meant to copy a standard model
with packages, classes... That's why you got nothing when running on MooseModel root,
because it knows nothing about the recursive structure of root and copies nothing. As far
as I know, nobody uses this class for standard Moose operations right now.
3) Suppose that I copy/export somehow a MooseModel (suppose the root) to a file. I take
another Moose image, I load the file, objects are alive again and I replace MooseModel
rootModel with the new object. How do I know if the copy/export worked correctly ? If I
do it in the same image, I can have both, but how can I compare them to be sure everything
was done ok ? method #= has no sense as it will use Object with is #==. So...any idea to
know if the MooseModel I export and load again with ImageSegment is really working or not?
I would change the tests setup to export/import the test model and run tests on it
(that's what I did to test the MooseModelCopier).
Where did you do that? I didn't find tests for MooseModelCopier?
Where can I change the export/import setup? I guess there is a TestResource somewhere.
Maybe in MooseModelTestResource ? or in subclasses?
What I did (again, it was an experiment, so quick and dirty):
Take resource classes like LANPackageTestResource, FAMIXNavigationPluginTestsResource
setUp
| oldModel |
model := MooseModel new.
self importModel.
oldModel := model.
model := MooseModelCopier new copyModel: model.
Transcript show: model == oldModel
Then tests are run on a model copy and should be all green (we don't compare the copy
and the original though)
--
Simon