Git Product home page Git Product logo

Comments (4)

miniway avatar miniway commented on June 8, 2024

Basically, I don't like using ThreadLocal, but it was not easy to make API compatible with jzmq without performance penalty.

The first implementation was to create Selector at the poller constructor. This was safer but some usage and example pattern was

while
    create poller            # creates Selector every time and has severe performance penalty
    register handles
    poll

At that time, there was a document to guide to create a poller outside of a loop,

create poller
register handles
while
    poll

From the 0.2.0, ThreadLocal has been used as both patterns could have same performance based on assumptions.

  • Poller should be created and used on the same thread
  • There would not be a case which one thread needs to wait on multiple poller.

We should have enhanced the document.

from jeromq.

kdlan avatar kdlan commented on June 8, 2024

But this still force me to change my code...

Have you considered to move the Poller.open() from the constructor to the Poller.poll() where the selector is eventually been used in the Poller. In this way, the Poller object shoud not need to hold the selector instance and when call Poller.poll, just get it from the ThreadLocal variable and pass it to zmq.ZMQ.zmq_poll

This seems can fix my issue and have no influence on performance as 0.2.0.

from jeromq.

miniway avatar miniway commented on June 8, 2024

I would still recommend not sharing the Poller object between threads for a future change.

If you think the change is meaningful to the community, please send a pull request on it.

from jeromq.

kdlan avatar kdlan commented on June 8, 2024

It seems 0.3.0-SNAPSHOT have deprecated org.jeromq.ZMQ and org.zeromq.ZMQ.Poller does not holder the threadlocal variable. I will wait 0.3.0 and move to the new api

from jeromq.

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.