Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cache in getproperty for GAPFuncsType #123

Closed
fingolfin opened this issue Nov 2, 2018 · 4 comments
Closed

Improve cache in getproperty for GAPFuncsType #123

fingolfin opened this issue Nov 2, 2018 · 4 comments
Labels
kind: enhancement New feature or request

Comments

@fingolfin
Copy link
Member

That cache is problematic, because it will become out of date if the identifier is changed on the GAP side.

This problem could be avoided, while still retaining most of the performance gain (which in turn I believe mostly stems from avoiding to convert a jl_symbol into a GAP string object), if instead of caching the function pointer, we cached the GAP GVar (an plain UInt value). Then that GVar value can be used to efficiently retrieve the currently assigned value, if any.

This cache of GVar values then could also be used in other places that want to give access to gap global variables.

@fingolfin fingolfin added the kind: enhancement New feature or request label Nov 2, 2018
@fingolfin
Copy link
Member Author

Of course it might be useful to benchmark the various approaches. Code which needs optimal performance should also copy the function out, i.e. myfunc = GAP.GAPFuncs.myfunc, then call that. So I'd compare that in the benchmark, too. I'd do it now, except for the crashes, see PR #121

@fingolfin
Copy link
Member Author

So one argument for keeping the cache as-is, which I overlooked before, is that each GAP object is wrapped into a Julia GapFunc object. But I wonder why: couldn't the Julia function call function simply be defined for MPtr instead? Since creating a GapFunc performs no additional error checking, there seems to be no convenience lost, is there?

@sebasguts
Copy link
Contributor

Well, technically we could overload the () operator for all MPtr, no problem. I think this is a sensible addition anyway.

The caching is of course done for speedup only, but you are right, it is potentially dangerous. I would suggest the following:

  • Drop the GapFunc type.
  • Rename the GAPFuncs variable into something like GAPObjs, and do the caching with the gvarnum.
  • Allow calling all GAP objects, for better or worse (as GAP does anyway)

What do you think?

@fingolfin
Copy link
Member Author

Sounds good to me. One more remark, though: all the other "convenience" wrappers for GAP functionality from within Julia are now in LibGAP.jl/src/gap.jl, only the "call function" one is in JuliaInterface/julia/gaptypes.jl. I don't see a reason for that, and would suggest moving it to LibGAP.jl, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants