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

Fibonacci example generates unexpectedly large output #173

Open
rajsite opened this issue Aug 8, 2024 · 5 comments
Open

Fibonacci example generates unexpectedly large output #173

rajsite opened this issue Aug 8, 2024 · 5 comments

Comments

@rajsite
Copy link

rajsite commented Aug 8, 2024

The current fibonacci example on https://porffor.dev/ with content:

let a = 0, b = 1;
Porffor.numberLog(a); Porffor.numberLog(b);

for (let i = 2; i <= 45; i++) {
  let t = b + a;
  a = b;
  b = t;

  Porffor.numberLog(t);
}

Compiles out to 323265 bytes.

If I break out some asm.js ideas buried in the back of my head and tweak it like:

let a = 0, b = 1;
Porffor.numberLog(a); Porffor.numberLog(b);

for (let i = 2; i <= 45; i++) {
  let t = b|0 + a; // could alternatively do `+b + a`
  a = b;
  b = t;

  Porffor.numberLog(t);
}

Compiles out to 341 bytes.

Seems like compiled output size would be interesting to track as 262 compliance goes up.

@CanadaHonk
Copy link
Owner

CanadaHonk commented Aug 8, 2024

Yep this is a bug of it including much more built-ins than needed and not doing the best type tracking, should be fixed in next few weeks.

@rajsite
Copy link
Author

rajsite commented Aug 8, 2024

Couple related observations:

  • Looks like Array Reading is also generating quite a bit of output 323578 bytes
  • I'm guessing the syntax highlighting or something is slowing down the page for the larger generations / making my chrome tab crash. Might be helpful to show it plaintext / limit the output size if it's too large.

@Rob23oba
Copy link
Contributor

Rob23oba commented Aug 8, 2024

Well, there's not much optimization currently since that's not really the focus right now. In the future such code should compile again to reasonable sizes.

@CanadaHonk
Copy link
Owner

Still not amazing but the same code now compiles to 74307 bytes instead of the huge size of before.

@rajsite
Copy link
Author

rajsite commented Aug 17, 2024

Maybe a custom font with built-in syntax highlighting will help with rendering large output a bit. 🤯
Need more porffor wasm in my fonts. 🔥

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

No branches or pull requests

3 participants