Merge pull request #22221 from MichaelEischer/index-jsontext-decode

Speed up index decoding using Go 1.27's jsontext
This commit is contained in:
Michael Eischer authored and GitHub committed 2026-11-28 12:36:24 +01:00
commit 15e1e33a19
7 files changed
+678 -17

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
Enhancement: Speed up index decoding by 50%
Loading the repository index is now roughly 50% faster.
https://github.com/restic/restic/pull/22221
+1 -17
View File
@@ -526,29 +526,13 @@ func (idx *Index) merge(idx2 *Index) error {
// DecodeIndex unserializes an index from buf.
func DecodeIndex(buf []byte, id restic.ID) (idx *Index, err error) {
debug.Log("Start decoding index")
idxJSON := &jsonIndex{}
err = json.Unmarshal(buf, idxJSON)
idx, err = decodeIndexJSON(buf)
if err != nil {
debug.Log("Error %v", err)
return nil, errors.Wrap(err, "DecodeIndex")
}
idx = NewIndex()
for _, p := range idxJSON.Packs {
packID := idx.addToPacks(p.ID)
for _, blob := range p.Blobs {
idx.store(packID, pack.Blob{
BlobHandle: restic.BlobHandle{
Type: blob.Type,
ID: blob.ID},
Offset: blob.Offset,
Length: blob.Length,
UncompressedLength: blob.UncompressedLength,
})
}
}
idx.ids = append(idx.ids, id)
idx.final = true
+37
View File
@@ -0,0 +1,37 @@
//go:build !go1.27
package index
import (
"encoding/json"
"github.com/restic/restic/internal/repository/pack"
"github.com/restic/restic/internal/restic"
)
// decodeIndexJSON unserializes an index using encoding/json.
func decodeIndexJSON(buf []byte) (*Index, error) {
idxJSON := &jsonIndex{}
err := json.Unmarshal(buf, idxJSON)
if err != nil {
return nil, err
}
idx := NewIndex()
for _, p := range idxJSON.Packs {
packID := idx.addToPacks(p.ID)
for _, blob := range p.Blobs {
idx.store(packID, pack.Blob{
BlobHandle: restic.BlobHandle{
Type: blob.Type,
ID: blob.ID},
Offset: blob.Offset,
Length: blob.Length,
UncompressedLength: blob.UncompressedLength,
})
}
}
return idx, nil
}
@@ -0,0 +1,281 @@
//go:build go1.27
package index
import (
"bytes"
"encoding/json/jsontext"
"io"
"math"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository/pack"
"github.com/restic/restic/internal/restic"
)
// Bits for the members each object in the index format defines. A repeated
// known member is rejected here.
const (
indexSeenPacks = 1 << iota
)
const (
packSeenID = 1 << iota
packSeenBlobs
)
const (
blobSeenID = 1 << iota
blobSeenType
blobSeenOffset
blobSeenLength
blobSeenUncompressedLength
)
// decodeIndexJSON directly streams the index JSON into an Index without intermediate objects.
// Hand-rolled decoder for packJSON to significantly improve performance.
func decodeIndexJSON(buf []byte) (*Index, error) {
// use custom duplicate name check as jsontext's one is much slower.
dec := jsontext.NewDecoder(bytes.NewBuffer(buf), jsontext.AllowDuplicateNames(true))
idx := NewIndex()
if err := assertJSONKind(dec, jsontext.KindBeginObject); err != nil {
return nil, err
}
var seen uint
for dec.PeekKind() != jsontext.KindEndObject {
key, err := dec.ReadValue()
if err != nil {
return nil, err
}
switch string(key) {
case `"packs"`:
if err := markField(&seen, indexSeenPacks, "packs"); err != nil {
return nil, err
}
if err := decodePacksJSON(dec, idx); err != nil {
return nil, err
}
default:
// ignore unknown keys (e.g. historical "supersedes")
if err := dec.SkipValue(); err != nil {
return nil, err
}
}
}
if err := assertJSONKind(dec, jsontext.KindEndObject); err != nil {
return nil, err
}
tok, err := dec.ReadToken()
switch {
case errors.Is(err, io.EOF):
case err != nil:
return nil, err
default:
return nil, errors.Errorf("trailing data after index JSON: %v", tok.Kind())
}
return idx, nil
}
func assertJSONKind(dec *jsontext.Decoder, want jsontext.Kind) error {
tok, err := dec.ReadToken()
if err != nil {
return err
}
if tok.Kind() != want {
return errors.Errorf("expected %v, got %v", want, tok.Kind())
}
return nil
}
func decodePacksJSON(dec *jsontext.Decoder, idx *Index) error {
if err := assertJSONKind(dec, jsontext.KindBeginArray); err != nil {
return err
}
for dec.PeekKind() != jsontext.KindEndArray {
if err := decodePackJSON(dec, idx); err != nil {
return err
}
}
return assertJSONKind(dec, jsontext.KindEndArray)
}
func decodePackJSON(dec *jsontext.Decoder, idx *Index) error {
if err := assertJSONKind(dec, jsontext.KindBeginObject); err != nil {
return err
}
var (
packIndex uint32
seen uint
pending []pack.Blob
)
for dec.PeekKind() != jsontext.KindEndObject {
key, err := dec.ReadValue()
if err != nil {
return err
}
switch string(key) {
case `"id"`:
if err := markField(&seen, packSeenID, "id"); err != nil {
return err
}
v, err := dec.ReadValue()
if err != nil {
return err
}
var packID restic.ID
if err := packID.UnmarshalJSON(v); err != nil {
return err
}
packIndex = idx.addToPacks(packID)
for _, blob := range pending {
idx.store(packIndex, blob)
}
pending = nil
case `"blobs"`:
if err := markField(&seen, packSeenBlobs, "blobs"); err != nil {
return err
}
if err := assertJSONKind(dec, jsontext.KindBeginArray); err != nil {
return err
}
for dec.PeekKind() != jsontext.KindEndArray {
blob, err := decodeBlobJSON(dec)
if err != nil {
return err
}
if seen&packSeenID != 0 {
idx.store(packIndex, blob)
} else {
pending = append(pending, blob)
}
}
if err := assertJSONKind(dec, jsontext.KindEndArray); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
if err := assertJSONKind(dec, jsontext.KindEndObject); err != nil {
return err
}
if seen&packSeenID == 0 {
return errors.Errorf("pack without ID found")
}
return nil
}
func decodeBlobJSON(dec *jsontext.Decoder) (pack.Blob, error) {
if err := assertJSONKind(dec, jsontext.KindBeginObject); err != nil {
return pack.Blob{}, err
}
var (
blob pack.Blob
seen uint
)
for dec.PeekKind() != jsontext.KindEndObject {
key, err := dec.ReadValue()
if err != nil {
return pack.Blob{}, err
}
switch string(key) {
case `"id"`:
if err := markField(&seen, blobSeenID, "id"); err != nil {
return pack.Blob{}, err
}
v, err := dec.ReadValue()
if err != nil {
return pack.Blob{}, err
}
if err := blob.ID.UnmarshalJSON(v); err != nil {
return pack.Blob{}, err
}
case `"type"`:
if err := markField(&seen, blobSeenType, "type"); err != nil {
return pack.Blob{}, err
}
v, err := dec.ReadValue()
if err != nil {
return pack.Blob{}, err
}
if err := blob.Type.UnmarshalJSON(v); err != nil {
return pack.Blob{}, err
}
case `"offset"`:
if err := markField(&seen, blobSeenOffset, "offset"); err != nil {
return pack.Blob{}, err
}
blob.Offset, err = decodeJSONUint(dec)
if err != nil {
return pack.Blob{}, err
}
case `"length"`:
if err := markField(&seen, blobSeenLength, "length"); err != nil {
return pack.Blob{}, err
}
blob.Length, err = decodeJSONUint(dec)
if err != nil {
return pack.Blob{}, err
}
case `"uncompressed_length"`:
if err := markField(&seen, blobSeenUncompressedLength, "uncompressed_length"); err != nil {
return pack.Blob{}, err
}
blob.UncompressedLength, err = decodeJSONUint(dec)
if err != nil {
return pack.Blob{}, err
}
default:
if err := dec.SkipValue(); err != nil {
return pack.Blob{}, err
}
}
}
if err := assertJSONKind(dec, jsontext.KindEndObject); err != nil {
return pack.Blob{}, err
}
return blob, nil
}
// markField records that name has been seen. A second occurrence is an error.
func markField(seen *uint, bit uint, name string) error {
if *seen&bit != 0 {
return errors.Errorf("duplicate field %q", name)
}
*seen |= bit
return nil
}
func decodeJSONUint(dec *jsontext.Decoder) (uint, error) {
tok, err := dec.ReadToken()
if err != nil {
return 0, err
}
if tok.Kind() != jsontext.KindNumber {
return 0, errors.Errorf("expected number, got %v", tok.Kind())
}
n, err := tok.Uint()
if err != nil {
return 0, err
}
if n > math.MaxUint32 {
return 0, errors.Errorf("invalid unsigned integer %d", n)
}
return uint(n), nil
}
@@ -0,0 +1,128 @@
//go:build go1.27
package index_test
import (
"fmt"
"strings"
"testing"
"github.com/restic/restic/internal/repository/index"
"github.com/restic/restic/internal/restic"
rtest "github.com/restic/restic/internal/test"
)
// Test cases where the hand-rolled decoder is more strict than the basic encoding/json decoder.
func assertDecodeIndexErrorContains(t *testing.T, doc, msg string) {
t.Helper()
_, err := index.DecodeIndex([]byte(doc), restic.NewRandomID())
if err == nil || !strings.Contains(err.Error(), msg) {
t.Fatalf("expected error containing %q, got %v", msg, err)
}
}
func TestDecodeIndexPackWithoutID(t *testing.T) {
assertDecodeIndexErrorContains(t, `{"packs":[{"blobs":[]}]}`, "pack without ID found")
}
func TestDecodeIndexUint32Max(t *testing.T) {
idx := mustDecodeIndex(t, `{"packs":[{"id":"73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c","blobs":[{"id":"3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce","type":"data","offset":4294967295,"length":4294967295,"uncompressed_length":4294967295}]}]}`)
list := idx.Lookup(restic.BlobHandle{
ID: restic.TestParseID("3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce"),
Type: restic.DataBlob,
}, nil)
rtest.Equals(t, 1, len(list))
rtest.Equals(t, uint(4294967295), list[0].Blob.Offset)
rtest.Equals(t, uint(4294967295), list[0].Blob.Length)
rtest.Equals(t, uint(4294967295), list[0].Blob.UncompressedLength)
}
func TestDecodeIndexRejectsUint32Overflow(t *testing.T) {
// Same pack and blob in every case.
const (
pack = "73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c"
blob = "3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce"
)
tests := []struct {
name string
doc string
}{
{
"offset",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[{"id":"%s","type":"data","offset":4294967296,"length":1}]}]}`, pack, blob),
},
{
"length",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[{"id":"%s","type":"data","offset":0,"length":4294967296}]}]}`, pack, blob),
},
{
"uncompressed_length",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[{"id":"%s","type":"data","offset":0,"length":1,"uncompressed_length":4294967296}]}]}`, pack, blob),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assertDecodeIndexErrorContains(t, test.doc, "invalid unsigned integer")
})
}
}
func TestDecodeIndexRejectsDuplicateFields(t *testing.T) {
const (
pack = "73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c"
blob = "3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce"
)
tests := []struct {
name string
doc string
field string
}{
{
"packs",
fmt.Sprintf(`{"packs":[],"packs":[{"id":"%s","blobs":[]}]}`, pack),
"packs",
},
{
"pack id",
fmt.Sprintf(`{"packs":[{"id":"%s","id":"%s","blobs":[]}]}`, pack, pack),
"id",
},
{
"blobs",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[],"blobs":[{"id":"%s","type":"data","offset":0,"length":1,"uncompressed_length":2}]}]}`, pack, blob),
"blobs",
},
{
"blob id",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[{"id":"%s","id":"%s","type":"data","offset":0,"length":1}]}]}`, pack, blob, blob),
"id",
},
{
"blob type",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[{"id":"%s","type":"data","type":"tree","offset":0,"length":1}]}]}`, pack, blob),
"type",
},
{
"offset",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[{"id":"%s","type":"data","offset":0,"offset":1,"length":1}]}]}`, pack, blob),
"offset",
},
{
"length",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[{"id":"%s","type":"data","offset":0,"length":1,"length":2}]}]}`, pack, blob),
"length",
},
{
"uncompressed_length",
fmt.Sprintf(`{"packs":[{"id":"%s","blobs":[{"id":"%s","type":"data","offset":0,"length":1,"uncompressed_length":2,"uncompressed_length":3}]}]}`, pack, blob),
"uncompressed_length",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assertDecodeIndexErrorContains(t, test.doc, fmt.Sprintf("duplicate field %q", test.field))
})
}
}
@@ -0,0 +1,192 @@
package index_test
import (
"bytes"
"fmt"
"strings"
"testing"
"github.com/restic/restic/internal/repository/index"
"github.com/restic/restic/internal/repository/pack"
"github.com/restic/restic/internal/restic"
rtest "github.com/restic/restic/internal/test"
)
func mustDecodeIndex(t *testing.T, doc string) *index.Index {
t.Helper()
idx, err := index.DecodeIndex([]byte(doc), restic.NewRandomID())
rtest.OK(t, err)
return idx
}
func assertDecodeIndexError(t *testing.T, doc string) {
t.Helper()
_, err := index.DecodeIndex([]byte(doc), restic.NewRandomID())
if err == nil {
t.Fatalf("expected error for %s", doc)
}
}
func sampleDecodeIndex() *index.Index {
idx := index.NewIndex()
idx.StorePack(restic.TestParseID("73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c"), pack.Blobs{
{
BlobHandle: restic.BlobHandle{
Type: restic.DataBlob,
ID: restic.TestParseID("3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce"),
},
Offset: 0,
Length: 10,
},
{
BlobHandle: restic.BlobHandle{
Type: restic.TreeBlob,
ID: restic.TestParseID("9ccb846e60d90d4eb915848add7aa7ea1e4bbabfc60e573db9f7bfb2789afbae"),
},
Offset: 10,
Length: 20,
UncompressedLength: 40,
},
})
idx.StorePack(restic.TestParseID("ed54ae36197f4745ebc4b54d10e0f623eaaaedd03013eb7ae90df881b7781452"), pack.Blobs{
{
BlobHandle: restic.BlobHandle{
Type: restic.DataBlob,
ID: restic.TestParseID("d3dc577b4ffd38cc4b32122cabf8655a0223ed22edfd93b353dc0c3f2b0fdf66"),
},
Offset: 0,
Length: 5,
UncompressedLength: 9,
},
})
return idx
}
func TestDecodeIndexRejectsMalformed(t *testing.T) {
tests := []struct {
name string
doc string
}{
{"empty input", ""},
{"truncated object", "{"},
{"truncated packs array", `{"packs":[`},
{"truncated pack", `{"packs":[{`},
{"top-level array", "[]"},
{"packs is an object", `{"packs":{}}`},
{"pack is an array", `{"packs":[[]]}`},
{"blobs is an object", `{"packs":[{"id":"73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c","blobs":{}}]}`},
{"trailing object", `{"packs":[]}{}`},
{"trailing junk", `{"packs":[]} trailing`},
{"truncated blob", `{"packs":[{"id":"73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c","blobs":[{}]}`},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assertDecodeIndexError(t, test.doc)
})
}
}
func TestDecodeIndexRejectsBadFields(t *testing.T) {
const blob = "3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce"
blobDoc := func(id, typ, offset, length, extra string) string {
return fmt.Sprintf(`{"packs":[{"id":"73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c","blobs":[{"id":%s,"type":%s,"offset":%s,"length":%s%s}]}]}`,
id, typ, offset, length, extra)
}
quotedBlob := `"` + blob + `"`
tests := []struct {
name string
doc string
}{
{"short blob id", blobDoc(`"abcd"`, `"data"`, "0", "1", "")},
{"non-hex blob id", blobDoc(`"`+strings.Repeat("g", 64)+`"`, `"data"`, "0", "1", "")},
{"blob id is a number", blobDoc("1", `"data"`, "0", "1", "")},
{"whitespace in blob id", blobDoc(`" `+blob+`"`, `"data"`, "0", "1", "")},
{"unknown blob type", blobDoc(quotedBlob, `"foo"`, "0", "1", "")},
{"blob type is a number", blobDoc(quotedBlob, "1", "0", "1", "")},
{"offset is a string", blobDoc(quotedBlob, `"data"`, `"0"`, "1", "")},
{"negative offset", blobDoc(quotedBlob, `"data"`, "-1", "1", "")},
{"fractional offset", blobDoc(quotedBlob, `"data"`, "1.5", "1", "")},
{"length is a string", blobDoc(quotedBlob, `"data"`, "0", `"1"`, "")},
{"negative length", blobDoc(quotedBlob, `"data"`, "0", "-1", "")},
{"fractional length", blobDoc(quotedBlob, `"data"`, "0", "1.5", "")},
{"uncompressed_length is a string", blobDoc(quotedBlob, `"data"`, "0", "1", `,"uncompressed_length":"1"`)},
{"negative uncompressed_length", blobDoc(quotedBlob, `"data"`, "0", "1", `,"uncompressed_length":-1`)},
{"fractional uncompressed_length", blobDoc(quotedBlob, `"data"`, "0", "1", `,"uncompressed_length":1.5`)},
{"short pack id", fmt.Sprintf(`{"packs":[{"id":"abcd","blobs":[{"id":"%s","type":"data","offset":0,"length":1}]}]}`, blob)},
{"pack id is a number", fmt.Sprintf(`{"packs":[{"id":1,"blobs":[{"id":"%s","type":"data","offset":0,"length":1}]}]}`, blob)},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assertDecodeIndexError(t, test.doc)
})
}
}
func TestDecodeIndexUnknownKeys(t *testing.T) {
doc := `{
"supersedes": ["ed54ae36197f4745ebc4b54d10e0f623eaaaedd03013eb7ae90df881b7781452"],
"extra": {"nested": [1, true, null, {"a": "b"}]},
"packs": [{
"comment": "hello",
"id": "73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c",
"blobs": [{
"note": [1, {"a": 2}],
"id": "3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce",
"type": "data",
"offset": 7,
"length": 8,
"uncompressed_length": 9
}]
}]
}`
idx := mustDecodeIndex(t, doc)
packID := restic.TestParseID("73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c")
blobID := restic.TestParseID("3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce")
rtest.Equals(t, restic.NewIDSet(packID), idx.Packs())
rtest.Equals(t, uint(1), idx.Len(restic.DataBlob))
rtest.Equals(t, uint(0), idx.Len(restic.TreeBlob))
list := idx.Lookup(restic.BlobHandle{ID: blobID, Type: restic.DataBlob}, nil)
rtest.Equals(t, 1, len(list))
rtest.Equals(t, uint(7), list[0].Blob.Offset)
rtest.Equals(t, uint(8), list[0].Blob.Length)
rtest.Equals(t, uint(9), list[0].Blob.UncompressedLength)
rtest.Equals(t, packID, list[0].PackID())
}
func TestDecodeIndexEmpty(t *testing.T) {
for _, doc := range []string{`{}`, `{"packs":[]}`, "{\"packs\":[]}\n\t "} {
t.Run(doc, func(t *testing.T) {
idx := mustDecodeIndex(t, doc)
rtest.Equals(t, 0, len(idx.Packs()))
rtest.Equals(t, uint(0), idx.Len(restic.DataBlob))
rtest.Equals(t, uint(0), idx.Len(restic.TreeBlob))
})
}
idx := mustDecodeIndex(t, `{"packs":[{"id":"73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c","blobs":[]}]}`)
rtest.Equals(t, restic.NewIDSet(restic.TestParseID("73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c")), idx.Packs())
rtest.Equals(t, uint(0), idx.Len(restic.DataBlob))
rtest.Equals(t, uint(0), idx.Len(restic.TreeBlob))
}
func TestDecodeIndexRoundtrip(t *testing.T) {
idx := sampleDecodeIndex()
var buf bytes.Buffer
rtest.OK(t, idx.Encode(&buf))
decoded := mustDecodeIndex(t, buf.String())
rtest.Equals(t, packedBlobs(idx), packedBlobs(decoded))
}
func packedBlobs(idx *index.Index) map[pack.PackedBlob]struct{} {
got := make(map[pack.PackedBlob]struct{})
for pb := range idx.Values() {
got[*pb] = struct{}{}
}
return got
}
+34
View File
@@ -241,6 +241,39 @@ var docExampleV2 = []byte(`
}
`)
// docExampleReordered is v2 with pack/blob keys out of Encode order.
var docExampleReordered = []byte(`
{
"packs": [
{
"blobs": [
{
"length": 38,
"offset": 0,
"type": "data",
"id": "3ec79977ef0cf5de7b08cd12b874cd0f62bbaf7f07f3497a5b1bbcc8cb39b1ce"
},
{
"uncompressed_length": 511,
"length": 112,
"offset": 38,
"type": "tree",
"id": "9ccb846e60d90d4eb915848add7aa7ea1e4bbabfc60e573db9f7bfb2789afbae"
},
{
"id": "d3dc577b4ffd38cc4b32122cabf8655a0223ed22edfd93b353dc0c3f2b0fdf66",
"uncompressed_length": 234,
"type": "data",
"length": 123,
"offset": 150
}
],
"id": "73d04e6125cf3c28a299cc2f3cca3b78ceac396e4fcf9575e34536b26782413c"
}
]
}
`)
var exampleTests = []struct {
id, packID restic.ID
tpe restic.BlobType
@@ -281,6 +314,7 @@ func TestIndexUnserialize(t *testing.T) {
}{
{docExampleV1, 1},
{docExampleV2, 2},
{docExampleReordered, 2},
} {
idx, err := index.DecodeIndex(task.idxBytes, restic.NewRandomID())
rtest.OK(t, err)