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

10_000 lines with 「say ‘a’;」 take 16 seconds to run #5070

Closed
p6rt opened this issue Jan 20, 2016 · 8 comments
Closed

10_000 lines with 「say ‘a’;」 take 16 seconds to run #5070

p6rt opened this issue Jan 20, 2016 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 20, 2016

Migrated from rt.perl.org#127330 (status was 'rejected')

Searchable as RT127330$

@p6rt
Copy link
Author

p6rt commented Jan 20, 2016

From @AlexDaniel

Create a file with 10_000 lines​:

for x in {1..10000}; do echo 'say �a�;' >> print.p6; done

And then time it​:

time perl6 print.p6

It will take around 16 seconds to run.

You can also use ï½¢printï½£ instead of ï½¢sayï½£, it does not matter.

The time grows linearly. I haven't done any serious benchmarks but please
look at the attached graph, the data just speaks for itself.

Very important note (by Zoffix++)​:
�It's all in compilation too.
17 seconds before it told me I got a syntax error.
It takes 17s to run 10,000 prints on my box, but if I move them into a
module and a sub and precompile the module, then I get 1.2s run. This is
all compared to 0.2s run with Perl 5 on the same box�

Perhaps sub lookups are that slow?

Originally reported by zhmylove++.

@p6rt
Copy link
Author

p6rt commented Jan 20, 2016

From @AlexDaniel

perl6prints.png

@p6rt
Copy link
Author

p6rt commented Jan 24, 2016

From @niner

I don't think it's related to subs. It's compilation in general that's rather slow, most of all parsing.

nine@​sphinx​:~> for x in {1..10000}; do echo 'say â��aâ��;' >> print.p6; done
nine@​sphinx​:~> time perl6 --stagestats print.p6 > /dev/null
Stage start : 0.000
Stage parse : 5.442
Stage syntaxcheck​: 0.000
Stage ast : 0.000
Stage optimize : 0.503
Stage mast : 1.035
Stage mbc : 0.102
Stage moar : 0.000

real 0m7.232s
user 0m7.152s
sys 0m0.076s

nine@​sphinx​:~> for x in {1..10000}; do echo "my \$a$x = â��aâ��;" >> str.p6; done
nine@​sphinx​:~> time perl6 --stagestats str.p6 > /dev/null
Stage start : 0.000
Stage parse : 8.204
Stage syntaxcheck​: 0.000
Stage ast : 0.000
Stage optimize : 0.351
Stage mast : 0.885
Stage mbc : 0.014
Stage moar : 0.000

real 0m9.543s
user 0m9.480s
sys 0m0.060s

I'm closing this ticket, as compiling these examples will most probably be sped up by general improvements to the compiler and optimization infrastructure and not something that's specifically targeted at the examples. For a core developer it's kinda hard to forget about parsing being slow anyway :)

@p6rt
Copy link
Author

p6rt commented Jan 24, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 24, 2016

@niner - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Jan 24, 2016
@p6rt
Copy link
Author

p6rt commented Oct 11, 2017

From @AlexDaniel

FWIW it went from 4.1724 to 3.3393 (2015.12→HEAD(a72214c))  for 5k of says.
On 2016-01-24 06​:28​:38, nine@​detonation.org wrote​:

I don't think it's related to subs. It's compilation in general that's
rather slow, most of all parsing.

nine@​sphinx​:~> for x in {1..10000}; do echo 'say ‘a’;' >> print.p6;
done
nine@​sphinx​:~> time perl6 --stagestats print.p6 > /dev/null
Stage start : 0.000
Stage parse : 5.442
Stage syntaxcheck​: 0.000
Stage ast : 0.000
Stage optimize : 0.503
Stage mast : 1.035
Stage mbc : 0.102
Stage moar : 0.000

real 0m7.232s
user 0m7.152s
sys 0m0.076s

nine@​sphinx​:~> for x in {1..10000}; do echo "my \$a$x = ‘a’;" >>
str.p6; done
nine@​sphinx​:~> time perl6 --stagestats str.p6 > /dev/null
Stage start : 0.000
Stage parse : 8.204
Stage syntaxcheck​: 0.000
Stage ast : 0.000
Stage optimize : 0.351
Stage mast : 0.885
Stage mbc : 0.014
Stage moar : 0.000

real 0m9.543s
user 0m9.480s
sys 0m0.060s

I'm closing this ticket, as compiling these examples will most
probably be sped up by general improvements to the compiler and
optimization infrastructure and not something that's specifically
targeted at the examples. For a core developer it's kinda hard to
forget about parsing being slow anyway :)

@p6rt
Copy link
Author

p6rt commented Oct 11, 2017

From zoffix@zoffix.com

Quoting Parrot Raiser <1parrota@​gmail.com>​:

Round trips to the OS, like repeated "says", have been slow relative
to internal processes since the dawn of time.

In this case, there are no trips. It's the *parsing* time that's slow.
In fact, if you change it to `$ = �a�;` it's equally slow.

Looking at this now, with an extra year of knowledge, it makes perfect
sense for this to be unusually slower​: each line switches back and
forth from Main language braid, to Quote language braid, and then back
to Main.

For a core developer it's kinda hard to forget about parsing being
slow anyway :)

Indeed, we all pay a ~70s of wait time to parse core code after
*every* change.

I'm actually debugging a bug that requires me to learn how the braid
switcher works; I'll take a look if the switch can be improved�don't
hold your breath tho, I'm a n00b.

@p6rt
Copy link
Author

p6rt commented Oct 11, 2017

From @zoffixznet

On Wed, 11 Oct 2017 10​:29​:41 -0700, zoffix@​zoffix.com wrote​:

Looking at this now, with an extra year of knowledge, it makes perfect
sense for this to be unusually slower​: each line switches back and
forth from Main language braid, to Quote language braid, and then back
to Main.

I was wrong. The braid switch makes virtually no difference and slowness is present even with 10000 repeated `1;`

@p6rt p6rt added the slow label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant