How to use :since with CompUnit

前端 未结 1 1366
忘了有多久
忘了有多久 2021-01-17 22:40

I am trying to create a cache of POD6 by precompiling them using the CompUnit set of classes.

I can create, store and retrieve pod as follows:

use v6         


        
相关标签:
1条回答
  • 2021-01-17 23:22

    Module loading code caches look ups and essentially start with:

    $lock.protect: { 
        return %loaded{$id} if %loaded{$id}:exists; 
    }
    

    So the question becomes "how do I load a module and then unload it (so i can load it again)?" to which the answer is: you cannot unload a module. You can however change the filename, distribution longname ( via changing the name, auth, api, or version ), or precomp id -- whatever a specific CompUnit::Repository uses to uniquely identify modules -- to bypass the cache.

    What seems to be overlooked is that $key is intended to represent an immutable name, such that it will always point at the same content. What version of foo.pm should be loaded for Module Used::Inside::A if foo.pm is being loaded by Module A and B at the same time, Module A loads foo first, and then Module B modifies foo? The old version Module A loaded, or the ( possibly conflicting with previous version ) Module B loaded version? And how would this differentiation work for precomp file generation themselves ( which again can happen in parallel )?

    Of course if we ignore the above we could add code to make expensive .IO.modified calls for every single module load for all CompUnit::Repository types ( slowing down startup speed ) to say "hey this immutable thing changed". But the granularity of file system modified timestamps on some OS's made the check pretty fragile ( especially for multi-threaded module loading with precomp files being generated ), meaning that even more expensive calls to get a checksum would be necessary every single time.

    0 讨论(0)
提交回复
热议问题