Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply all changes from Configura to the public MPS. #76

Closed
wants to merge 3 commits into from

Conversation

gareth-rees
Copy link
Member

These changes were originally implemented as custom work for Configura on the custom/cet/main branch. With permission from the customer (see e-mail from Göran Rydqvist) we apply them to the public MPS, and integrate the custom documentation and interfaces into the public manual and headers.

The custom interfaces are as follows:

  1. The Transforms interface provides a mechanism to rewrite references throughout the MPS-managed heap;

  2. The Arena extension/contraction callbacks provide a mechanism for the client to register stack decoding callbacks on Windows managed runtime;

  3. The hash arrays flag for allocation points prevents the MPS from aggressively collecting address-based hash tables.

These changes were originally implemented as custom work for Configura
on the custom/cet/main branch. With permission from the customer (see
e-mail https://info.ravenbrook.com/mail/2022/01/18/12-53-38/0/ from
Göran Rydqvist) we apply them to the public MPS, subject to future
work to integrate the custom documentation and interfaces into the
public manual and headers.

The custom interfaces are as follows:

1. The Transforms interface provides a mechanism to rewrite references
throughout the MPS-managed heap;

2. The Arena extension/contraction callbacks provide a mechanism for
the client to register stack decoding callbacks on Windows managed
runtime;

3. The hash arrays flag for allocation points prevents the MPS from
aggressively collecting address-based hash tables.
* Move transforms sources to the core sections of the makefiles.
* Move function declarations to the public header mps.h.
* Update copyright notices for transforms code.
* Remove references to Configura from the comments.
* Remove trailing whitespace.
* Translate design to reStructuredText.
* Move documentation to reference section of manual.
* Add warning about unsuitability when ambiguous references may exist.
* Move type and macro declarations to the public header mps.h.
* Move documentation to appropriate sections of manual.
Copy link
Member Author

@gareth-rees gareth-rees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some review to be going on with.

@@ -113,15 +113,16 @@ LONG WINAPI ProtSEHfilter(LPEXCEPTION_POINTERS info)

/* ProtSetup -- set up the protection system */

static void *vehHandle;
Copy link
Member Author

@gareth-rees gareth-rees Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a comment to explain why it's global. I can only guess that this is to assist with debugging? The name should start with prot since it belongs to the prot module.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPH to change variable name and investigate reason for making global

Comment on lines +49 to +51
AVER(mps_old_list != NULL);
AVER(mps_new_list != NULL);
/* count: cannot check */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check the public names (starting mps_) or the internal names consistently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPH todo

destroyed */
if (transform->oldToNew != NULL)
CHECKD(Table, transform->oldToNew);
CHECKL(BoolCheck(transform->aborted));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can also check that an aborted transform has a valid table.

CHECKL(!transform->aborted || transform->oldToNew != NULL);

transformTableAlloc,
transformTableFree,
transform,
0, 1); /* these can't be old references */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have constants for these values, something like this:

#define TransformUnusedKey ((TableKey)0)
#define TransformDeletedKey ((TableKey)1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPH todo

{
Seg seg;
AVER(SegOfAddr(&seg, transform->arena, old_list[i]));
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could assert that the old ref is not equal to TransformUnusedKey or TransformDeletedKey here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPH todo

/* Condemn generation containing seg if not already condemned. */
gen = PoolSegPoolGen(SegPool(seg), seg)->gen;
AVERT(GenDesc, gen);
if (RingIsSingle(&gen->trace[trace->ti].traceRing))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use TraceSetIsMember(gen->activeTraces, trace) here to avoid needing to know so many details of the data structures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPH todo

Arena arena;
Globals globals;
Trace trace;
double mortality;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mortality does not seem to be used anywhere.

Comment on lines +342 to +343
/* I'm not sure why the interface is defined this way. RB 2012-08-03 */
TransformDestroy(transform);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an annoying wart on the interface — I think we should fix this before making the interface public, even though this requires the customer to update their code.

trace->fix = transformFix;
trace->fixClosure = transform;

res = TraceStart(trace, 1.0, 0.0);
Copy link
Member Author

@gareth-rees gareth-rees Jan 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These estimates of the mortality and finishing time do not seem very good! Since this is non-incremental, we don't need accurate estimates, but maybe there is a better way to communicate that to TraceStart

Comment on lines +334 to +335
/* Force the trace to complete now. */
ArenaPark(globals);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the arena ends up parked, we need to update the arena state documentation to mentation that mps_transform_apply() parks the arena.

Copy link
Member Author

@gareth-rees gareth-rees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments. I haven't looked very closely at ztfm.c since it is a test case.

Comment on lines +79 to +81
* How the implementation is an add-on to the MPS.

* How the code is kept separate from the mainstream MPS.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These points no longer need to be written.


* How the code is kept separate from the mainstream MPS.

* Why it has its own hash table implementation (no good reason).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true any more.

Comment on lines +143 to +144
If the transform was successfully applied, it is destroyed, as if
:c:func:`mps_transform_destroy` had been called.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to avoid this (see above).

Comment on lines -202 to +205
#. Edit the index of releases (``release/index.html``) and add the
#. Edit the index of releases (``release/index.*``) and add the
release to the table, in a manner consistent with previous releases.

#. Edit the index of versions (``version/index.html``) and add the
#. Edit the index of versions (``version/index.*``) and add the
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change makes sense — the indexes for the public MPS are still in HTML format.

mps_transform_destroy(t1);
after(myrootExact, perset, 1, -10, 2, +10);

/* Two transforms, both live [-- not supported yet. RHSK 2010-12-16] */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is true that multiple transforms are not supported yet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPH investigate

Comment on lines +1269 to +1279
/* testscriptB -- create pools and objects; call testscriptC
*
* Is called via mps_tramp, so matches mps_tramp_t function prototype,
* and use trampDataStruct to pass parameters.
*/

typedef struct trampDataStruct {
mps_arena_t arena;
mps_thr_t thr;
const char *script;
} trampDataStruct;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use mps_tramp any more, so this needs to be updated.

trampData.arena = arena;
trampData.thr = thr;
trampData.script = script;
testscriptB(&trampData, sizeof trampData);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only call of testscriptB so perhaps it could be inlined here.

/* 1<<19 == 524288 == 1/2 Mebibyte */
/* 16<<20 == 16777216 == 16 Mebibyte */

testscriptA("Arena(size 500000000), "
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only call to testscriptA so perhaps it could be inlined here.

Comment on lines -222 to -223
$(PFM)\$(VARIETY)\cvmicv.exe: $(PFM)\$(VARIETY)\cvmicv.obj \
$(PFM)\$(VARIETY)\mps.lib $(FMTTESTOBJ) $(TESTLIBOBJ)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cvmicv.c contains coverage tests for the CVM interface, since the code being tested is now all part of the mainline, should not these coverage tests be migrated as well?

@rptb1
Copy link
Member

rptb1 commented Jan 13, 2023

Do we want to make Configura's MPS synchronized with the public MPS for simplicity, ease of delivery, etc.? I understand from @thejayps that some editing may have occurred in this work and that he had to re-add (without source control) work to do with interior pointers back to the code base.

@rptb1
Copy link
Member

rptb1 commented Jan 13, 2023

We have to be extraordinarily careful about this. It affects thousands of real users. I'm working with @thejayps to locate the ends of all the worms in this particular can.

@rptb1
Copy link
Member

rptb1 commented Feb 20, 2023

Blocked pending work planned in https://info.ravenbrook.com/mail/2023/02/06/10-44-45/0/ , which includes a full risk assessment and double-checking of this work.

@rptb1 rptb1 added blocked Unable to proceed. See comment for reason. high risk This work is or would be of high risk of introducing defects. labels Feb 20, 2023
@thejayps thejayps added the optional Will cause failures / of benefit. Worth assigning resources. label Feb 20, 2023
@thejayps
Copy link
Contributor

We have assigned this as priority "optional" since we are currently researching the associated issue in another way. This pull request could become of higher importance later.

@rptb1
Copy link
Member

rptb1 commented Jun 12, 2023

Added "pending" label because @gareth-rees ' comments require actions as if they were from a formal review.

@rptb1
Copy link
Member

rptb1 commented Nov 6, 2023

This work is subsumed by #213 , #214 , #215 , and #230 and so we will not merge this branch. Postmortem was identified as a requirement but was already implemented in a compatible way in the public MPS.

@rptb1 rptb1 closed this Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Unable to proceed. See comment for reason. high risk This work is or would be of high risk of introducing defects. optional Will cause failures / of benefit. Worth assigning resources. pending Something needs doing, even if closed.
3 participants