Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Object-oriented access bottleneck
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] Object-oriented access bottleneck
From: Nuutti Kotivuori <naked+caml@naked.iki.fi>

[...]
> What this all amounts to is that you cannot store data inside classes
> at all, if some parts of it might require performance critical
> work. The problem can be lessened by placing the data in a record,
> which is only referenced from the object and passed around - or
> something similar - but that adds complexity into the whole thing.
> 
> So - I am asking if I'm correct in my deductions here, or if I missed
> some important point. Or if there's an alternative way to circumvent
> this restriction.
> 
> To summarize - is there any way to have some function (or method or
> whatever) that is able to access object member data, without the
> overhead of a lazy binding function call? Preferably ofcourse such a
> function should be eligible to be inlined.

I think the correct name is "late binding".
But you're correct. Classes are not very good for performance, and
nothing serious is done for their optimization.

As you remarked already, the object model chosen in ocaml makes final
methods mostly irrelevant. There is however one way to tell the
compiler that a specific method code should be used, but this only
works for calls inside a class:
   inherit c ... as super
   method p = ... super#m ...
In this case, if we know statically the class c, we exactly know the
code referenced by super#m. However, this information is not used
currently (and is probably not what you want for your own code). And
there is no way to tell this for a method defined in the same class.

The approach you suggest of using a record sounds like a good idea.
This will make the problem clearer: either you really need objects,
and external functions are just there for performance; or you didn't
need them anyway, and you will be able to rewrite everything as
functions with a record parameter.
Note also that this is not as clumsy as it looks: even without records,
you can already pass (by hand) all non-mutable fields to external
functions (labelled parameters handy there?)

If your problem requires objects, I'm interested if you can show me
some code: I'm in the process of making extensive changes to object
compilation, and I need serious performance sensitive benchmarks.
(All my programs using objects call them only a few times, so that
method calls could be 10 times slower and I wouldn't care)

Regards,

Jacques Garrigue

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners