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

Change Tree.t representation to use lazy contents values #1285

Merged
merged 7 commits into from
Feb 5, 2021

Conversation

craigfe
Copy link
Member

@craigfe craigfe commented Feb 5, 2021

This changes the type of trees to support lazy contents values:

- type t = Node of lazy_node | Contents of blob * metadata
+ type t = Node of lazy_node | Contents of lazy_contents

This means that contents are (internally) handled symmetrically to nodes: as unforced pointers to values in the underlying stores wherever possible. The user-facing changes are:

  • Tree.destruct returns unforced contents pointers that can be dereferenced with Tree.Contents.force.
  • Tree.of_hash and Tree.shallow now take kinded hashes with appropriate metadata.

This is motivated by #1284, which stems from the fact that we don't currently support "shallow" tree leaves. With this change, it's easy to extend Tree.shallow to support this, and I've added @smelc's now-working test case from that issue here. (Thanks!)

Fixes #1284.

src/irmin/tree.ml Outdated Show resolved Hide resolved
src/irmin-graphql/server.ml Outdated Show resolved Hide resolved
src/irmin/tree.ml Outdated Show resolved Hide resolved
@samoht
Copy link
Member

samoht commented Feb 5, 2021

That looks great and simplify quite a few bits of tree.ml which is nice (especially the merge function!). I think we used to have a kinded_hash in previous version of irmin, but that's fine to re-introduce these now that there is a clear goal (ie. work with shallow trees).

Copy link
Contributor

@Ngoguey42 Ngoguey42 left a comment

Choose a reason for hiding this comment

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

LGTM!

@craigfe craigfe merged commit 8063155 into mirage:master Feb 5, 2021
craigfe added a commit to craigfe/opam-repository that referenced this pull request Feb 16, 2021
… irmin-chunk, irmin-pack, irmin-test, irmin-http, irmin-unix, ppx_irmin, irmin-bench, irmin-graphql, irmin-containers, irmin-mirage-git and irmin-mirage-graphql (2.5.0)

CHANGES:

### Changed

- **irmin**
  - `Store.Tree.remove` is now much faster when operating on large directories.
    The commits following removals are also much faster. (mirage/irmin#1289, @Ngoguey42)

  - Changed `Store.Tree.{of_hash, shallow}` to take kinded hashes, allowing the
    creation of unforced contents values. (mirage/irmin#1285, @craigfe)

  - Changed `Tree.destruct` to return _lazy_ contents values, which may be forced
    with `Tree.Contents.force`. (mirage/irmin#1285, @craigfe)

- **irmin-bench**
  - New features in benchmarks for tree operations (mirage/irmin#1269, @Ngoguey42)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store.Tree.shallow breaks hash stability on `Contents nodes
3 participants