Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > sys.setcheckinterval query

Reply
Thread Tools

sys.setcheckinterval query

 
 
Anand Pillai
Guest
Posts: n/a
 
      07-20-2003
Quoting from documentation on sys module in python
standard documentation.

"""
setcheckinterval(interval)
Set the interpreter's ``check interval''. This integer value
determines how often the interpreter checks for periodic things such
as thread switches and signal handlers. The default is 10, meaning the
check is performed every 10 Python virtual instructions. Setting it to
a larger value may increase performance for programs using threads.
Setting it to a value <= 0 checks every virtual instruction,
maximizing responsiveness as well as overhead.
"""
I have a program that uses multiple threads. Is there any direct
correlation
between the number of threads my program might spawn and the value of
ther
'interval' variable.

I am interested in the last but one statement which says, "Setting it
to a larger value may increase performance for programs using
threads.". So my question is what would that value be? How can I find
out the number of
python 'virtual instructions' for every function I have?

Thanks

~Anand
 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      07-21-2003
Anand Pillai wrote:
>
> """
> setcheckinterval(interval)
> Set the interpreter's ``check interval''. This integer value
> [...]
> """
> I am interested in the last but one statement which says, "Setting it
> to a larger value may increase performance for programs using
> threads.". So my question is what would that value be? How can I find
> out the number of python 'virtual instructions' for every function I have?


Do you really want to waste time optimizing at such a level? I suspect
it's very unlikely you will notice any difference other than with
order-of-magnitude changes. In other words, it's normally every 10
instructions, but if you change it to 100 or 1000 you could notice a
difference. (Zope sets the checkinterval to 120 (in the version I checked),
but I think I'd be surprised if 100 or 140 turned out much different.
Trying to "tune" it to, say 27, or 73, or something would be sheer insanity.

If you need better performance than what you are getting, find your
bottlenecks by profiling and optimize there, or write a C extension,
or use Pyrex, or Psycho or something.

(To find the number of bytecode instructions, use module "dis", BTW.)

-Peter
 
Reply With Quote
 
 
 
 
Aahz
Guest
Posts: n/a
 
      07-23-2003
In article <(E-Mail Removed) >,
Anand Pillai <(E-Mail Removed)> wrote:
>
>"""
>setcheckinterval(interval)
> Set the interpreter's ``check interval''. This integer value
>determines how often the interpreter checks for periodic things such
>as thread switches and signal handlers. The default is 10, meaning the
>check is performed every 10 Python virtual instructions. Setting it to
>a larger value may increase performance for programs using threads.
>Setting it to a value <= 0 checks every virtual instruction,
>maximizing responsiveness as well as overhead.
>"""


Note that Python 2.3 changes the default to 100, so be careful about
hard-coding anything.
--
Aahz ((E-Mail Removed)) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET won't retrieve query results that depend on union query Eric Nelson ASP .Net 5 02-04-2009 10:51 PM
Trying to query the Address table data of AdventureWorks database from Query Analyzer - need help! Learner ASP .Net 1 01-30-2006 08:58 PM
Build dynamic sql query for JSTL <sql:query> Anonymous Java 0 10-13-2005 10:01 PM
xpath query query David Gordon XML 2 05-18-2005 03:33 PM
CAML Query: Multiple Query Fields Issue Jon F. ASP .Net Web Services 0 05-12-2004 08:19 PM



Advertisments