vision-dbms / vision

The master repository for the Vision database system.
https://vision-dbms.com
BSD 3-Clause "New" or "Revised" License
27 stars 12 forks source link

Container handle processing and cycle detection changes in the 8.1 garbage collector #16

Closed MichaelJCaruso closed 7 years ago

MichaelJCaruso commented 7 years ago

Building a bootstrap database on the Mac uncovered a bug in the release 8.1 version of the garbage collector. Note that this is a logic issue and NOT a MacOS specific problem; however, it does not manifest itself in similar fashion on other platforms. In all likelihood that is the result of timing differences in the re-use of reclaimed memory but that hypothesis has not been confirmed.

Current Status

The goal of this pull request is to address this and whatever other issues prove to be related. Currently, the changes found here do not yet do that. They do, however:

Relative to the primary bug fix goals of this request, the following changes are currently present as well:

Problem Analysis

In a nutshell, it appears that the 8.1 garbage collector is failing to retain containers indirectly referenced by handle alone. The following structure exposes the problem:

   (Vector)
      |
      |     ... POP via USegStore
      |
      V
  (Closure)
      |
      |     ... Handle via Context
      |
      V
  (Context) ... only reference is from Closure handle
      |
      |     ... Handle via Descriptor Store
      |
      V
   (Store)  ... only reference is from Context handle

There are a couple of different things going on that jointly conspire to cause a problem:

Without going into too much detail regarding the discovery algorithm, here's what appears to be happening:

VCommitter commented 7 years ago

Crud. This cycle garbage collection was introduced because it fixed a memory leak in the datafeeds that rendered Interface BatchFeedManager's batching ineffective. Without the cycle detection the batching actually doesn't conserve memory; without the cycle detection uploads using Interface BatchFeedManager have the same memory consumption as if it weren't used.

We can put this into master as an incremental step but I hesitate to put it into a release branch; it will break most necessary uses of Interface BatchFeedManager.

MichaelJCaruso commented 7 years ago

Could not know that, but that sounds like a great production test case.

beepoxis commented 7 years ago

Now that you mention it, I'm almost certain I baked a reproducer into the ivr test suite

VCommitter commented 7 years ago

Does this pull request allow bootstraps to be built where they otherwise fail to build? Or does it succeed with a warning?

MichaelJCaruso commented 7 years ago

The former. Without it, bootstrap fails. With it, bootstrap quietly and correctly succeeds.

VCommitter commented 7 years ago

Is this meant to be a "pure" refactor now? I didn't see the mark() -> startMark() change to the Cycle Detection visitor so I thought you might be pull requesting the refactor that isn't meant to change or fix functionality?

MichaelJCaruso commented 7 years ago

This is a pure re-factor at the moment with no functionality changes except for the two bug fixes mentioned in the updated pull request. I'll submit the change you mention now.