-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Painless currently utilizes an improvised statement counter in an attempt to prevent infinite loops. In some use cases this isn't really enough as each iteration of the loop can take an excessive amount of time. We should explore the possibility of adding additional safety features.
Some ideas that have been proposed already are the following:
- add a sampling of nanoseconds where every n iterations of a loop, time is taken into account to possibly terminate a script early if it's taking too long
- track memory usage of certain types of objects including Strings, and have a cap for allowed memory usage
- possibly create some custom data structures to better track usage of memory and number of API calls
Given that one of Painless's primary design goals is performance, I would like to propose a final feature if we do decide we would like more safety features -- two modes, safety and performance. As each of the above described features would likely add a non-insignificant amount of overhead, we could have a mode where they are disabled if the user requires the best performance available. Or we could even have a selection of enabled/disabled safety features, but this may be overly complex.
I would be interested in hearing about everyone's ideas, thoughts, and concerns related to this issue. @simonw @nik9000 @rjernst