Coder Social home page Coder Social logo

Investigate performance benchmark about exq HOT 20 CLOSED

akira avatar akira commented on May 15, 2024
Investigate performance benchmark

from exq.

Comments (20)

j-mcnally avatar j-mcnally commented on May 15, 2024

can we just make this a test and then assert some anticipated performance time?

from exq.

akira avatar akira commented on May 15, 2024

Yeah that would be a great way to go about it. As part of #21, if we can make a test and assert performance, it would be awesome.

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

Not sure how fast Timex is either, i use it to handle / parse dates. Could be a potential bottleneck?

from exq.

akira avatar akira commented on May 15, 2024

Not sure about Timex, did not look at that one. Even so, if we get the stats recorded async / separate process that shouldn't be an issue, since it would probably be on a different core.

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

Yep yep, sounds like a plan.

from exq.

akira avatar akira commented on May 15, 2024

About to check in the harness - definitely notice a slowdown, this should help diagnose.

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

If we want to test differences between maps / structs and poison / exjson we could try

http://www.erlang.org/doc/man/timer.html#tc-1

from exq.

akira avatar akira commented on May 15, 2024

OK, see #35. With old branch, it is able to get 5k in about 3 seconds. The current version only gets about 1k messages in 6 seconds. There do appear to be some intermittent failures with the Redis shutdown.

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

the terminate callbacks may be getting backed up when they write to redis. Did you test with commenting out the terminate callback to manager?

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

Should we create a redis connection pool? I feel like a single redis connection may cause blocking behavior

from exq.

akira avatar akira commented on May 15, 2024

Looking at it now, it seems like the first major culprit is the job_json method, with the Poison encoding the struct. Using Poison with Enum vs Struct definitely speeds that up.

I feel like Redis is pretty fast, and handles a large number of instructions / sec. It's definitely worth a try though. The other thing is the JSON parsing - another thing worth trying is having multiple dispatchers once the job is out of Redis. I still need to think of the process model / supervision tree to see what the best thing is - we can take a look at something like pool_boy or another library. I do feel like the stats can safely be put in another process because it is out of band (if we do that, we should captures the timestamp before sending it to the stats worker).

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

is {jid, Poison.Encoder.encode(job, %Job{})} faster?

i wonder if supplying the struct type would help Poison to figure things out faster.

from exq.

akira avatar akira commented on May 15, 2024

Yeah looks like, this is faster it seems (same as JSEX):

    jid = UUID.uuid4
    job = Enum.into([{:queue, queue}, {:class, worker}, {:args, args}, {:jid, jid}], HashDict.new)
    {jid, Poison.encode!(job)}

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

cool looks good to me.

from exq.

akira avatar akira commented on May 15, 2024

Seems like the other culprit is the decode (3.8 vs 0.8):

    json = Poison.decode!(state.job)
    job = %Exq.Job{
      queue: Dict.get(json, "queue"),
      class: Dict.get(json, "class"),
      jid: Dict.get(json, "jid"),
      error_message: Dict.get(json, "error_message"),
      error_class: Dict.get(json, "error_class"),
      failed_at: Dict.get(json, "failed_at"),
      retry: Dict.get(json, "retry"),
      retry_count: Dict.get(json, "retry_count"),
      processor: Dict.get(json, "processor"),
      args: Dict.get(json, "args"),
      finished_at: Dict.get(json, "finished_at"),
      enqueued_at: Dict.get(json, "enqueued_at")}

from exq.

akira avatar akira commented on May 15, 2024

And finally... The terminate / sending stats is the final difference. Will see if separating that out will fix it (2.5 vs 4.5 sec).

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

you are doing god's work.

I know we Encode/Decode structs in there.

from exq.

akira avatar akira commented on May 15, 2024

OK I merged #35. There's still a few encode / decode in the stats that I didn't get a chance to fix - I wonder if we can put an encode / decode in the struct.

from exq.

j-mcnally avatar j-mcnally commented on May 15, 2024

yes! i was gonna recommend that. im adding more code that needs to do this, if we can do that, it would be great.

from exq.

akira avatar akira commented on May 15, 2024

OK, looks like that was moved into #40, closing this one.

from exq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.