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

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Optimization wollok game #328

wants to merge 16 commits into from

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.76%. Comparing base (59c43f7) to head (dbe14b0).

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.69%   89.76%   +0.06%     
==========================================
  Files          28       28              
  Lines        3183     3204      +21     
  Branches      579      582       +3     
==========================================
+ Hits         2855     2876      +21     
  Misses        172      172              
  Partials      156      156              

☔ 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
"wollokVersion": ":master",
"wollokVersion": ":optimization-wollok-game",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

⚠️

@PalumboN PalumboN marked this pull request as ready for review January 8, 2025 16:37
benchmark('ticks_1', 12)
benchmark('ticks_100', 637)
benchmark('onCollide_1', 11)
benchmark('onCollide_10_same_position', 5000)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Este caso se debería poder optimizar reutilizando la lista de colliders:

  • Sabiendo que si un collider choca con otro, el otro también choca con él
  • Ahora se está iterando todos los visuales por cada uno, pero en este ejemplo termina armando siempre la misma lista de colliders

Ahora es medio paja hacerlo porque cada colisión es independiente del resto, habría que cambiar el modelo actual para centralizar el manejo de los colliders. Prefiero hacerlo en la próxima iteración.

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

stub(console)
const iterations = 30

const program = `games.${fqn}`
Copy link
Contributor

Choose a reason for hiding this comment

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

una pavada, pero no falta subir los programas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Están en Language

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 ✈️✈️✈️✈️

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