moosetechnology / Fame

Fame is a meta-modeling framework for executable models.
MIT License
4 stars 10 forks source link

Cache number parser to not create too many instances #75

Closed jecisc closed 5 months ago

jecisc commented 5 months ago

This change caches the number parser. During the import of a model the number parser represented 5% en the objects created. With this change we only create 1.

guillep commented 5 months ago

Did you see some performance improvement?

jecisc commented 5 months ago

With Seba's profiler I see that we reduce by almost 10% the allocated size in memory during an import of a medium size model.

There is a little gain of speed but it's not huge because this represent just a small part of the import but also because we tweak the GC parameters to have a big young space (64MB instead of 2.8MB).

I guess that without this change of parameter we would have a bigger difference.

I was thinking to propose to reuse the same Parser in Number/Integer>>#readFrom:* methods but that would cause problems in case of concurrency since the class NumberParser has states.