Does Restic Seperate tree and data into different packs in the index file?

I just noticed that in the design docs, it states that tree and data blobs are stored in same pack files, but after running restic cat on the index file, I notice otherwise. Please suggest changes.

They are not saved in the same pack, for good reason, e.g. tree blobs should be caches why data blobs shouldn’t. That is, mixed pack files are not (or better: no longer) created.

However, the design document does allow mixed pack files, so having these fully complies with the specification.

There was some discussion when compression was added where I proposed to add the blob type as a pack attribute when saving blob information in a pack file or an index file, but this was discarded, see Implement compression support by MichaelEischer · Pull Request #3666 · restic/restic · GitHub

But the design documentation specifies they’re still mixed, and the use of this is for tree blobs to be cached quicker?

I had a look at the design document:
“In repository format version 1, data and tree blobs should be stored in separate pack files. In version 2, they must be stored in separate files. Compressed and non-compress blobs of the same type may be mixed in a pack file.”

And yes, the reason for separating them is that caching tree blobs gives an big performance boost for remote repositories.

1 Like

Yes the documentation does state that, then the example of index structure given in the design docs showed mixed data and tree blob in a single pack file. Hence causing confusion.

I’ve opened doc: Remove mixed pack files from index example by MichaelEischer · Pull Request #4242 · restic/restic · GitHub . Did I miss anything?

No, I think its clear now. Thank you :slight_smile:

@MichaelEischer

“In repository format version 1, data and tree blobs should be stored in separate pack files. In version 2, they must be stored in separate files. Compressed and non-compress blobs of the same type may be mixed in a pack file.” (References — restic 0.16.4 documentation)

Finding it hard to understand this statement.

In version 1, data and tree blobs should be stored in the same pack files?

In version 2, data and tree blobs must be stored in separate pack files?

Very old restic versions (before the cache was introduced) just combined data and tree blobs into pack files irrespective of the blob type. With the introduction of the cache, all new pack files either contain data or tree blobs but never both. To not break backwards compatibility, version 1 still allows pack files to contain a mixture of data and tree blobs. With version 2, it is no longer allowed.