I would suspect that you would not get a _significant_ performance advantage from specifying processor affinity, but if you really want to measure it and find out by experimentation, read on.
I was not able to find any portable way within a JVM to set processor affinity, after some amount of Googling on the Internet about a year ago. There might be some ways that are specific to some JVMs, but I didn't find any then. If you want to set the processor affinity for an arbitrary process running on Linux, whether it is a JVM or not, you can do so with a sched_affinity() call in a little wrapper process that starts up the process for you. According to the StackOverflow discussion linked below, user tgamblin found that sched_affinity() semantics can vary across Linux distributions. They mention a Portable Linux Processor Affinity library that may be useful, although I haven't tried it myself. They mention that for some high-performance parallel applications, e.g. using the MPI library, it is common practice to manually specify processor affinity. http://stackoverflow.com/questions/360307/multicore-hyperthreading-how-are-threads-distributed Note that if you benchmark manually setting processor affinity vs. not, note that benchmarking this with programs that use very little memory (e.g. an infinite loop that just counts iterations) will likely not show as much difference as a benchmark that has significant usage of the on-chip CPU instruction and/or data cache, so that switching the scheduling of the thread to a different CPU core actually causes significant cache misses after being "moved". Andy On Thu, Oct 20, 2011 at 11:41 AM, Tim Robinson <tim.blacks...@gmail.com>wrote: > This may not be a Clojure specific kind of question, but this is for > my Clojure web app(s) so hopefully it's not too far off. > > Currently when I deploy my web apps I run 1 app instance on 1 app > server. Given these are multi-core servers I am thinking about running > 4 app instances on a server to get max IO capabilities at a lower > cost. (Note that I currently using nginx, to route requests to a > Clojure/Ring+Jetty web app on a specified port. I am expecting that in > order to run 4 app instances I will need to load balance within nginx > to each port and also set the processor affinity for each app instance > to ensure they are balanced across cores). > > So here are my questions: > > 1. Does this idea make sense? why/whynot? > 2. Do you do currently do this for your web apps and can you provide > any insight/experiences that could be helpful? > 3. Is there a way to specify processor affinity within the > application, such that I wouldn't need to manually set them > afterwards? > 4. Are there better ideas to accomplish the same kind of thing? > > Thanks for any help/ideas. > > Tim > > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en