#11729: Cache module import locations
---------------------------+------------------------------------------------
   Reporter:  vbraun       |          Owner:  jason       
       Type:  enhancement  |         Status:  new         
   Priority:  major        |      Milestone:  sage-4.7.2  
  Component:  misc         |       Keywords:  sd32        
Work_issues:               |       Upstream:  N/A         
   Reviewer:               |         Author:  Volker Braun
     Merged:               |   Dependencies:              
---------------------------+------------------------------------------------
Description changed by vbraun:

Old description:

> This ticket implements a cached module importer for Python. It hooks into
> the Python import framework and caches whether a module was found and if
> so, its location. The cache is persistent over sessions.
>
> Except for the location of the persistent storage (in
> `$DOT_SAGE/import_cache.txt`) there is no dependency on Sage.
>
> By default, the cached importer is not active. To activate it on your
> system, you have to import the module at one point in the Python startup,
> preferably as early as possible. The easiest way to do so is to create a
> file `$SAGE_LOCAL/lib/python/site-packages/sitecustomize.py` containing
> the single line
> {{{
> import sage.misc.importer
> }}}
>
> Some benchmarks:
> {{{
> #!sh
> [vbraun@volker-laptop-two ~]$ rm ~/.sage/import_cache.txt
> [vbraun@volker-laptop-two ~]$ strace -e file -f sage -c quit |& grep
> ENOENT | wc
>   20173  243630 3085872
> [vbraun@volker-laptop-two ~]$ strace -e file -f sage -c quit |& grep
> ENOENT | wc
>    2276   28856  258830
> [vbraun@volker-laptop-two ~]$ strace -e file -f sage -c quit |& grep
> ENOENT | wc
>    2276   28905  257473
> }}}
> Sage-4.7.2.alpha1 startuptime on my laptop decreased from 0.89s to 0.78s
> with the cached importer.
>
> Note: at this point you should erase the `import_cache.txt` before and
> after rebuilding the sage library. In the future, we might introduce
> timestamps for the cache to be erased automatically if it is obsolete.

New description:

 This ticket implements a cached module importer for Python. It compiles a
 list of all available files during build (when sage -b is run), hooks into
 the Python import framework and finds modules by the predetermined file
 list.


 Apply trac_11729_cached_importer.patch to the sage library and
 trac_11729_import_cache_during_build.patch to the sage_scripts
 (`$AGE_LOCAL/bin`) repository.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11729#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to