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

Evaluate Profile-Guided Optimization (PGO) #2392

Open
zamazan4ik opened this issue Jul 13, 2023 · 3 comments
Open

Evaluate Profile-Guided Optimization (PGO) #2392

zamazan4ik opened this issue Jul 13, 2023 · 3 comments

Comments

@zamazan4ik
Copy link

Hi!

Recently I checked Profile-Guided Optimization (PGO) improvements on multiple projects. The results are here.

Since PGO showed measurable improvements in compiler/interpreter-like workloads (V8, CPython, Clang, Clangd, GCC, Rustc, etc.) I think it could be useful to check PGO for the Espruino project too.

We need to perform PGO benchmarks on Espruino. And if it shows improvements - add a note about possible improvements in Espruino performance with PGO. Providing an easier way (e.g. a build option) to build scripts with PGO can be useful for the end-users too.

@gfwilliams
Copy link
Member

Yes, that sounds like a good thing to try.

There are benchmarks in the benchmark folder that you could try (I've tended to just use mandelbrot.js for quick tests). On-device I do:

function m() {
  for (y=0;y<32;y++) {
    line="";
    for (x=0;x<32;x++) {
      var Xr=0;
      var Xi=0;
      var Cr=(4.0*x/32)-2.0;
      var Ci=(4.0*y/32)-2.0;
      var i=0;
      while ((i<8) && ((Xr*Xr+Xi*Xi)<4)) {
        var t=Xr*Xr - Xi*Xi + Cr;
        Xi=2*Xr*Xi+Ci;
        Xr=t;
        i++;
      }
      if (i&1)
	      line += "*";
      else
        line += " ";
     }
   //  print(line);
  }
}

t=getTime();m();print(getTime()-t);

I imagine since we can't easily profile on embedded it might be worth running a 32 bit compile on Raspberry Pi, which should be a marginally closer platform to the Cortex M4.

Perhaps you could create a branch with PGO added using that to show how the process works? If it's providing marked improvements then we could look at coming up with some more representative JS code for profiling.

@gfwilliams
Copy link
Member

Any progress on this, or shall I close it?

@zamazan4ik
Copy link
Author

Any progress on this, or shall I close it?

No progress yet on this from my side. But I do not think that we need to close it. It could stay open, and possibly other future contributors will be interested in starting work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants