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

Optimization wollok game #328

Merged
merged 20 commits into from
Feb 4, 2025
Merged

Optimization wollok game #328

merged 20 commits into from
Feb 4, 2025

Conversation

PalumboN
Copy link
Contributor

@PalumboN PalumboN commented Jan 6, 2025

[Run benchmarks]
^- esto hace que corran los benchmarks en el CI y ponga los resultados como comment del commit

Acá se mejora la performance de las natives críticas de Wollok Game en base a lo que había investigado @mind-ar en un PR/issue que no encontré.

La optimización que se implementa es evitar invocar los getters creados por properties en las natives de game (que, además, por querer optimizar de más tenía un bug).

Lo importante es que armé unos mini-benchmarks de game para medir esto.

De paso también abrí al puerta para poder compilar implementaciones nativas de cualquier método. Por ahora solo se hace para las properties (no solo de game, sino de todo el programa).

Quiero implementar más benchmarks del lenguaje antes de meterme con un compilador...

TODOs


Benchmarks en uqbar-project/wollok-language#236

@PalumboN PalumboN marked this pull request as draft January 6, 2025 00:24
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 85.18519% with 8 lines in your changes missing coverage. Please review.

Project coverage is 89.80%. Comparing base (3a15eb2) to head (66f7025).
Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
src/wre/game.ts 76.47% 2 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #328      +/-   ##
==========================================
- Coverage   89.85%   89.80%   -0.05%     
==========================================
  Files          28       29       +1     
  Lines        3212     3226      +14     
  Branches      584      586       +2     
==========================================
+ Hits         2886     2897      +11     
- Misses        171      173       +2     
- Partials      155      156       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 32 to 47
const deltaError = Math.max(0.1, expectedTime * 0.1) // 0.1 or 10 %
restore()

// console.info(`${message} - ${fqn} - ${time} ms (${iterations} iterations)`)
results.push({ message, fqn, time, iterations })
time.should.be.closeTo(expectedTime, deltaError)
})
}

benchmark('empty', 0.55)
benchmark('visuals_1', 0.4)
benchmark('visuals_100', 0.3)
benchmark('ticks_1', 0.8)
benchmark('ticks_100', 44)
benchmark('onCollide_1', 0.8)
benchmark('onCollide_100', 44)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these assertions portable on different machines / browsers / JS implementations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just hope:

  • to have some number more or less regular in the CI
  • detect when the number changes a lot

@PalumboN PalumboN force-pushed the optimization-wollok-game branch from 1b55a35 to db4e5ed Compare January 8, 2025 04:55
package.json Outdated Show resolved Hide resolved
@PalumboN PalumboN marked this pull request as ready for review January 8, 2025 16:37
Copy link
Contributor

@fdodino fdodino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Te dejo una pregunta, mañana si querés lo vemos

test/benchmarks.ts Show resolved Hide resolved
Copy link
Contributor

@ivojawer ivojawer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increibleee, Wollok vuelaa ✈️✈️✈️✈️

@PalumboN PalumboN merged commit 578480c into master Feb 4, 2025
4 of 5 checks passed
@PalumboN PalumboN deleted the optimization-wollok-game branch February 4, 2025 23:01
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

Successfully merging this pull request may close these issues.

4 participants