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
len([msg for msg in query.all() if msg.msg['new'] is 1])
consume lots of memory, but also lots of CPU.
The replacement use less memory, but we still have to decode thousand of json string to verify if enough of them have the right value.
I think it would be better to provide a new operation like count that take a lambda (for example "msg.msg['new'] is 1"), a limit (let's say "10"), and try to decode message until we found 10 of them.
This would save a lot of CPU IMHO (not as much as doing the verification server side), and make it easier to people to write good rules without doing cut and paste from the original rules, especially cut and paste of less efficient examples.
Alternatively, if writing a operation is not good, adding a function that could be reused by the lambda would be easier. I prefer the higher level construct of adding a operation, since this can be later verified, but complexity wise, a operation that can be used is fine too.
The text was updated successfully, but these errors were encountered:
While fixing latest crash (see https://pagure.io/fedora-badges/pull-request/728), I found that we are using lots of ressources counting messages due to the snippet we use in rules.
For example:
consume lots of memory, but also lots of CPU.
The replacement use less memory, but we still have to decode thousand of json string to verify if enough of them have the right value.
I think it would be better to provide a new operation like count that take a lambda (for example "msg.msg['new'] is 1"), a limit (let's say "10"), and try to decode message until we found 10 of them.
This would save a lot of CPU IMHO (not as much as doing the verification server side), and make it easier to people to write good rules without doing cut and paste from the original rules, especially cut and paste of less efficient examples.
For interns wanting to implement that, the code would be around https://github.com/fedora-infra/fedbadges/blob/develop/fedbadges/rules.py#L487
Alternatively, if writing a operation is not good, adding a function that could be reused by the lambda would be easier. I prefer the higher level construct of adding a operation, since this can be later verified, but complexity wise, a operation that can be used is fine too.
The text was updated successfully, but these errors were encountered: