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

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

Closed
wants to merge 2 commits into from

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.

cid.go Outdated Show resolved Hide resolved
cid.go Outdated Show resolved Hide resolved
@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
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.

None yet

2 participants