Re: Threads, Sockets and OSX

Eric Wong <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <20181206101027.GA28419@dcvr>
Peter Hickman <[email protected]> wrote:
> Using RVM on OSX I've tested this for 2.3.3 and 2.5.1 with no significant
> change in the behaviour. I did note that under 2.5.1 the freeze ups were
> shorter and the periods of work were longer but the picket fence CPU usage
> remains (100% for 15 seconds, 0% for 10 seconds, repeat)

So that might be down to the Mutex implementation being less OS-dependent
in 2.5.

Care to give 2.6 preview3 a try?

> I'm wondering, does Ruby implement it's own threading system or call out to
> the underlying OS services. This could be down to how OSX schedules stuff
> rather than a Ruby version issue

Ruby uses native threads and locking mechanisms; but the GVL
limits their ability of threads to run in parallel to only a few
safepoints.  The GVL is a custom lock designed for
high-contention.  It's implemented using normal pthreads
primitives, but optimized for contention, whereas normal
pthreads mutexes are optimized for low contention.

> Perhaps I need to implement this in Python and see if I get the same
> behaviour

AFAIK, Python's GVL is/was similar to ours, but had a fixed timeslice
with more wakeups and higher power consumption as a result.

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.