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

Replace jiffy by jsx #76

Merged
merged 2 commits into from
Sep 28, 2016
Merged

Conversation

BernardNotarianni
Copy link
Contributor

We are using cowboy-swagger for barrel-db and we would like to remove the dependency to jiffy and use jsx instead.

Here is a proposition for this refactoring.

Bernard.

@elbrujohalcon
Copy link
Member

Hi @BernardNotarianni … I've been under the impression that jiffy is somehow faster or more performant than jsx. Nevertheless I like the fact that jsx requires no hacks to compile.
I'll let the team at inaka voice their opinions on this matter. If all goes well, I'll merge it.

@@ -99,14 +99,14 @@ schema(DefinitionName) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% @hidden
-spec enc_json(jiffy:json_value()) -> iolist().
-spec enc_json(jiffy:json_term()) -> iolist().
Copy link
Member

Choose a reason for hiding this comment

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

According to Dialyzer:

Invalid type specification for function cowboy_swagger:enc_json/1. The success typing is (atom() | binary() | [any()] | number() | {{non_neg_integer(),1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12,1..255},{byte(),byte(),byte()}} | map()) -> binary()

@HernanRivasAcosta
Copy link
Member

I am extremely convinced that measurable performance gains at runtime trumps having to write (or, to be fair, copy pasting) a couple of overrides in the rebar config.

To be honest, I think it's a bad idea to move to a slower alternative to gain a bit of simplicity. If you really want to do this, I would suggest a fork, but I would suggest even more strongly to just use jiffy.

However, I am coming from the assumption that jiffy is faster, which I have yet to measure myself. I will run a few benchmarks before giving a definite answer, but I will always side with performance; specially since we can expect the JSON encoding/decoding code to be called at least once per request; if there's any part of a web server that could use an optimization, it's that one.

@cabol
Copy link
Contributor

cabol commented Sep 27, 2016

IMHO, I think PERFORMANCE shouldn't be a reason to keep using jiffy, because from cowboy-swagger perspective, PERFORMANCE is not an arquitectural driver, it was designed and build to serve documentation, from that point of view, if it takes some milliseconds more decoding/coding JSON, it is not a big deal – remember, API doc is requested on-demand by a final user. Furthermore, supposing you want to use cowboy-swagger, the JSON lib you use in your project is totally independent from cowboy-swagger (cowboy-swagger would use jsx internally), in other words, your App can use other different lib for JSON – like jiffy if performance is a real issue for you.

On other hand, I'm not saying we should go for jsx neither, my point is, we should make a decision based on what would be more practical to the project (cowboy-swagger). So, my question for @BernardNotarianni is: what is/are the real need(s) to move from jiffy to jsx? Why to do this change is important to you guys?

@BernardNotarianni
Copy link
Contributor Author

I quite agree with remarks from @cabol.

Moreover, our priorities are currently :

  1. Simplicity
  2. Reliabily
  3. Performance

Hence, in similar context, we would prefer a full erlang lib over the one including parts in C, unless other constraints come in. That's why we chose jsx and we would like now to avoid to package 2 json libs.

I do not have stronger cons against jiffy. If it is your standard choice for your applications, I fully understand you will not want to have dependencies to 2 json libs too 😄

If you decide to keep it, I guess we will be happy with our own fork, as swagger is not a critical part of our core.

@elbrujohalcon
Copy link
Member

@BernardNotarianni we're discussing this internally, but in any case… it would be nice if you can fix that dialyzer warning above :)

@BernardNotarianni
Copy link
Contributor Author

Sure. Sorry about that.

@BernardNotarianni
Copy link
Contributor Author

@elbrujohalcon it looks like I fixed one problem but created a new one 😢

However, I did not find where I could have more information about the errors. Any clue?

@elbrujohalcon
Copy link
Member

@BernardNotarianni a link to details should appear there… it's a bug in gadget. I'll check it out myself.

@elbrujohalcon elbrujohalcon reopened this Sep 28, 2016
@elbrujohalcon elbrujohalcon merged commit 84ea5d6 into inaka:master Sep 28, 2016
@elbrujohalcon
Copy link
Member

…aaaand merged! Thanks @BernardNotarianni !

@BernardNotarianni
Copy link
Contributor Author

Thank you for you time 😄

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.

5 participants