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

Use unsized, typeless, tuple to fix OTP 18 compilation #745

Merged
merged 1 commit into from
Sep 16, 2015
Merged

Use unsized, typeless, tuple to fix OTP 18 compilation #745

merged 1 commit into from
Sep 16, 2015

Conversation

ahf
Copy link

@ahf ahf commented Jun 15, 2015

This patch fixes compilation for OTP 18.

There's currently no method of specifying a tuple of arbitrary size of type T.

This patch fixes compilation for OTP 18. There's currently no method of
specifying a tuple of arbitrary size of type T.
@marianoguerra
Copy link

👍 please merge this, making it harder to use riak_core on latest ubuntu with erlang 18 by default.

@cmeiklejohn
Copy link
Contributor

👎

Wouldn't it be better to introduce an actual type for this tuple and what it contains? From what I can tell, you've weakened the type such that Dialyzer will be less effective in determining the proper type -- this isn't just a tuple, it's a tuple containing something.

@ahf
Copy link
Author

ahf commented Sep 14, 2015

How are you going to do that? There is, to my knowledge, no way to specify a tuple of arbitrary size of type T.

The code is based around the idea that you (ab)use tuples to create O(1) lookup tables. See:
https://github.com/ahf/riak_core/blob/fix-undefined-tuple-type/src/chashbin.erl#L141-L142

Fixing the implementation is a much harder issue, but until then the code is simply broken - not just broken in the "it could be nicer" kind of broken, but the "s*** doesn't compile" kind of broken.

@jlouis
Copy link

jlouis commented Sep 15, 2015

As far as I read the source code, the tuple/N form was removed in R18 (and rightly so, it doesn't make any sense from a type level perspective). So sooner or later, you have to fix this. A possibility is to replace to tuple with a map() nowadays, which will probably be a bit slower, but not much.

@lehoff
Copy link

lehoff commented Sep 16, 2015

Changing the tuple to a map sounds fine re getting cleaner code and better help for Dialyzer.

However, there are many Riak installations on R16, so changing to a map() would make it harder to maintain one code branch.

And then we have the issue of the code being written with some performance goals in mind.
Changing would require proper measurements of the critical path in Riak for starters - if chashbin is on the critical path one has to measure the impact of the change.

@marianoguerra
Copy link

if I include a switch on the version maintaining the current type for < R18 and the new one for >= R18 will it be accepted?

if not, is there a proposed solution?

as is, riak_core doesn't compile on R18.

@jlouis
Copy link

jlouis commented Sep 16, 2015

Were I to make the call, I'd just take the patch. I'm weary about the dialyzer being able to do anything sensible (check with typer what it infers).

@lehoff
Copy link

lehoff commented Sep 16, 2015

Having looked a bit deeper into the code I agree with @jlouis since the nodes field is only used inside the chashbin module and it is limited what Dialyzer can get out of that.

Accepting this will enable us to keep the code the same without any version magic.

lehoff added a commit that referenced this pull request Sep 16, 2015
Use unsized, typeless, tuple to fix OTP 18 compilation
@lehoff lehoff merged commit c2d6529 into basho:develop Sep 16, 2015
@lehoff
Copy link

lehoff commented Sep 16, 2015

Double-checked inside Basho and the patch is fine.

@ahf
Copy link
Author

ahf commented Sep 16, 2015

Thanks.

@mbbroberg
Copy link

Awesome work @ahf! If you find the time, come hang out with us at RICON this year. 👌

Thanks for merging @lehoff.

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.

6 participants