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

Changes in pod6 files not available after the first call to update-cache #16

Open
antoniogamiz opened this issue Feb 11, 2020 · 25 comments
Labels
bug Something isn't working ⚠️Urgent⚠️

Comments

@antoniogamiz
Copy link
Collaborator

You can see that happening in Raku/Documentable#73.

Maybe this question is relevant to the problem.

@antoniogamiz antoniogamiz added the bug Something isn't working label Feb 11, 2020
@JJ
Copy link
Collaborator

JJ commented Feb 12, 2020 via email

@JJ
Copy link
Collaborator

JJ commented Feb 26, 2020

The new version of 040-pod-extraction is failing now with:

Attempt to obtain non-existent POD for <a-pod-file>. Is the source new and failed to compile? Has the cache been updated?
  in method pod at /home/jmerelo/Code/forks/raku/pod-cached/lib/Pod/To/Cached.pm6 (Pod::To::Cached) line 214
  in block <unit> at t/040-pod-extraction.t line 34

This is due to the fact that, before, stuff was created and then tested in a different instance of a program. Now that we do it in the same instance it's not going to work. So that's the deeper problem I talk about in #17

JJ added a commit that referenced this issue Feb 26, 2020
Understanding the power of the cache
JJ added a commit that referenced this issue Feb 26, 2020
Seeing some light at the end of the tunnel for #16 and #13. Also just eliminating debug code. And found also #18
JJ added a commit that referenced this issue Feb 27, 2020
Text does not update
@antoniogamiz
Copy link
Collaborator Author

I have been trying to unlock the cache as @JJ said here, without any success. I propose to use Pod::Load to serve the pods that have been modified. I mean, use Pod::Load in get-pods to serve those that have been modified and use the cache for those that have not.

@JJ
Copy link
Collaborator

JJ commented Feb 28, 2020

The way I see it, there are several options

  • Use a different mechanism to update the cache. Right now we are using high-level CompUnits, we should lower that level so that we don't turn the caches into something immutable.
  • Use CompUnits at a higher level. Right now, CompUnits are a mechanism for retrieving precompiled code, which is version-based and has got its own indexing mechanisms. We are avoiding that mechanism altogether and using our own. Maybe we shouldn't; we should piggyback on it and add metainformation to current CompUnit caches.
  • Hack the lock put on installed CompUnits and unlock it.

I think that the only reasonable purpose, relying on tested and documented APIs is the second one. The first is undocumented, and probably not frozen or specced. Ditto for third: we overcome some lock, it's bound to break. Besides, second would be also a way to re-use existing installations so that we can "install" documentation, for instance, and create HTML out of it, which would result in all kinds of good things.

@niner
Copy link

niner commented Feb 29, 2020

Can someone describe for me what you are actually trying to achieve and what kind of issues you are encountering? I'm a bit surprised that no one has ever talked to me about the best way to use our precompilation infrastructure. I could probably give you answers, so you don't have to guess and if there are no answers yet improve our API, so it covers your use case (whatever that is).

Also note that the stable API is defined by these classes and roles:

  • CompUnit
  • CompUnit::DependencySpecification
  • CompUnit::Handle
  • CompUnit::Loader
  • CompUnit::PrecompilationRepository
  • CompUnit::PrecompilationStore
  • CompUnit::PrecompilationId
  • CompUnit::PrecompilationDependency
  • CompUnit::PrecompilationUnit
  • CompUnit::Repository
  • CompUnit::RepositoryRegistry
  • Distribution
  • Distribution::Resource
  • Distribution::Resources

Everything else is subject to change. Everything not covered by spec tests is subject to change.

@JJ
Copy link
Collaborator

JJ commented Feb 29, 2020

Thanks @niner, for dropping by. The basic idea is we want to use the precomp API for a POD cache. In a pinch I would describe it more or less like the current CUR infrastructure, but mutable. We would like to be able to cache a document we have already seen, and then check if the new version of the document is different (by date), and if it is, substitute it.

@niner
Copy link

niner commented Feb 29, 2020

Please don't assume that I know anything about our Pod stuff because....I don't :D
Why do you need a POD cache? Where and how should it be used? That's incidentally something that the README also doesn't answer.

Rakudo doesn't use timestamps for invalidating precomp files. The whole thing works only with checksums of file contents and for good reason. We learned the disadvantages of timestamps the hard way and I'd suggest you spare yourselves the pain and move on to checksums as well. After all the precomp infrastructure wants you to do that anyway.

I don't see why you'd have any issues with the precomp infrastructure for the use case as you've described it. After all, things work just fine when you develop a module in a FileSystem repository and make changes to source files. So I'm gonna need more information on your use case and your troubles.

@JJ
Copy link
Collaborator

JJ commented Feb 29, 2020 via email

@antoniogamiz antoniogamiz changed the title Changes in pod6 files not available after the firs call to update-cache Changes in pod6 files not available after the first call to update-cache Feb 29, 2020
@niner
Copy link

niner commented Feb 29, 2020 via email

@antoniogamiz
Copy link
Collaborator Author

Steps to reproduce it: Raku/Documentable#73 (comment)

@niner
Copy link

niner commented Feb 29, 2020

After installing Documentable::CLI (had to skip tests as Pod::To::Cached doesn't seem to installed), I tried the script you pointed out:

nine@sphinx:~/test> mkdir Pod-To-Cached-issue-73
nine@sphinx:~/test> cd Pod-To-Cached-issue-73/
nine@sphinx:~/test/Pod-To-Cached-issue-73> cat > test.raku
use lib 'lib';
use Documentable::CLI;
use Pod::To::Cached;
use Documentable::Utils::IO;

my $cache-dir = cache-path("docs");

my $pod-cache = Pod::To::Cached.new(
    source      => "docs",
    :verbose,
    path        => $cache-dir
);

$pod-cache.update-cache;

my $pod = $pod-cache.pod("type/documentable");

# the subtitle of the pod 
say $pod[0].contents[1].contents[0].contents.first
nine@sphinx:~/test/Pod-To-Cached-issue-73> raku test.raku 
Source verification failed with:
docs is not a directory
  in submethod TWEAK at /home/nine/rakudo/install/share/perl6/site/sources/E4B781FB1DD47C7D9EAE831448606DD3EBCDC8ED (Pod::To::Cached) line 63
  in block <unit> at test.raku line 8

Is that the error this issue is about?

@antoniogamiz
Copy link
Collaborator Author

antoniogamiz commented Feb 29, 2020

You need to run it from the Documenable repo, so you have to clone it first. Sorry, I should have said that.

@niner
Copy link

niner commented Feb 29, 2020

nine@sphinx:~/test/Pod-To-Cached-issue-73/Documentable (master=)> raku ../test.raku
Source verified
Got cache at ./.cache-docs
Caching language/cli
Caching type/documentable/secondary
Caching type/documentable/docpage
Caching language/typegraph
Caching language/configuration-file
Caching type/documentable/config
Caching homepage
Caching language/document-format
Caching type/documentable/index
Caching type/documentable/heading/grammar
Caching type/documentable/to/html/wrapper
Caching type/documentable/primary
Caching type/documentable
Caching language/highlighting
Caching type/documentable/search
Caching type/docpage/factory
Caching type/documentable/registry
Caching 404
Cache fully updated
Represents a self-contained Perl 6 documentation element.
nine@sphinx:~/test/Pod-To-Cached-issue-73/Documentable (master=)> vi docs/Type/Documentable.pod6
nine@sphinx:~/test/Pod-To-Cached-issue-73/Documentable (master=)> raku ../test.raku
Source verified
Got cache at ./.cache-docs
Caching type/documentable
Cache fully updated
Represents a self-contained Perl 6 documentation element.
nine@sphinx:~/test/Pod-To-Cached-issue-73/Documentable (master *=)>

I don't get any error. Seems to work just fine?

@antoniogamiz
Copy link
Collaborator Author

Have you modified the subtitle of the pod? Does that change appear? Nope.

@antoniogamiz
Copy link
Collaborator Author

And that's the error, that we never truly update the cache. I mean, we update it, but those changes are not available to the program running the cache. For those changes to be available, we need to stop running the program and start it again.

@niner
Copy link

niner commented Feb 29, 2020 via email

@antoniogamiz
Copy link
Collaborator Author

When you print it. In the first run of the script you got:

Represents a self-contained Perl 6 documentation element.

And in the second run, supposedly after you modified the subtitle:

Represents a self-contained Perl 6 documentation element.

As you can see, the changes are not available.

@niner
Copy link

niner commented Feb 29, 2020

Unfortunately I've got to go now. Would have been so useful to have this info as real steps to reproduce, so I wouldn't have had to guess so much.

@antoniogamiz
Copy link
Collaborator Author

Sorry for all the trouble and misunderstanding, I should have added that to the issue. I will try to do it better next time, thanks for your time.

@niner
Copy link

niner commented Feb 29, 2020

I replaced Pod::To::Cached with the code I suggested above and it precompiles and picks up changes in the files just fine:

my $pod-file-path = "docs/Type/Documentable.pod6";

my $precomp-repo = CompUnit::PrecompilationRepository::Default.new(
    :store(CompUnit::PrecompilationStore::File.new(:prefix('docs/.precomp'.IO))),
);
my $handle = $precomp-repo.try-load(
    CompUnit::PrecompilationDependency::File.new(
        :src($pod-file-path),
        :id(CompUnit::PrecompilationId.new-from-string($pod-file-path)),
        :spec(CompUnit::DependencySpecification.new(:short-name($pod-file-path))),
    ),
);

use nqp;
my $pod = nqp::atkey($handle.unit, '$=pod');

say $pod[0].contents[1].contents[0].contents.first;

@antoniogamiz
Copy link
Collaborator Author

That's fantastic. I will try to use that code in Pod::To::Cached and see what happens. Thanks a lot for your help :).

@JJ
Copy link
Collaborator

JJ commented Feb 29, 2020 via email

@JJ
Copy link
Collaborator

JJ commented Feb 29, 2020 via email

antoniogamiz added a commit to antoniogamiz/Pod-To-Cached that referenced this issue Mar 15, 2020
@JJ
Copy link
Collaborator

JJ commented May 6, 2020

We need to fix this pronto, using code suggested by @niner
This is going to imply a major rewrite, including possibly a change in API. So stay tuned.

@JJ
Copy link
Collaborator

JJ commented May 6, 2020

I'm checking this and the changes needed to get it going, and I'm under the impression it's going to be better to just writing a new cache from scratch to use it from Documentable. Most attributes (for instance, the JSON file with state) is not really going to be needed if we use this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ⚠️Urgent⚠️
Projects
None yet
Development

No branches or pull requests

3 participants