Comments (12)
I did some informal test and determined that the overhead for the benchmark in ipfs/kubo#3376 was around 17ms. Most of the time for that benchmark was in the base32 decoding (see whyrusleeping/base32#1). This might still be useful but nothing urgent.
from go-cid.
@kevina Yeah, this is a pretty good point. I'm not opposed to this.
from go-cid.
Okay, this is something I will measure then. I will also measure the benefits (and cons) of using a string for a Multihash
.
It may be a while before I can get to it as I can't just change the Cid form a pointer to a value type without lots of code change so I will need to isolate the benchmark code to have a few dependencies as possible before I can measure anything.
from go-cid.
So, I opened a competing issue (#25) because having to call KeyString()
every time one wants to use a CID in a map is a pain (and slow). However, making multihash a string would also fix this issue.
from go-cid.
@Stebalien as I am updating GC code that relies heavily on the indexing by Cid having the Cid stored as string possibly could improve it quite a bit.
from go-cid.
Taking a look at my heap profile, it looks like the KeyString
function is now responsible for ~10% of my allocated memory.
from go-cid.
@Stebalien making multihash a string is actually a different issue in a different repo, multiformats/go-multihash#29. @whyrusleeping was concerned about the cost of converting the string to a []byte
but maybe now its the cost of converting a []byte
to a string that is really the problem.
from go-cid.
Ah. I see. Either that or just storing CIDs in as byte strings (fully serialized) would work.
from go-cid.
@Stebalien so if I understand you correctly, what you want is for the official CID representation to be a serialized string. That would be the most efficient in memory representative however they may be a non-trivial cost then if we need information on the Cid itself.
If there is any interest this is something I could look into.
from go-cid.
My main concern is that I want it to be usable as a key in a map. We can achieve this by:
- Storing the multihash as a string and using the raw Cid (not a pointer to it) as a map key.
- Storing the encoded CID inside of the CID as a string (
struct { version uint64, codec uint64, cidStr string }
). KeyString would return this (slightly more space). - Just using the bare CID as a string.
from go-cid.
@Stebalien ah, now I see what you are after. In most of these cases we should stop passing around CIDs as pointers (see #38). I am not sure if the Cid type necessary should be directly storable as map keys, but we should definitely aim to reduce the cost of KeyString.
from go-cid.
We are going with a string representation.
from go-cid.
Related Issues (20)
- Implement 'K'-encoding (base36 cids) HOT 2
- Inaccurate godoc comment for uvarint HOT 1
- Possible to calculate cid using Writer interface instead of reading full file into memory? HOT 3
- add CidFromReader HOT 9
- cid Undef cannot be marshalled HOT 3
- Support parse (github.com/ipfs/go-path).Path HOT 16
- Provide an efficient API to check whether a CID has `IDENTITY` multihash code HOT 3
- CodecToStr and Codecs in v0.3.1 could cause data corruption HOT 3
- CidFromReader wraps valid io.EOF in ErrInvalidCid HOT 1
- Bloom filter backed version of Cid.Set HOT 1
- Extract non-core functionaly into new package HOT 5
- LRU cache HOT 3
- protobuf vs dag-pb HOT 2
- Should the JSON represenetation of CID always be formatted as links. HOT 6
- Generated CIDv0 differs from the one generated by IPFS HOT 13
- Proposal: Moving CID to multiformats Org HOT 1
- Prefix.Sum creates bad inline CIDs
- Qm hash identifiers duplicated within the IPFS ecosystem HOT 1
- Harden varint encoding. HOT 1
- Support for reading concatenated CIDs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-cid.