The Global Interpreter Lock (GIL) is a mechanism used in some computer language interpreters that allows only one thread to execute at a time. This prevents parallelism and hurts performance. Languages like Python and Ruby use the GIL for increased single-threaded speed and easier integration of C libraries. While removing the GIL is possible, it would require making internal data structures thread-safe. Using separate processes can achieve parallelism but uses significantly more memory.
4. GIL - Global Interpreter Lock
Mechanism used in computer language
interpreters to synchronize the execution
of threads so that only one thread can
execute at a time.
9. GIL - Global Interpreter Lock
Which is the reasons to implement GIL?
10. GIL - Global Interpreter Lock
According to:
Guido van Rossum
Python Creator
Yukihiro "Matz" Matsumoto
Ruby Creator
11. GIL - Global Interpreter Lock
● Increased speed of single-threaded programs (no necessity to acquire
or release locks on all data structures separately)
● Easy integration of C libraries that usually are not thread-safe.
● Ease of implementation (having a single GIL is much simpler to
implement than a lock free interpreter or one using fine grained locks).
12. GIL - Global Interpreter Lock
It is possible remove GIL from this
interpreters?
13. GIL - Global Interpreter Lock
We can not eliminate it because memory
management(internal data structures) is
not thread-safe in this interpreters!
14. GIL - Global Interpreter Lock
Ways to minimise the performance
problem
15. GIL - Global Interpreter Lock
Use separate processes to achieve full
parallelism, as each process has its own
interpreter and in turn has its own GIL.
16. GIL - Global Interpreter Lock
Problem
Increase the amount of memory used
very fast!
17. GIL - Global Interpreter Lock
In fact, there are ways to implement interpreters without GIL, below there is a
list of environments that do not have GIL where you could run your favority
language: