-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
Runtime of program taking forever .... #3140
Comments
Additional information: Moving the directory that the FALLBACK() method would use to a different name (one that won't resolve any dynamically loaded modules) results in an error. Why?
new() is already resolved as per normal. There's no reason for FALLBACK() to even be involved .... that is until I call a method that isn't handled by the class. Does FALLBACK() do something (like preload possible methods) or something? https://docs.perl6.org/language/typesystem#index-entry-FALLBACK_%28method%29 |
Have you considered installing the module? I'm pretty sure the problem is that you're using |
Is this actually true? test.pl6:
; truss -s 1024 -o data ./test.pl6 2>/dev/null && fgrep mylib data I see no indication that perl6 is doing this at all. In other words, the mere existence of In fact, the mylib directory hasn't even existed during my testing. The only time a directory traversal is performed is when I include a module either statically or dynamically via: use Module; $class here is irrelevant, but it's doing what it should be doing:
You'll notice that it searches for META6.json first followed by the exact module name, but never does a traversal of any kind. Another thing to note before continuing on with my response, it appears multiple stat(2) calls are happening for each file it's looking for within the directory tree:
|
On Freitag, 27. September 2019 21:52:05 CEST pprocacci wrote:
I guess it boils down to me not understanding why perl6 needs to do the
traversal in the first place. I know you said it's because perl6 needs to
SHA1 all files ... but why? In my opinion, perl6 should only be interested
in the files that are required to run a given program, of which are defined
by the programmers. Perl6 should know exactly where to find these files
without the traversal. Proactively searching through and SHA1 via a
traversal seems extremely wasteful.
Why can't perl6 simply check some internal cache for a file with a matching
SHA1 and use it, otherwise translate the Service::Blah::Test accordingly to
<lib>/Service/Blah/Test.pm6.
Because we wouldn't know if one of Test.pm6' dependencies has changed.
What if <lib>/Service/Blah/Test.pm6 uses <lib>/Service/Blah/A.pm6 and you
change A.pm6 and your test loads Test.pm6. To know if the precompiled Test.pm6
from an earlier run can still be used, we need to know the exact state of the
whole repository.
We calculate this state at the time the first module is loaded from the
repository which is why your first test didn't show anything.
|
I think I'm starting to understanding and this is due to the compiled nature of perl6. perl5 doesn't have this problem because it will always re-read, re-parse and re-eval all and only the source files it needs to deliver a response. If a source file changes, the output will change accordingly and it will do so only looking at the minimum number of source files it has too. Is there any way to run a perl6 program bypassing this "compiled nature" because in my use case, this actually does more harm than good. |
You can disregard my last comment. I'll just stick with perl5. Thanks for the input guys! |
@pprocacci Sorry to hear this. Would appreciate if you could tell us (as a comment to this issue) what drove you to that decision. I'm not saying that we could fix that in any amount of time, but it would at least let us know what could be a decision point for using / not using Perl 6. Thank you in advance! |
In short, it's not production ready. I LIKE perl6. I don't like continuously running into things which I expect to just work. All 5 of the below problems I've encountered while trying to write a single library. Each time I run into a problem, I put it down for several months only to come back later with what I perceive as a workaround, and bam .... another problem. SocketsEVALRACEThough I haven't created a ticket regarding this, using Excessive syscallsAgain not reported (minor), but detailed within this ticket: RE interpolation in character classes (doc problem)And then there's this ticket, which I now understand to be a major difference between perl5 and 6. In perl5, the number of files in a directory imposes no runtime penalty if designed correctly. In perl6 I feel at this time the only workaround is to essentially Don't misunderstand me, I'll continue using perl6 for my less complex needs, but this current project I can't seem to make any headway on due to the continuous issues that crop up. I'm always running into something. ;) |
On Montag, 30. September 2019 15:43:09 CEST pprocacci wrote:
And then there's this ticket, which I now understand to be a major
difference between perl5 and 6. In perl5, the number of files in a
directory imposes no runtime penalty if designed correctly. In perl6 I
feel at this time the only workaround is to essentially `cat *.pl6 >
huge_file.pm6` to avoid large directory traversals.
Just to clarify: this penalty applies only to filesystem repositories, i.e.
what you specify via `perl6 -I` or `PERL6LIB` or `use lib`. Once the modules
are installed properly, we do not crawl any directories or calculate hashes
but are actually much faster than Perl 5 when loading large numbers of
modules.
I am however still a little surprised: even if my module is located in the
rakudo source tree with its 326 files and 112807 lines of code (representing a
really large project), the penalty for loading modules with `perl6 -Isrc` is
just about 300 milliseconds. That's once per program run, not per module! I
wonder how you end up with 10s of seconds spent.
Btw. I'm really curious what code base this is with over 1000 files?
|
I am attempting to write a perl6 sdk for Amazon Web Services much like https://metacpan.org/pod/Paws Attached is the code I've created thus far. It's very much a work in progress and it's very fluid and has been changing quite a bit. Also note, I had no intention of sharing this until it was what I would consider to be nearing completion ... which it currently is not. Due note however, that I've changed the 1000's of files as initially claimed and have instead essentially packed that data into single service files.
Following the above, the ./builder-bin/generate perl6 script Running the above currently creates
..... resulting in 1000's of files separating each shape into their own files under their own service directory.
As for the service files themselves, once ./builder-bin/generate has been ran, you can look at any of the resulting service files (Ex: auto-lib/Paws/Service/Pinpoint.pm6) to understand how this one file when split out according to |
The Problem
42 seconds of runtime to dynamically load a module which only calls new().
Expected Behavior
I expect the loading and execution of new() to be only seconds at most.
Actual Behavior
/usr/bin/time -h ./doit.pl6
40.79s real 36.02s user 4.78s sys
Steps to Reproduce
The above is the incomplete directory structure I am working with. For a better idea of the number of files/directories in each path:
There are a lot of modules that I'm trying to avoid 'use'ing and instead only load the needed modules at runtime. I'm leaning on the FALLBACK method in auto-lib/Test/Service/Something.pm6 (below) to avoid having to do so. It's my understanding that the FALLBACK() method in my example (below) shouldn't matter because all I'm doing is using the method new().
In short:
doit.pl6 loads lib/Test.pm6 at compile time.
lib/Test.pm6 loads auto-lib/Service/Something at runtime.
auto-lib/Service/Something loads lib/Test.pm6 at compile time.
auto-lib/Service/Something should load an unknown method name at runtime using FALLBACK()
I only Instantiate Test and Something with methods new() and nothing else.
It's obvious to me that perl6 is doing something I don't expect it to do, but there's no indication as to what that may be. A full tarball of my project can be provided if necessary.
doit.pl6
lib/Test.pm6
auto-lib/Test/Service.pm6 - * Note <RAM ...> is incomplete and just here to show example.
auto-lib/Test/Service/Something.pm6
auto-lib/Test/Service/Something/Else.pm6
Environment
perl6 -v
):This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03
implementing Perl 6.d.
The text was updated successfully, but these errors were encountered: