Python threads: Dive into GIL!

Talks | Submit a talk
Authors Vishal Kanaujia, Chetan Giridhar
Talk Type talk
Level Intermediate
Topic Core Python (including Python 3.x)
Tags Multi-threading, Python Internals, GIL, Performance
Summary

Benefit of multi-threaded application grows with ubiquity of multi-core architecture that potentially can simultaneously run multiple threads of execution. Python supports multi-threaded applications and developers are flocking to realize the assured gain of multiple cores with threaded applications.

Unfortunately, Python has significant bottleneck for multi-threading. Any thread in CPython interpreter requires a special lock (GIL) which results in serial, rather than parallel execution of multi-threaded applications, irrespective of cores availability and design techniques.

This talk focuses on the problem, dissects the root cause and its implications. The problem alleviation is discussed with introduction of Python3.0 which has new GIL implementation, improving the overall performance of Python threads.

Outline

This talk covers the following:

  • Threading fundamentals
  • Using threads in python programming – An example
  • Overview of Global Interpreter Lock
  • Diving into GIL
  • Comparing GIL implementation – v2.7 and v3.2
  • Experiment and Measure
  • Jython: In GIL context
  • Conclusion
Notes

This topic is culminated from our professional experiences of dealing with python threads. Intended audiences: Python for Linux developers, industry experts and students.

Profile of the authors

Vishal Kanaujia: has experience of working in Python on Linux environment and is a frequent contributor to reputed magazines including 'Linux-For-You' and 'AgileRecord'. You can reach Vishal at vishalkanaujia@gmail.com

Chetan Giridhar: has extensive experience with Python programming. He is technical reviewer of 'Python Testing Cookbook', author of 'Design patterns in python' book and is an Editor at the 'The Python papers Anthology'. You can visit him at Technobeans

Files
file size uploaded comment
convoyPy3_2.txt 1.8 KB september 7, 2011 Convoy effect with Python3.2
Python-threads_v4.0.pdf 167.8 KB september 7, 2011 Python threads presentation v4.0
Python-threads_v3.0.pdf 143.2 KB september 6, 2011 Python threads presentation v3.0
Python-threads.pdf 472.2 KB september 5, 2011 version 2 of the presentation
Python-threads.pptx 169.5 KB september 5, 2011 version 2 of the presentation
Python-threads_v1.0.pdf 157.7 KB september 1, 2011 Python threads presentation
Multi-threaded.py 1.4 KB August 31, 2011 Issues with mutli-threaded Python applications

You can upload or delete a file if you are author of this talk.