Opened 9 years ago

Closed 7 years ago

Last modified 21 months ago

#8431 closed defect (fixed)

Invoke python with -OO to save memory

Reported by: cscott Owned by: dsd
Priority: normal Milestone:
Component: sugar Version: Development build as of this date
Keywords: Cc:
Blocked By: #8438 Blocking:
Deployments affected: Action Needed: test in build
Verified: no


The sugar shell and any long lived services should invoke python with -OO to save memory. This saves about 6M of memory space, at the cost of NAND space for the .pyo files.

This bug will track investigation into this issue, as discussed in (and the referenced previous discussion and buzilla/numpy bugs).

Change History (11)

comment:1 Changed 9 years ago by cscott

I've begun by putting patched versions of python 2.5.1 and numpy into joyride, with the fixes linked to from and

Both these patches are upstream, and have appeared in python 2.5.2/will appear in numpy 1.2.0, so we won't be carrying these patches long.

Putting the patched versions in joyride will make it easier for experimenters to quantify the costs by editing their local image to turn on -OO and generating the appropriate .pyo files.

comment:2 Changed 9 years ago by cscott

  • Blocked By 8438 added

comment:3 Changed 9 years ago by cscott

With the patch for #8438, I've edited /usr/bin/sugar-shell to change the first line to #!/usr/bin/python2.5 -OO and run without any obvious problems.

For speed I also generated .pyo files as follows:

$ python2.5 -OO
>>> import compileall
>>> compileall.compile_path()
>>> compileall.compile_dir('/usr/share/sugar/shell')

I haven't determined how much extra space the .pyo files add to the image, but in devel@ it was suggested that we generate .pyo files *instead* of .pyc files -- so the net result should be a savings in NAND space.

comment:4 Changed 7 years ago by dsd

  • Milestone changed from Opportunity to 1.5-future

As of F11 those python and numpy bugs are fixed and after compiling all pyo objects, a quick PYTHONOPTIMIZE=2 export in olpc-session doesn't break anything obvious. would be nice to revisit this.

comment:5 Changed 7 years ago by Quozl

  • Milestone changed from 1.5-future to 1.5-software-update

comment:6 Changed 7 years ago by dsd

  • Owner changed from cscott to dsd

I plan to remove all pyc files from the build and replace them with pyo. This will save about 3mb of disk space.
I'll add the PYTHONOPTIMIZE to olpc-session. This will affect all programs opened under Sugar and GNOME. I also checked that Sugar, the presence service, and the datastore are all started in this mode too.

comment:7 Changed 7 years ago by dsd

  • Action Needed changed from never set to test in build

olpc-utils-1.0.15 ready for testing in next build

comment:8 Changed 7 years ago by Quozl

  • Milestone changed from 1.5-software-later to 1.5-software-update

comment:9 Changed 7 years ago by cjb

test in os102

comment:10 Changed 7 years ago by RafaelOrtiz

  • Resolution set to fixed
  • Status changed from new to closed

comment:11 Changed 21 months ago by Quozl

  • Milestone 10.1.1 deleted

Milestone 10.1.1 deleted

Note: See TracTickets for help on using tickets.