Code Monkey home page Code Monkey logo

Comments (5)

colinxs avatar colinxs commented on July 1, 2024

In reference to #691, changing allocated_lock in src/memory/binned.jl to a ReentrantLock appears to alleviate this issue, and it's not too much slower:

julia> l1=Threads.SpinLock();

julia> l2=ReentrantLock();

julia> @btime Base.@lock $l1 begin end
  20.569 ns (0 allocations: 0 bytes)

julia> @btime Base.@lock $l2 begin end
  37.242 ns (0 allocations: 0 bytes)

Perhaps changing all/some of the locks in CuArrays to a ReentrantLock could serve as a stopgap?

from cuarrays.jl.

maleadt avatar maleadt commented on July 1, 2024

Perhaps changing all/some of the locks in CuArrays to a ReentrantLock could serve as a stopgap?

No, the code does not support that. I'll have a look.

from cuarrays.jl.

colinxs avatar colinxs commented on July 1, 2024

Ah I thought they'd be interchangeable. Could you elaborate why the code wouldn't support a ReentrantLock?

from cuarrays.jl.

maleadt avatar maleadt commented on July 1, 2024

A reentrant lock can be taken by the same task. But in this case, we're protecting against concurrent access of datastructures that are used in regular code as well as from finalizers. So while we're modifying the map and have the lock, a GC run could trigger our finalizer that, potentially on the same task, will be able to acquire the lock and start modifying the same datastructure too.

from cuarrays.jl.

colinxs avatar colinxs commented on July 1, 2024

I see. So there's no guarantee that finalizes are run in a separate task and swapping allocated_lock to a ReentrantLock only masked that underlying problem. Thanks for clarifying! I tried to grok the code in gc.c/task.c etc. but.. there's a lot there :)

from cuarrays.jl.

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.