You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw that achievement generation is quite inefficient when it comes to database usage.
The culprit is getModel method that is called 3 times for each achievement progress modification:
in constructor
in getOrCreateProgressForAchiever to fetch achievement id
in getOrCreateProgressForAchiever to associate newly created progress with details model
Then in this getModel method we have 2 database calls: read and save
That makes 6 database calls (8 if there is an update) for each achievement update.
My suggestion would be to make a dedicated command for synchronizing achievement details with database and remove save call from getModel as well as getModel call from constructor (possibly as a config option for backword compatibility) .
An extra improvement would be to reuse results of getModel instead of calling it each time.
Another suggestion would be to add an option for having stable ids
(eg. calculated from md5 of achievement fully qualified class name or just provided by user)
and assume that those will match model's id,
but that is something to be discussed
and since its a super breaking change, definitely require a config option.
The text was updated successfully, but these errors were encountered:
Hi @hubertnnn ! Thanks a lot for the feedback. I 100% agree that the current base is not as efficient as it could be, and will be taking a look at this for the next release (scheduled for January).
If you would like to help, please submit a pull request!
I saw that achievement generation is quite inefficient when it comes to database usage.
The culprit is
getModel
method that is called 3 times for each achievement progress modification:getOrCreateProgressForAchiever
to fetch achievement idgetOrCreateProgressForAchiever
to associate newly created progress with details modelThen in this
getModel
method we have 2 database calls:read
andsave
That makes 6 database calls (8 if there is an update) for each achievement update.
My suggestion would be to make a dedicated command for synchronizing achievement details with database and remove
save
call fromgetModel
as well asgetModel
call from constructor (possibly as a config option for backword compatibility) .An extra improvement would be to reuse results of
getModel
instead of calling it each time.Another suggestion would be to add an option for having stable ids
(eg. calculated from md5 of achievement fully qualified class name or just provided by user)
and assume that those will match model's id,
but that is something to be discussed
and since its a super breaking change, definitely require a config option.
The text was updated successfully, but these errors were encountered: