Giter VIP home page Giter VIP logo

Comments (3)

daochenzha avatar daochenzha commented on May 12, 2024

@huzhoudaxia Very good question. Basically, the get_batch is getting a batch of samples instead of one sample. After getting all the samples, it will send the signals to the free_queue. Since there are multiple threads, there could be some weird cases. Let me give you an example:

Suppose we use 4 threads, the batch size is 32, and the number of buffers is 50. The four threads all request 32 samples (and they will only send free signals after getting 32 samples). Suppose at some time step, they get, 12, 12, 12, and 14 samples, respectively. At this time step, the program will get stuck since the buffers have not been freed.

Thus, we add a lock here to make getting 32 samples atomic.

from douzero.

huzhoudaxia avatar huzhoudaxia commented on May 12, 2024

@daochenzha Thank you for your time. Your answer is very helpful.

from douzero.

yffbit avatar yffbit commented on May 12, 2024

similar to the Dining Philosophers Problem

from douzero.

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.