Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atom generator exhausts the atom limit #290

Open
Maria-12648430 opened this issue May 24, 2022 · 4 comments
Open

Atom generator exhausts the atom limit #290

Maria-12648430 opened this issue May 24, 2022 · 4 comments

Comments

@Maria-12648430
Copy link

The atom() generator produces atoms at random, with no limitations whatsoever. By extension, this is also true for union generators like term(). As atoms are never garbage collected, this means that over time the limit on the number of atoms in a runtime instance will get exhausted. How quickly that happens depends on how generators are used, how many properties there are in a suite, and how many suites there are.

We are working on property tests for OTP, currently for the lists module. We have 71 properties so far and are not done yet, but we already encounter failures because the atom space in exhausted. Yes, we can tune our generators to generate atoms more economically (cumbersome and makes tests more artificial), but still, this puts a tight lid on things in general. Going to extremes, it would never be possible to equip all of OTP with property tests, not even all of stdlib.

@kostis
Copy link
Collaborator

kostis commented May 24, 2022

Atom garbage collection is something known to be missing from Erlang/OTP's implementation for many years now, and a limitation which has forced most Erlang developers to write ugly and/or unnatural code in many of their programs. Moreover, the implementation of an atom garbage collector is not rocket science. So, perhaps it's high time that it is implemented.

If property-based testing is something that is of use to Erlang/OTP and your particular way of using the atom()/term() generator causes trouble for OTP, perhaps this may give some extra incentive to the OTP folks to bite the bullet and finally implement atom garbage collection.

In my opinion, artificially limiting the atom() and term() generators to e.g. just the existing atoms is not the PropEr solution to the issue(s) you are facing. But I am willing to be convinced otherwise.

@Maria-12648430
Copy link
Author

Well, I have no real idea how that works internally, I have my guesses and some cloudy memory. But I think it's not just a simple matter of not wanting to bother of cleaning up after yourself 😜 And I don't think my particular way of using atom() and term() will induce the OTP team to go down that road, despite them being in favor of property tests 😉

That said, personally I didn't feel any need for more or infinite atoms, and I would second-guess any production code that needs it.

On the other hand, I understand that limiting the generators is contrary to what property testing is really about: generating all sorts of possible input. But I don't see how the two will be brought together 🤷‍♀️

@Maria-12648430
Copy link
Author

@Maria-12648430
Copy link
Author

On a side note, an interesting point that came up in the discussion was that atoms generated purely at random alone are not all that useful. There are certain "interesting" atoms (well-known ones like ok, error, undefined etc, module and function names, etc) that are likely to trigger something but are rarely generated with just a random generator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants