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

Refactor to refmt #30

Merged
merged 24 commits into from
Sep 19, 2018
Merged

Refactor to refmt #30

merged 24 commits into from
Sep 19, 2018

Conversation

dignifiedquire
Copy link
Member

@dignifiedquire dignifiedquire commented Nov 13, 2017

Ref #29

@ghost ghost assigned dignifiedquire Nov 13, 2017
@ghost ghost added the status/in-progress In progress label Nov 13, 2017
node.go Outdated
cid *cid.Cid
err = cbor.UnmarshalAtlased(b, &m, cborAtlas)
if err != nil {
fmt.Printf("bytes: %s\n", hex.EncodeToString(b))
Copy link
Member

Choose a reason for hiding this comment

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

btw, you can use %x instead of %s to automatically encode to hex.

Copy link
Member Author

Choose a reason for hiding this comment

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

sweet, thank you <3

@dignifiedquire
Copy link
Member Author

More tests are passing with the latest fixes + latest refmt. Some more tests to fix before we are ready.

@ghost ghost assigned whyrusleeping Dec 11, 2017
@whyrusleeping
Copy link
Member

I actually think that something is broken on master. In TestMarshalRoundtrip, the object that gets created (on master) looks like this:

why@manwe /t/go-ipld-cbor> echo -n a36362617a82d82a5823001220aed1fe98cda4ba5a1681a19aa768f73b9d707c5621c7effdf2938e242080505ed82a58230012205773487d221545d26fd0f57fdb3a7d986bc479a850d7b0d762e8c7f4772790a063666f6f636261726463617473a163717578d82a5823001220434be0538b88f385bdb9d62de34e296a0908c857a876aec09e1f52673596d897 | refmt cbor.hex=pretty
Map<len:3> {
        "baz": Array<len:2> [
                _tag:42_ 001220aed1fe98cda4ba5a1681a19aa768f73b9d707c5621c7effdf2938e242080505e
                _tag:42_ 0012205773487d221545d26fd0f57fdb3a7d986bc479a850d7b0d762e8c7f4772790a0
        ]
        "foo": "bar"
        "cats": Map<len:1> {
                "qux": _tag:42_ 001220434be0538b88f385bdb9d62de34e296a0908c857a876aec09e1f52673596d897
        }
}

The string 'hello' is missing. This test started failing once we switched to refmt, and the created object looks like:

why@manwe ~/g/s/g/i/go-ipld-cbor> echo -n a46362617a82d82a5823001220aed1fe98cda4ba5a1681a19aa768f73b9d707c5621c7effdf2938e242080505ed82a58230012205773487d221545d26fd0f57fdb3a7d986bc479a850d7b0d762e8c7f4772790a063666f6f636261726463617473a163717578d82a5823001220434be0538b88f385bdb9d62de34e296a0908c857a876aec09e1f52673596d8976568656c6c6fd82a5823001220aed1fe98cda4ba5a1681a19aa768f73b9d707c5621c7effdf2938e242080505e | refmt cbor.hex=pretty
Map<len:4> {
        "baz": Array<len:2> [
                _tag:42_ 001220aed1fe98cda4ba5a1681a19aa768f73b9d707c5621c7effdf2938e242080505e
                _tag:42_ 0012205773487d221545d26fd0f57fdb3a7d986bc479a850d7b0d762e8c7f4772790a0
        ]
        "foo": "bar"
        "cats": Map<len:1> {
                "qux": _tag:42_ 001220434be0538b88f385bdb9d62de34e296a0908c857a876aec09e1f52673596d897
        }
        "hello": _tag:42_ 001220aed1fe98cda4ba5a1681a19aa768f73b9d707c5621c7effdf2938e242080505e
}

So while I was trying to avoid changing any tests, I think we actually should here.

@whyrusleeping
Copy link
Member

Ignore my previous comment, it looks like @dignifiedquire added that hello key in earlier commits but didnt update the expected hash.

@whyrusleeping
Copy link
Member

All thats left here is to add in the right sorting for maps to refmt for canonical cbor. I can manually make that change (and have locally), but would rather do it in a way thats flexible and have it officially be a part of refmt.

@dignifiedquire
Copy link
Member Author

dignifiedquire commented Dec 13, 2017 via email

@dignifiedquire
Copy link
Member Author

@whyrusleeping I think this is ready as soon as polydawn/refmt#19 is merged and we have a gx version of refmt.

@whyrusleeping
Copy link
Member

Alright, we're ready to go here I think

@dignifiedquire
Copy link
Member Author

@whyrusleeping is there a reason this is not merged yet?

@dignifiedquire dignifiedquire changed the title [WIP] Refactor to refmt Refactor to refmt Feb 19, 2018
@whyrusleeping
Copy link
Member

@dignifiedquire mostly because we need to do the update into go-ipfs intentionally, and not have it get included arbitrarily with a bunch of other updates. This sort of thing is a higher risk change, and is something we want to test carefully and individually.

@Stebalien
Copy link
Member

Stebalien commented Jul 17, 2018

This is blocked until it stops deserializing CIDs as *cid.Cid cid.Cid and starts deserializing them to *cid.Cid.

@whyrusleeping
Copy link
Member

@Stebalien cant we just change the castBytesToCid method to return a *cid.Cid?

@Stebalien
Copy link
Member

@whyrusleeping no, this is a limitation of refmt as it stands (I've discussed it with @warpfork and I just filed an issue (polydawn/refmt#32) so we can track it).

We could fix all the CIDs up using traverse but that would mean an additional step.


My other open concern is that I'm not sure we really want to expose the RegisterCBORType function as it could screw with Resolve (maybe?).

@Kubuxu
Copy link
Member

Kubuxu commented Sep 7, 2018

We also need: polydawn/refmt@2e9ba99

@warpfork
Copy link
Member

warpfork commented Sep 9, 2018

I have attempted to unblock :)

dignifiedquire and others added 17 commits September 11, 2018 21:16
Also, use a cloner instead of unmarshalling when wrapping an object.
Increasing `numWorkers` doesn't seem to help at all (not supprising). Really, we
could probably drop to NumCPUs (instad of 2x that) and we'd still be fine.
More than that doesn't help. +1 helps for the case where a goroutine holding a
worker gets unscheduled.
IIRC, pools are cleaned every GC cycle. However, by benchmarks aren't
actually *faster* with this change so I figured we might as well go for it. Our
issue here is really throughput, not latency, so even *if* these pools are
cleaned on GC, it's still useful.
We don't need to mutate, just replace.
Make sure we *actually* serialize/deserialize. Addresses @warpfork's CR.
@Stebalien
Copy link
Member

I've just rebased this on master in the refmt-rebased branch. Basically, we now just use cid.Cid (no pointers) so I got rid of all the "if we have a pointer do x, if we don't do y" stuff.

I've done a sanity check with the new uber-cool git range-diff master refmt refmt-rebased command but feel free to do the same.

@dignifiedquire please reset this branch to refmt-rebased when you're ready.

@warpfork
Copy link
Member

What's the landing strategy going to be for this? IIUC, there's already releases of go-ipld-cbor cut from this branch being used in some other projects...

I guess gx snapshots also do preserve those, but ditching the original git commit hashes matching those releases would also seem pretty lossy.

Idea: do a giant git checkout master && git merge -s ours refmt to keep this history (but not apply the diff to master yet -- so there's no conflict resolution to do) and make it referenced from master so we can drop the branch ref... and then do another giant commit that's the rebased squash of this (with conflicts resolved).

Maybe that's unnecessary footwork, just floating the idea.

@Stebalien
Copy link
Member

It's probably fine to drop the release commits, IMO. That shouldn't actually break anything due to how gx works.

@dignifiedquire
Copy link
Member Author

dignifiedquire commented Sep 17, 2018 via email

@Stebalien Stebalien merged commit f8f4e93 into master Sep 19, 2018
@ghost ghost removed the status/in-progress In progress label Sep 19, 2018
@Stebalien Stebalien deleted the refmt branch September 19, 2018 03:43
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

5 participants