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

OkJson is super slow when parsing long strings #99

Closed
runnedrun opened this issue Aug 28, 2012 · 8 comments
Closed

OkJson is super slow when parsing long strings #99

runnedrun opened this issue Aug 28, 2012 · 8 comments

Comments

@runnedrun
Copy link

I've been trying to pass long html strings in QC, and its been hanging. I investigated a bit and it looks like OkJson is the problem. When passing in a hash containing the entire html of a wikipedia page OkJson takes about 10 minutes to encode, whereas ruby's to_json takes 500 ms. OkJson is pretty awesome because of it's portability, but it's made it infeasible to pass long strings as arguments to QC. That being said, there may also be a better way to pass long strings to QC that I don't know about.

Thanks!

@joevandyk
Copy link
Contributor

Why does queue_classic use okjson?

@ryandotsmith
Copy link
Contributor

@joevandyk I chose okjson because dealing with all of Ruby's JSON dependencies is a nightmare.

@ryandotsmith
Copy link
Contributor

@runnedrun you could consider writing the HTML to a table. Then pass then enqueue the id of that row into QC. Then your worker can just look up the HTML when he picks up the job.

@joevandyk
Copy link
Contributor

@ryandotsmith isn't json in the stdlib?

@ryandotsmith
Copy link
Contributor

@joevandyk good call. I don't have a lot of experience with the stdlib JSON implementation. Is there any reason not to use it?

http://www.ruby-doc.org/stdlib-1.9.2/libdoc/json/rdoc/JSON.html

@joevandyk
Copy link
Contributor

@ryandotsmith json isn't in ruby 1.8's stdlib... that's the only downside i know of.

@ezkl
Copy link
Contributor

ezkl commented Sep 26, 2012

@ryandotsmith Have you seen Intridea's MultiJSON?

MultiJSON tries to have intelligent defaulting. That is, if you have any of the supported engines already loaded, it will utilize them before attempting to load any. When loading, libraries are ordered by speed. First Oj, then Yajl, then the JSON gem, then JSON pure. If no other JSON library is available, MultiJSON falls back to OkJson, a simple, vendorable JSON parser.

It supports and is tested against most rubies.

I've been meaning to contribute to QC. Let me know if you'd like me to fork and implement.

@ryandotsmith
Copy link
Contributor

closing the issue as @ezkl has a PR with a fix.

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

No branches or pull requests

4 participants