This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: >100k alloc wasted on startup
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: mikesfpy, rhettinger, tim.peters
Priority: normal Keywords: patch

Created on 2004-01-12 21:30 by mikesfpy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
intobject.c.diff mikesfpy, 2004-01-12 21:30 Patch vs. Objects/intobject.c
Messages (3)
msg45236 - (view) Author: Mike Pall (mikesfpy) Date: 2004-01-12 21:30
A glaring error in Objects/intobject.c function _PyInt_Init():

It allocates a whole BLOCK of ints each time through the loop
(i.e. 106 blocks of 1K size) and not just 106 int objects.

Allocating 106 blocks means a preallocation of more than 8600
int objects which is VERY unlikely to be needed by most programs.
So this bug wastes more than 100K on every startup.

The appended patch is vs. the current CVS. The bug is present
in 2.3.* and also in 2.2.? (not sure if I interpret the CVS logs right).

If you don't believe that this bug exists, just add a putc('#',stderr);
right before the code in fill_free_list() and see what happens when
you startup python. :-)
msg45237 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-01-12 21:45
Logged In: YES 
user_id=31435

Good eye!  Your analysis is correct, and the patch looks good 
too.  It's probably bad that the current code is spraying 
the "frequently used" little integers all over memory too.  The 
patch also fixes that.
msg45238 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-02-08 18:59
Logged In: YES 
user_id=80475

Accepted and applied to Objects/intobject.c 2.108 and 2.105.8.1
.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39808
2004-01-12 21:30:50mikesfpycreate