In the book
The Electromagnetic Age: Work, Love, and Life When Robots Rule the World, Robin Hanson briefly discusses the degradation of programs:
The software was originally developed for one set of tasks, tools and situations. But it is slowly changing to cope with the constant flow of new tasks, tools and situations. Such software becomes more complex, fragile, more difficult to make useful changes to it (Lehman and Biledi, 1985) 1 . In the end, it is better to start all over again and write from scratch new subsystems, and sometimes completely new systems.
I am sure it is true. As a rule, competent adaptation of software to new conditions takes more time and effort than writing new software from scratch. Programmers don't like to admit it, but the evidence is clear. There are several well-known examples in open source projects.
Firefox Multiprocess
Initially,
Mozilla Firefox ran all tasks in a single process. After
Google Chrome was released, it became clear that a multi-process model improves security and performance. Soon, Mozilla developers began to plan how to implement multiprocessing in Firefox. That was in 2007.
Almost ten years later, Mozilla finally
released multi-process Firefox to a massive audience . This delay was not at all due to a lack of desire. Mozilla has talented and motivated developers. However, Chrome was written from scratch in much less time than Firefox took to change. There are two main reasons for this:
')
- The redesign of a single-process architecture into a multiprocess involves many small changes. Some function calls need to be replaced by interprocess communication. The overall state needs to be wrapped in mutexes. Caches and local databases must support concurrent access.
- Firefox must maintain compatibility with existing extensions (or force developers to update them). Chrome created an API for extensions from scratch, with no such restrictions.
But the situation is even worse. Restrictions contradict each other: you need to rebuild the internal architecture, but leave the open-source APIs almost unchanged. No wonder that Mozilla took ten years for such a feat.
Event-Oriented Apache
Apache httpd « ». 80,
accept()
fork()
.
read()
write()
. ,
close()
exit()
.
, … . , . : 1995 . Apache , . ,
10 000 . « » 1000 1000 . , . .
,
Nginx .
Slowloris.
Nginx 2007 , . Nginx Apache httpd .
event Apache 2.2 2005 . . , , mod_php. 2012 , Apache 2.4 (MPM) . ,
prefork MPM-, Nginx. Apache / . MPM httpd
2.
CPython GIL
Python — . , ( , ) . Python : .
GIL.
:
CPython — , . , CPython . ( GIL , ).
GIL . Python . GIL , . . GIL — . CPython, , , Google, Microsoft Intel,
GIL .
, . , , , , .
, . , . , .
1. « : ». , -. . , .
↑2. , httpd, , . .
↑