From: vanekl on
I think the Captain is referring to something like this,
http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task-or-process.html


"fortunatus" <daniel.eliason(a)excite.com> wrote in message
news:fc490d1c-259e-4e94-ab67-90481c52589d(a)o30g2000yqb.googlegroups.com...
On Mar 6, 1:03 pm, "Captain Obvious" <udode...(a)users.sourceforge.net>
wrote:
> Are you testing this on a single-core system?
> Race conditions are rare on them, but on SMP systems (multi-core and/or
> multi-processor) they are much more frequent.
>
> For this reason I usually pin Lisp processes to CPUs in production.


How do you pin Lisp threads to CPUs?

Can you give an example for a particular Lisp implemtation (I'm hoping
SBCL or CLISP...) or point a manual page?

I assume by "Lisp processes" you are referring to threads in one Lisp
image, rather than running multiple Lisp images?


From: fortunatus on
On Mar 8, 12:10 pm, "vanekl" <va...(a)acd.net> wrote:
> I think the Captain is referring to something like this,http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task...
>
> news:fc490d1c-259e-4e94-ab67-90481c52589d(a)o30g2000yqb.googlegroups.com...
> On Mar 6, 1:03 pm, "Captain Obvious" <udode...(a)users.sourceforge.net>
> wrote:
> > For this reason I usually pin Lisp processes to CPUs in production.
>
> "fortunatus" <daniel.elia...(a)excite.com> wrote in message
> How do you pin Lisp threads to CPUs?


Thanks... I think that case would be referring to running multiple
whole Lisp images and setting processor affinity for each.

I'm interested if there are ways to set processor affinity for threads
running in one Lisp image.
From: Thomas A. Russ on
vanekl <vanek(a)acd.net> writes:

> On Mar 5, 8:50��pm, Giorgos Keramidas <keram...(a)ceid.upatras.gr> wrote:
> > It's probably a good idea to bind *PRINT-READABLY* with let instead of
> > setf in 'save', but this is really a minor detail; one that is easy to
> > notice and fix.
>
>
> Yeah, I tried this when I printed a hash table but for some reason the
> print would fail until I got rid of the LET binding. I don't
> understand why, so I just went with what works.

Well, the reason printing a hash table will fail when *PRINT-READABLY*
is non-NIl is because the standard printer for hash tables does not
print a readable representation of the tables. (Which is a shame).

So, if you were to print anyway (with *PRINT-READABLY* = NIL), you would
not be able to successfully read in the resulting printed form. So you
would lose data.

That is why *PRINT-READABLY* is there. So that you can tell whether
what you print can be successfully read back into lisp. If you get an
error message whenever you are printing something then you are informed
that what you are printing isn't readable. And you don't end up
assuming you saved something that you won't be able to read back in.

--
Thomas A. Russ, USC/Information Sciences Institute
From: vanekl on
On Mar 8, 12:52 pm, fortunatus <daniel.elia...(a)excite.com> wrote:
> On Mar 8, 12:10 pm, "vanekl" <va...(a)acd.net> wrote:
>
> > I think the Captain is referring to something like this,http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task...
>
> >news:fc490d1c-259e-4e94-ab67-90481c52589d(a)o30g2000yqb.googlegroups.com....
> > On Mar 6, 1:03 pm, "Captain Obvious" <udode...(a)users.sourceforge.net>
> > wrote:
> > > For this reason I usually pin Lisp processes to CPUs in production.
>
> > "fortunatus" <daniel.elia...(a)excite.com> wrote in message
> > How do you pin Lisp threads to CPUs?
>
> Thanks... I think that case would be referring to running multiple
> whole Lisp images and setting processor affinity for each.
>
> I'm interested if there are ways to set processor affinity for threads
> running in one Lisp image.


Thread affinity is inherited from whatever you set the process
affinity to on Linux 2.6.
http://www.ibm.com/developerworks/linux/library/l-affinity.html
From: Captain Obvious on
f> I assume by "Lisp processes" you are referring to threads in one Lisp
f> image, rather than running multiple Lisp images?

No, I'm not referring to threads. Pinning threads is very unlikely to have
any effects on race conditions.

All threads in a Lisp image share same address space (state), and race
conditions happen when more than one thread tries to change same piece of
state, or one thread is reading while another is writing or something like
that.
The idea is to pin whole Lisp process (image) to one CPU so that whole
process can do only one thing at a time.

As for running multiple Lisp images, it is kind of orthogonal. Yeah, you
might want to run many of them, or you can run non-Lisp processes on other
CPUs, whatever is good for you.
I'd say that running multiple Lisp processes makes sense in context of
web-servring, but unfortunately SBCL is a pig w.r.t. memory usage, so it
depends...

f> Can you give an example for a particular Lisp implemtation (I'm
f> hoping SBCL or CLISP...) or point a manual page?

Check your OS manual. On Linux each thread has a processes ID, and you can
use sched_setaffinity() on it.
For example, via a commandline utility taskset.

E.g. when I run a fresh SBCL it has one thread:

alex(a)debetch:~$ ps mo pid,tid,comm -C sbcl
PID TID COMMAND
6498 - sbcl
- 6498 -

Now I make a thread:
* (sb-thread:make-thread (lambda () (loop (sleep 1.0))))

#<SB-THREAD:THREAD {AF04E29}>

And I see it in `ps` output:

alex(a)debetch:~$ ps mo pid,tid,comm -C sbcl
PID TID COMMAND
6498 - sbcl
- 6498 -
- 6538 -

Now I can taskset them independently:

alex(a)debetch:~$ taskset -p 6498
pid 6498's current affinity mask: 3
alex(a)debetch:~$ taskset -p 6538
pid 6538's current affinity mask: 3
alex(a)debetch:~$ sudo taskset -p 1 6498
Password:
pid 6498's current affinity mask: 3
pid 6498's new affinity mask: 1
alex(a)debetch:~$ sudo taskset -p 2 6538
pid 6538's current affinity mask: 3
pid 6538's new affinity mask: 2
alex(a)debetch:~$ taskset -p 6498
pid 6498's current affinity mask: 1
alex(a)debetch:~$ taskset -p 6538
pid 6538's current affinity mask: 2