facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.21k stars 3k forks source link

Fail to create a code byte #5439

Closed zoymoy closed 8 years ago

zoymoy commented 9 years ago

Hi,

First thanks for the library. It sounds great. Although, I have a problem during code compilation. When I execute the following: sudo -u winadmin hhvm --hphp --target hhbc --input-list /tmp/files.list --file-cache /tmp/hhvm.hhbc.sq3 -k1 -l4

I get this: ... parsing /... parsing /... hphp failed running hphp took 0'28" (28745952 us) wall time

Now, when I execute the following script I noticed that I have many errors say "Unable to stat file /xxx/yyy" for i in cat /tmp/files.list; do rm -rf /tmp/hhvm.hhbc.sq3; echo $i;
sudo -u winadmin hhvm --hphp --target hhbc --file-cache /tmp/hhvm.hhbc.sq3 -k1 -l2 $i; rm -rf /tmp/hhvm.hhbc.sq3; done

Is that may be the reason for the failure I get?

Thanks, Yoav.

jwatzman commented 9 years ago

Can you paste the exact command and the exact output from HHVM? You've elided large bits of potentially important information. A small repro on a small repo would also be useful.

When HHVM says Unable to stat file ..., does that file actually exist?

jwatzman commented 9 years ago

Also, you might want to try the hhvm-repo-auth command, which is available in the nightly packages (and will be in the upcoming 3.8 release, in a month or so). https://github.com/facebook/hhvm/wiki/Performance-Tuning#use-repoauthoritative---20 has the commands for doing it manually -- in particular, you're specifying --file-cache, which is a separate feature from the hhbc bytecode repo; I'd get the bytecode repo working first. File cache can have its own interesting issues, and has been known to break some PHP code (though I think we've fixed most/all of that now).

zoymoy commented 9 years ago

Thanks for your response. It did help and I managed to execute my script. Now, looking at the performance of the execution, I feel that I don't understand the result.

This is the flow: I run a script using the following command (I use JIT=true): sudo -u winadmin hhvm -c /etc/php.ini -vRepo.Authoritative=false /srv/MyHeritage/scripts/SMPF/testPostFiltering.php -m 273517341-1-1000002-4855451-1-1000004

This does the job and below are the execution time it took (I ran it 5 times):

1 29.915576 sec

2 6.920603 sec

3 4.462061 sec

4 4.349344 sec

5 4.547136 sec

When I used pure php (not hhvm) it took 0.091281 sec

And my questions:

  1. Now, I understand the result for execution #1 but how come the 2nd+ runs take more than the php run? (I will be happy to know how the logic actually works).

Many thanks in advanced, Appreciate, Yoav.

paulbiss commented 9 years ago

If you're running the script using the JIT you likely won't see any performance improvement from running the script once (or several times in succession). The JIT is really only useful in server mode (where the expensive compilation is reused in many subsequent requests) or in very expensive scripts (which doesn't appear to be the case here).

One way to measure performance would be to run it using --count=$number argument to hhvm to run it to run the script $number times, reusing the compiled code machine code in subsequent runs.

It also looks like your options are wrong for using a precompiled repo, you'd want

hhvm --count=$ntimes -c /etc/php.ini -vRepo.Authoritative=true -vRepo.Central.Path=/path/to/hhvm.hhbc /srv/MyHeritage/scripts/SMPF/testPostFiltering.php -m 273517341-1-1000002-4855451-1-1000004
zoymoy commented 9 years ago

Thanks. This helped. When I use the --count=$ntimes parameter, and in the middle of the process one of the script files is updated (during the execution), what will happen? Will the process load the new updated file? If not, can I make it happen?

Thanks.

paulbiss commented 9 years ago

In repo-authoritative mode you cannot edit source files once bytecode compilation has been performed, for non-repo auth the change will probably be picked up (though I haven't tested this). Changing the files between runs is going to require the PHP be recompiled, so it's going to effect performance fairly negatively. I wouldn't recommend benchmarking a script that does that.