quil / quil

Main repo. Quil source code.
Eclipse Public License 1.0
2.96k stars 164 forks source link

Unnecessary reflection noticeably degrades performance #354

Open p-himik opened 3 years ago

p-himik commented 3 years ago

Take a look at this sampling snapshot, where the app was working for around 15-20 seconds: image Granted, there were a lot of calls to q/stroke, but it still spends most of its time in the reflection call. The relevant lines of the results of lein check:

Compiling quil.applet
Reflection warning, quil/applet.clj:35:19 - reference to field getSurface can't be resolved.
Reflection warning, quil/applet.clj:35:19 - reference to field getNative can't be resolved.
Reflection warning, quil/applet.clj:36:14 - reference to field getClass can't be resolved.
Reflection warning, quil/applet.clj:43:28 - reference to field destroy can't be resolved.
Reflection warning, quil/applet.clj:43:7 - call to method schedule can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:46:7 - reference to field getFrame can't be resolved.
Reflection warning, quil/applet.clj:46:7 - reference to field dispose can't be resolved.
Reflection warning, quil/applet.clj:57:26 - reference to field getSurface can't be resolved.
Reflection warning, quil/applet.clj:57:26 - call to method setVisible can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:69:24 - reference to field getSurface can't be resolved.
Reflection warning, quil/applet.clj:70:24 - reference to field frame can't be resolved.
Reflection warning, quil/applet.clj:75:8 - call to method setTitle can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:76:8 - call to method setResizable can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:77:8 - call to method setAlwaysOnTop can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:190:3 - reference to field state can't be resolved.
Reflection warning, quil/applet.clj:199:7 - call to method fullScreen can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:200:7 - call to method size can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:221:3 - call to method frameRateParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method keyPressedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method keyReleasedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method keyTypedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method mousePressedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method mouseReleasedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method mouseMovedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method mouseDraggedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method mouseEnteredParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method mouseExitedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method mouseClickedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method focusGainedParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:253:1 - call to method focusLostParent can't be resolved (target class is unknown).
Reflection warning, quil/applet.clj:257:42 - reference to field state can't be resolved.
Reflection warning, quil/applet.clj:258:20 - reference to field getCount can't be resolved.
Reflection warning, quil/applet.clj:263:5 - call to method registerMethod can't be resolved (target class is unknown).

The most important line there is Reflection warning, quil/applet.clj:190:3 - reference to field state can't be resolved. - at least, for all the functions that use quil.core/internal-state.

nbeloglazov commented 2 years ago

Curiuosly - I didn't see same reflection errors as you did. I saw around 5 and all in core.cljc but none in applet.clj.