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

Remove usage of explicit leaves #108

Merged
merged 21 commits into from
Mar 31, 2021

Conversation

make-github-pseudonymous-again
Copy link
Member

Fixes #104, fixes #107.

Everything went as planned except that we needed to mock the child of
the deleted node when it is an implicit leaf.

The losses:
This change puts additional load on:
  - delete_case{3,4,5},
  - insert_case3, and
  - rotate_{left,right}

This load comes from nullchecks before color checks and parent
assignments.
These checks should only be needed at the lowest levels of the fixed
path because of the red-black tree properties.
They could perhaps be circumvented entirely by adding additional mocked
leaves to the sibling of the child of the deleted node. This should
somehow be amortized by the facts that there is at most one deletion per
node created and that each node now costs less to create (because of the
allowed null pointers, see gains).
If property access is always preceded by a nullcheck and if an explicit
preceding nullcheck is somehow optimized away by the compiler, then perhaps
nothing needs to be done. We have to profile this.

The gains:
  - all Leaf children are replaced by null (>1/6 space save)
  - all isLeaf() calls are replaced by nullchecks: really faster? Should
    be since I assume each method call must be preceded by a null check
    internally?

Also we should rewrite delete_one_child to completely avoid this mocking
in case the deleted node is red. I left a TODO note about this.

This is progress on #104.
This avoids creating a mocked leaf in that case.
The coverage report seems to indicate that some additional pruning is
possible in delete_one_child. Need to investigate.
Indeed the previous coverage report gave the right insight.
This avoids using multiple Hidden Classes and enables inline caching.

Fixes #107.
This makes the config easier to parse.
The goal is to have case number zero for the base case of the recursion.
I had to do each of these renaming operations individually as otherwise
git would register a consequent amount of churn.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant