#15104: Special case modn_dense matrix operations to improve performance
-------------------------------------+-------------------------------------
       Reporter:  nbruin             |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.2
      Component:  linear algebra     |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Nils Bruin, Simon  |    Reviewers:
  King                               |  Work issues:  regression in
Report Upstream:  N/A                |  right_kernel_matrix
         Branch:                     |       Commit:
  u/SimonKing/ticket/15104           |  0f008f9266e3ed6fbd67e7f3d357474825bdb160
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 Running `M.right_kernel_matrix(basis='computed')` 1000 times, prun yields
 {{{
    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      1000    0.130    0.000    0.131    0.000
 dynamic_class.py:324(dynamic_class_internal)
      1000    0.068    0.000    0.414    0.000
 matrix_space.py:221(__init__)
      1000    0.038    0.000    0.580    0.001 {method
 'right_kernel_matrix' of
 'sage.matrix.matrix_modn_dense_float.Matrix_modn_dense_template' objects}
      1000    0.035    0.000    0.070    0.000
 matrix_space.py:929(_get_matrix_class)
      1000    0.031    0.000    0.066    0.000 arith.py:407(is_prime)
      1000    0.028    0.000    0.470    0.000
 matrix_space.py:145(__classcall__)
      1000    0.027    0.000    0.259    0.000
 category.py:435(__classcall__)
     11000    0.023    0.000    0.023    0.000 {isinstance}
 2000/1000    0.017    0.000    0.428    0.000
 unique_representation.py:1006(__classcall__)
      1000    0.016    0.000    0.019    0.000 {method 'is_prime' of
 'sage.rings.integer.Integer' objects}
      1000    0.015    0.000    0.192    0.000
 category_types.py:324(__init__)
      8000    0.014    0.000    0.014    0.000
 finite_field_prime_modn.py:272(order)
      1000    0.014    0.000    0.172    0.000 category.py:466(__init__)
         1    0.013    0.013    0.592    0.592 <string>:1(<module>)
 2000/1000    0.010    0.000    0.419    0.000
 {sage.misc.classcall_metaclass.typecall}
      1000    0.008    0.000    0.011    0.000 all.py:1(arithmetic)
      1000    0.008    0.000    0.276    0.000
 modules.py:70(__classcall_private__)
      2000    0.008    0.000    0.012    0.000 weakref.py:223(__new__)
      2000    0.007    0.000    0.007    0.000 weakref.py:228(__init__)
      1000    0.007    0.000    0.015    0.000
 category.py:1964(_make_named_class)
      1000    0.007    0.000    0.138    0.000
 dynamic_class.py:122(dynamic_class)
      1000    0.006    0.000    0.265    0.000
 vector_spaces.py:34(__classcall_private__)
      1000    0.006    0.000    0.010    0.000
 finite_field_prime_modn.py:99(__cmp__)
      1000    0.005    0.000    0.177    0.000
 category_types.py:202(__init__)
      1000    0.005    0.000    0.020    0.000
 category.py:1238(subcategory_class)
      1000    0.005    0.000    0.197    0.000
 vector_spaces.py:64(__init__)
      2000    0.004    0.000    0.004    0.000 {built-in method __new__ of
 type object at 0xb775ffc0}
      1000    0.004    0.000    0.006    0.000
 category_types.py:206(_make_named_class_key)
      1000    0.004    0.000    0.006    0.000
 rational_field.py:994(is_RationalField)
      1000    0.003    0.000    0.005    0.000
 integer_mod_ring.py:148(is_IntegerModRing)
      1000    0.003    0.000    0.005    0.000
 number_field.py:920(is_CyclotomicField)
      1000    0.003    0.000    0.003    0.000 fields.py:60(__contains__)
      1000    0.002    0.000    0.002    0.000 proof.py:151(get_flag)
      1000    0.002    0.000    0.002    0.000 proof.py:18(arithmetic)
      1000    0.002    0.000    0.002    0.000 {cmp}
      1000    0.002    0.000    0.002    0.000
 matrix_space.py:1095(is_dense)
      1000    0.002    0.000    0.002    0.000 matrix_space.py:1433(nrows)
      1000    0.002    0.000    0.002    0.000 matrix_space.py:1421(ncols)
      1000    0.002    0.000    0.002    0.000
 {sage.rings.integer_ring.is_IntegerRing}
      1000    0.002    0.000    0.002    0.000 {method 'category' of
 'sage.rings.ring.Ring' objects}
      1000    0.002    0.000    0.002    0.000
 finite_field_prime_modn.py:202(characteristic)
      1000    0.002    0.000    0.002    0.000 {method 'has_key' of 'dict'
 objects}
      1000    0.002    0.000    0.002    0.000 {method 'base_ring' of
 'sage.structure.category_object.CategoryObject' objects}
         1    0.000    0.000    0.000    0.000 {range}
         1    0.000    0.000    0.000    0.000 {method 'disable' of
 '_lsprof.Profiler' objects}
 }}}
 with the current branch. So, a matrix space is created 1000 times---I
 suppose that this only happens because of weak caching.

--
Ticket URL: <http://trac.sagemath.org/ticket/15104#comment:20>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to