Skip to content

perf: add a generic CID type which allows for aliased byte slices#159

Closed
Jorropo wants to merge 2 commits intomasterfrom
no-alloc
Closed

perf: add a generic CID type which allows for aliased byte slices#159
Jorropo wants to merge 2 commits intomasterfrom
no-alloc

Conversation

@Jorropo
Copy link
Contributor

@Jorropo Jorropo commented Jun 12, 2023

This is backward compatible (that why I hacked it with generics).
I should probably make generic versions of the builders too.

Results:

name   old time/op    new time/op    delta
PB-12     730ns ± 5%     255ns ± 2%   -65.04%  (p=0.000 n=9+10)

name   old alloc/op   new alloc/op   delta
PB-12      224B ± 0%        0B       -100.00%  (p=0.000 n=10+10)

name   old allocs/op  new allocs/op  delta
PB-12      4.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

Jorropo added a commit to ipfs/boxo that referenced this pull request Jun 12, 2023
```
$ benchstat /mnt/ramdisk/{old,new}
name   old time/op    new time/op    delta
PB-12     730ns ± 5%     255ns ± 2%   -65.04%  (p=0.000 n=9+10)

name   old alloc/op   new alloc/op   delta
PB-12      224B ± 0%        0B       -100.00%  (p=0.000 n=10+10)

name   old allocs/op  new allocs/op  delta
PB-12      4.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
```

Depends on ipfs/go-cid#159.
Jorropo added a commit to ipfs/boxo that referenced this pull request Jun 12, 2023
```
$ benchstat /mnt/ramdisk/{old,new}
name   old time/op    new time/op    delta
PB-12     730ns ± 5%     255ns ± 2%   -65.04%  (p=0.000 n=9+10)

name   old alloc/op   new alloc/op   delta
PB-12      224B ± 0%        0B       -100.00%  (p=0.000 n=10+10)

name   old allocs/op  new allocs/op  delta
PB-12      4.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
```

Depends on ipfs/go-cid#159.
Jorropo added a commit to ipfs/boxo that referenced this pull request Jun 12, 2023
```
$ benchstat /mnt/ramdisk/{old,new}
name   old time/op    new time/op    delta
PB-12     730ns ± 5%     255ns ± 2%   -65.04%  (p=0.000 n=9+10)

name   old alloc/op   new alloc/op   delta
PB-12      224B ± 0%        0B       -100.00%  (p=0.000 n=10+10)

name   old allocs/op  new allocs/op  delta
PB-12      4.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
```

Depends on ipfs/go-cid#159.
Copy link

@willscott willscott left a comment

Choose a reason for hiding this comment

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

  • We probably should have the cid test and fuzzing also run against GenericCid
  • would be good to add a test demonstrating that a cid with a backing []byte can interop with a string cid.

@Jorropo Jorropo marked this pull request as draft June 12, 2023 09:32
Jorropo added a commit to ipfs/boxo that referenced this pull request Jun 12, 2023
```
$ benchstat /mnt/ramdisk/{old,new}
name   old time/op    new time/op    delta
PB-12     730ns ± 5%     255ns ± 2%   -65.04%  (p=0.000 n=9+10)

name   old alloc/op   new alloc/op   delta
PB-12      224B ± 0%        0B       -100.00%  (p=0.000 n=10+10)

name   old allocs/op  new allocs/op  delta
PB-12      4.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
```

Depends on ipfs/go-cid#159.
Jorropo added a commit to ipfs/boxo that referenced this pull request Jun 12, 2023
```
$ benchstat /mnt/ramdisk/{old,new}
name   old time/op    new time/op    delta
PB-12     730ns ± 5%     255ns ± 2%   -65.04%  (p=0.000 n=9+10)

name   old alloc/op   new alloc/op   delta
PB-12      224B ± 0%        0B       -100.00%  (p=0.000 n=10+10)

name   old allocs/op  new allocs/op  delta
PB-12      4.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
```

Depends on ipfs/go-cid#159.
@Jorropo Jorropo marked this pull request as ready for review February 17, 2024 11:05
This skips an allocation when appending strings to bytes.
@Jorropo Jorropo closed this Feb 17, 2024
@rvagg rvagg deleted the no-alloc branch February 19, 2024 02:34
@MichaelMure
Copy link
Contributor

@rvagg
Copy link
Member

rvagg commented Jan 22, 2025

@MichaelMure feel free to take it over and try again with a new PR

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.

4 participants