Skip to content

Commit b08bc4d

Browse files
committed
refactor: test-cid-v1-wide with UnixFSHAMTDirectoryMaxFanout=1024
lets make the fanout match the max links from files and rename profile to `-wide` this will make it easier to discuss in ipfs/specs#499
1 parent 7d17622 commit b08bc4d

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

config/profile.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fetching may be degraded.
280280
},
281281
},
282282
"test-cid-v1": {
283-
Description: `Makes UnixFS import produce legacy CIDv1 with the same suboptimal settings as legacy-cid-v0, but with 1MiB file chunk, CIDv1 and raw leaves. Use only if legacy behavior is required.`,
283+
Description: `Makes UnixFS import produce CIDv1 with raw leaves, sha2-256 and 1 MiB chunks (max 174 links per file, 256 per HAMT node, switch dir to HAMT above 256KiB).`,
284284
Transform: func(c *Config) error {
285285
c.Import.CidVersion = *NewOptionalInteger(1)
286286
c.Import.UnixFSRawLeaves = True
@@ -293,16 +293,16 @@ fetching may be degraded.
293293
return nil
294294
},
295295
},
296-
"test-cid-v1-2025-v35": {
297-
Description: `Makes UnixFS import produce modern CIDv1 with raw leaves, sha2-256 and 1 MiB chunks and wider file DAGs (1024 links per level).`,
296+
"test-cid-v1-wide": {
297+
Description: `Makes UnixFS import produce CIDv1 with raw leaves, sha2-256 and 1MiB chunks and wider file DAGs (max 1024 links per every node type, switch dir to HAMT above 1MiB).`,
298298
Transform: func(c *Config) error {
299299
c.Import.CidVersion = *NewOptionalInteger(1)
300300
c.Import.UnixFSRawLeaves = True
301301
c.Import.UnixFSChunker = *NewOptionalString("size-1048576") // 1MiB
302302
c.Import.HashFunction = *NewOptionalString("sha2-256")
303303
c.Import.UnixFSFileMaxLinks = *NewOptionalInteger(1024)
304304
c.Import.UnixFSDirectoryMaxLinks = *NewOptionalInteger(0) // no limit here, use size-based Import.UnixFSHAMTDirectorySizeThreshold instead
305-
c.Import.UnixFSHAMTDirectoryMaxFanout = *NewOptionalInteger(256)
305+
c.Import.UnixFSHAMTDirectoryMaxFanout = *NewOptionalInteger(1024)
306306
c.Import.UnixFSHAMTDirectorySizeThreshold = *NewOptionalString("1MiB") // 1MiB
307307
return nil
308308
},

docs/changelogs/v0.35.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,11 @@ You can set default values for these options using the following configuration s
7171

7272
The release updated configuration [profiles](https://github.com/ipfs/kubo/blob/master/docs/config.md#profile) to incorporate these new `Import.*` settings:
7373
- Updated Profile: `test-cid-v1` now includes current defaults as explicit `Import.UnixFSFileMaxLinks=174`, `Import.UnixFSDirectoryMaxLinks=0`, `Import.UnixFSHAMTDirectoryMaxFanout=256` and `Import.UnixFSHAMTDirectorySizeThreshold=256KiB`
74-
- New Profile: `test-cid-v1-2025-v35` adopts modern defaults, increasing the maximum file DAG width from 174 to 1024 and raising the HAMT directory sharding threshold from 256KiB to 1MiB, aligning with 1MiB file chunks.
75-
- Benefits: Larger blocks (256KiB to 1MiB) enable up to 4x faster Amino DHT announcements and lookups.
76-
- Status: This profile is a candidate for future default settings.
74+
- New Profile: `test-cid-v1-wide` adopts experimental directory DAG-shaping defaults, increasing the maximum file DAG width from 174 to 1024, HAMT fanout from 256 to 1024, and raising the HAMT directory sharding threshold from 256KiB to 1MiB, aligning with 1MiB file chunks.
7775
- Feedback: Try it out and share your thoughts at [discuss.ipfs.tech/t/should-we-profile-cids](https://discuss.ipfs.tech/t/should-we-profile-cids/18507) or [ipfs/specs#499](https://github.com/ipfs/specs/pull/499).
7876

7977
> [!TIP]
80-
> Apply the modern CIDv1 test profile with `ipfs config profile apply test-cid-v1-2025-v35`.
78+
> Apply the modern CIDv1 test profile with `ipfs config profile apply test-cid-v1-wide`.
8179
8280
#### 📦️ Important dependency updates
8381

docs/config.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,16 +2800,38 @@ Disables [Reprovider](#reprovider) system (and announcing to Amino DHT).
28002800

28012801
Makes UnixFS import (`ipfs add`) produce legacy CIDv0 with no raw leaves, sha2-256 and 256 KiB chunks.
28022802

2803+
See <https://github.com/ipfs/kubo/blob/master/config/profile.go> for exact [`Import.*`](#import) settings.
2804+
28032805
> [!NOTE]
28042806
> This profile is provided for legacy users and should not be used for new projects.
28052807
28062808
### `test-cid-v1` profile
28072809

2808-
Makes UnixFS import (`ipfs add`) produce modern CIDv1 with raw leaves, sha2-256 and 1 MiB chunks.
2810+
Makes UnixFS import (`ipfs add`) produce modern CIDv1 with raw leaves, sha2-256
2811+
and 1 MiB chunks (max 174 links per file, 256 per HAMT node, switch dir to HAMT
2812+
above 256KiB).
2813+
2814+
See <https://github.com/ipfs/kubo/blob/master/config/profile.go> for exact [`Import.*`](#import) settings.
28092815

28102816
> [!NOTE]
2811-
> This profile will become the new implicit default, provided for testing purposes.
2812-
> Follow [kubo#4143](https://github.com/ipfs/kubo/issues/4143) for more details.
2817+
> [`Import.*`](#import) settings applied by this profile MAY change in future release. Provided for testing purposes.
2818+
>
2819+
> Follow [kubo#4143](https://github.com/ipfs/kubo/issues/4143) for more details,
2820+
> and provide feedback in [discuss.ipfs.tech/t/should-we-profile-cids](https://discuss.ipfs.tech/t/should-we-profile-cids/18507) or [ipfs/specs#499](https://github.com/ipfs/specs/pull/499).
2821+
2822+
### `test-cid-v1-wide` profile
2823+
2824+
Makes UnixFS import (`ipfs add`) produce modern CIDv1 with raw leaves, sha2-256
2825+
and 1 MiB chunks and wider file DAGs (max 1024 links per every node type,
2826+
switch dir to HAMT above 1MiB).
2827+
2828+
See <https://github.com/ipfs/kubo/blob/master/config/profile.go> for exact [`Import.*`](#import) settings.
2829+
2830+
> [!NOTE]
2831+
> [`Import.*`](#import) settings applied by this profile MAY change in future release. Provided for testing purposes.
2832+
>
2833+
> Follow [kubo#4143](https://github.com/ipfs/kubo/issues/4143) for more details,
2834+
> and provide feedback in [discuss.ipfs.tech/t/should-we-profile-cids](https://discuss.ipfs.tech/t/should-we-profile-cids/18507) or [ipfs/specs#499](https://github.com/ipfs/specs/pull/499).
28132835
28142836
## Types
28152837

test/cli/add_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func TestAdd(t *testing.T) {
199199
require.NoError(t, err)
200200
cidStr := node.IPFS("add", "-r", "-Q", randDir).Stdout.Trimmed()
201201

202-
// Confirm the number of links is more than UnixFSHAMTDirectoryMaxFanout=256 (indicating regular "basic" directory"
202+
// Confirm the number of links is more than UnixFSHAMTDirectorySizeThreshold (indicating regular "basic" directory"
203203
root, err := node.InspectPBNode(cidStr)
204204
assert.NoError(t, err)
205205
require.Equal(t, 903, len(root.Links))
@@ -219,7 +219,7 @@ func TestAdd(t *testing.T) {
219219
require.NoError(t, err)
220220
cidStr := node.IPFS("add", "-r", "-Q", randDir).Stdout.Trimmed()
221221

222-
// Confirm this time, the number of links is less than UnixFSHAMTDirectoryMaxFanout=256
222+
// Confirm this time, the number of links is less than UnixFSHAMTDirectorySizeThreshold
223223
root, err := node.InspectPBNode(cidStr)
224224
assert.NoError(t, err)
225225
require.Equal(t, 252, len(root.Links))
@@ -290,7 +290,7 @@ func TestAdd(t *testing.T) {
290290
require.NoError(t, err)
291291
cidStr := node.IPFS("add", "-r", "-Q", randDir).Stdout.Trimmed()
292292

293-
// Confirm the number of links is more than UnixFSHAMTDirectoryMaxFanout=256 (indicating regular "basic" directory"
293+
// Confirm the number of links is more than UnixFSHAMTDirectoryMaxFanout (indicating regular "basic" directory"
294294
root, err := node.InspectPBNode(cidStr)
295295
assert.NoError(t, err)
296296
require.Equal(t, 897, len(root.Links))
@@ -310,17 +310,17 @@ func TestAdd(t *testing.T) {
310310
require.NoError(t, err)
311311
cidStr := node.IPFS("add", "-r", "-Q", randDir).Stdout.Trimmed()
312312

313-
// Confirm this time, the number of links is less than UnixFSHAMTDirectoryMaxFanout=256
313+
// Confirm this time, the number of links is less than UnixFSHAMTDirectoryMaxFanout
314314
root, err := node.InspectPBNode(cidStr)
315315
assert.NoError(t, err)
316316
require.Equal(t, 252, len(root.Links))
317317
})
318318
})
319319

320-
t.Run("ipfs init --profile=test-cid-v1-2025-v35 applies UnixFSChunker=size-1048576 and UnixFSFileMaxLinks=1024", func(t *testing.T) {
320+
t.Run("ipfs init --profile=test-cid-v1-wide applies UnixFSChunker=size-1048576 and UnixFSFileMaxLinks=1024", func(t *testing.T) {
321321
t.Parallel()
322322
seed := "v1-seed-1024"
323-
profile := "--profile=test-cid-v1-2025-v35"
323+
profile := "--profile=test-cid-v1-wide"
324324

325325
t.Run("under UnixFSFileMaxLinks=1024", func(t *testing.T) {
326326
t.Parallel()
@@ -352,10 +352,10 @@ func TestAdd(t *testing.T) {
352352
})
353353
})
354354

355-
t.Run("ipfs init --profile=test-cid-v1-2025-v35 applies UnixFSHAMTDirectoryMaxFanout=256 and UnixFSHAMTDirectorySizeThreshold=1MiB", func(t *testing.T) {
355+
t.Run("ipfs init --profile=test-cid-v1-wide applies UnixFSHAMTDirectoryMaxFanout=256 and UnixFSHAMTDirectorySizeThreshold=1MiB", func(t *testing.T) {
356356
t.Parallel()
357357
seed := "hamt-cid-v1"
358-
profile := "--profile=test-cid-v1-2025-v35"
358+
profile := "--profile=test-cid-v1-wide"
359359

360360
t.Run("under UnixFSHAMTDirectorySizeThreshold=1MiB", func(t *testing.T) {
361361
t.Parallel()
@@ -371,7 +371,7 @@ func TestAdd(t *testing.T) {
371371
require.NoError(t, err)
372372
cidStr := node.IPFS("add", "-r", "-Q", randDir).Stdout.Trimmed()
373373

374-
// Confirm the number of links is more than UnixFSHAMTDirectoryMaxFanout=256 (indicating regular "basic" directory"
374+
// Confirm the number of links is more than UnixFSHAMTDirectoryMaxFanout (indicating regular "basic" directory"
375375
root, err := node.InspectPBNode(cidStr)
376376
assert.NoError(t, err)
377377
require.Equal(t, 3599, len(root.Links))
@@ -391,10 +391,10 @@ func TestAdd(t *testing.T) {
391391
require.NoError(t, err)
392392
cidStr := node.IPFS("add", "-r", "-Q", randDir).Stdout.Trimmed()
393393

394-
// Confirm this time, the number of links is less than UnixFSHAMTDirectoryMaxFanout=256
394+
// Confirm this time, the number of links is less than UnixFSHAMTDirectoryMaxFanout
395395
root, err := node.InspectPBNode(cidStr)
396396
assert.NoError(t, err)
397-
require.Equal(t, 256, len(root.Links))
397+
require.Equal(t, 992, len(root.Links))
398398
})
399399
})
400400

0 commit comments

Comments
 (0)