homalg-project / CAP_project

CAP project -- Categories, Algorithms, and Programming
https://homalg-project.github.io/docs/CAP_project-based/
24 stars 18 forks source link

Caching for functors #526

Open mohamed-barakat opened 4 years ago

mohamed-barakat commented 4 years ago

How can I disable caching for a functor or a natural transformation?

kamalsaleh commented 4 years ago

I deactivate the Object/MorphismCache of the functor and the NaturalTransformationCache for the transformation:

# for func.
DeactivateCachingObject( ObjectCache( F ) );
DeactivateCachingObject( MorphismCache( F ) );
# for nat.
DeactivateCachingObject( NaturalTransformationCache( eta ) );

I don't think there are a convenience methods for that yet.

mohamed-barakat commented 4 years ago

Excellent, thank you very much.

Let us turn this issue into a feature request for improving the documentation of the CAP manual in

Section 1.7 Caching

mohamed-barakat commented 4 years ago

I have now disabled the object/morphism caches for all functors created in FunctorCategories. I would be grateful if you could test the new behavior of Bialgebroids and FunctorCategories. I will add back "custom" object caching to the functors later which should be much faster than the current deactivated one.

kamalsaleh commented 4 years ago

It seems that the last commit in functor categories should be adjusted:

Here is timing experiment:

In functor categories package, example beilinson_quiver.g, let

a := DirectSum( List( [ 1 .. 14 ], i -> Random( indec_projs ) ) );;
b := DirectSum( List( [ 1 .. 14 ], i -> Random( indec_projs ) ) );;

Before deactivating the caching:

B := Time( BasisOfExternalHom, [a,b] );;
#! 32.203597235 Secs.
Size(B);
#! 492
Time( Sum, [B] );
#! 5.403279159 Secs.

After deactivating the caching:

B := Time( BasisOfExternalHom, [a,b] );;
#! 32.473417945 Secs.
Size(B);
#! 492
Time( Sum, [B] );
#! 71.87341444499999 Secs.
mohamed-barakat commented 4 years ago

Could you please open an issue on FunctorCategories so we can keep the traffic low here.