----boundary-LibPST-iamunique-1996748822_-_-
Content-type: text/plain
(I've just fired-up the mail program when Doug's message arrived.
His example also points to the problem discussed below.
With the proposal described below, the assiggment rw := A.r
in his example would not be possible.)
Hi All!
Here is another little safety-tightening proposal for BB 1.5:
to allow a limited export for any pointer types based on records
or arrays.
The effect would be to prohibit explicit assignments to variables
of such pointer types except in the defining module.
This would allow the server module e.g. to guarantee that the
client has only one valid pointer to access and manipulate (via
calls to procedures in the server module) a data structure, so that
the server could reuse the data structure and return it to the
client.
I am dealing with some convoluted calculations that are hard to
have confidence in, whereas efficiency concerns that make me
wish for such a mechanism, are significant (factor 1.5 for CPU
time).
The description of the problem is attached -- there seems to be a
kind of a half-way quasi-solution, but it is incomplete and implies
serious inefficiencies of its own.
Cheers
Fyodor Tkachov
--------------------------------------------------------------
PS The problem description.
The mechanism we are talking about reduces the CPU time by a
factor of 1.5, which may translate into saved hours -- perhaps
days as the complexity of interesting problems in this family is
practically unlimited from above.
Suppose module A exports a pointer type, called Register, to be
used to provide an intermediate storage in a special kind of
calculations.
A Register object contains internal data structures whose size is
adapted dynamically (it is extremely hard to predict a priori what
could be needed).
Module A maintains a pool of Registers; the size of the pool is
also adapted dynamically.
Module A provides a Register from the pool to the client upon
request.
There is also a mechanism to "release" a Register back into the
pool when it is no longer needed.
It is this reuse of Registers (as profiling shows) that is responsible
for the 1.5 speed-up factor.
However, a variant of the problem of dangling pointers emerges:
the client program may preserve (by programmer's mistake) a
copy of the pointer to a Register that has already been released
into the pool and then requested from the pool again.
A quasi-solution is to embed the pointer to Register into an
auxiliary exported type:
Interface* = POINTER TO LIMITED r: Register RECORD.
All manipulations with Registers by the client (including release of
Registers) are supposed to be performed via the Interface
objects.
Furthermore, a new Interface object should be allocated each
time a Register is requested, even if the Register it refers to is
being reused.
Then the server can guarantee that even if the client maintains
several references to an Interface object, once a Register has
been "released" (via the corresponding Interface object), the field
r is NILed and erroneous access to the Register becomes
impossible.
Since Interface objects are much smaller than the Register
objects, garbage is accumulated much slower and the 50%
overhead is much reduced.
But then there is the problem of access to the data structures
hidden inside the Register: it's a bunch of arrays which the client
should be able to traverse.
If one gives client pointers to those arrays, the problem we
started from reemerges.
The only alternative is to give the client copies of the hidden
arrays, which, again, is expensive as the client may need to look
at the data several times.
May be I am missing a good solution.
--------------------------------------------------------------
--------------------------------------------
To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
blackbox-request{([at]})nowhere.xy
To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.
Send any problem reports or questions related to this email list to the list owner at
owner-blackbox{([at]})nowhere.xy
Current posting policy:
a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.
b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.
----boundary-LibPST-iamunique-1996748822_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIChJJ3ZlIGp1c3QgZmlyZWQtdXAgdGhlIG1haWwg
cHJvZ3JhbSB3aGVuIERvdWcncyBtZXNzYWdlIGFycml2ZWQuXHBhcg0KSGlzIGV4YW1wbGUgYWxz
byBwb2ludHMgdG8gdGhlIHByb2JsZW0gZGlzY3Vzc2VkIGJlbG93LlxwY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mcgYW55IG92ZXJoZWFkLlxwYXINClxw
YXINCmIpIElmLCBmb3Igc29tZSByZWFzb24sIHlvdSBjYW5ub3QgcG9zdCBmcm9tIHRoZSBhZGRy
ZXNzLCBieSB3aGljaCB5b3UgYXJlIHN1YnNjcmliZWQsIHlvdXIgbWVzc2FnZSB3aWxsIGJlIG1v
ZGVyYXRlZCB0byBhdm9pZCBzcGFtLiBQbGVhc2UgdW5kZXJzdGFuZCB0aGF0IG1vZGVyYXRpb24g
d2lsbCBvZnRlbiBjYXVzZSBzb21lIGRlbGF5LCBpbiBwYXJ0aWN1bGFyIG92ZXIgd2Vla2VuZHMg
b3IgaG9seWRheXN9fQBkZXJhdA==
----boundary-LibPST-iamunique-1996748822_-_---
Received on Wed Jul 09 2003 - 23:09:20 UTC
This archive was generated by hypermail 2.3.0
: Thu Sep 26 2013 - 06:29:09 UTC