4 ms·
> Also, where's the unit test? What would you think if the following were true for a fairly generalized problem: - It is easy to prove a particular upper boun
by thaumasiotes 6y ago
> Also, where's the unit test?
What would you think if the following were true for a fairly generalized problem:
- It is easy to prove a particular upper bound on memory requirements when calling a function.
- It is very difficult to know exactly what the memory requirements will be for particular input.
- No known input achieves the known upper bound.
Is it a problem if we allocate enough memory to satisfy the bound we can prove, and then don't have a unit test showing we can't do with less?
- pmiller2 6y agoIf that's all the case, then, where's the proof? It might be "easy to prove," but it's probably not an "I can prove this trivially, on the fly" type of task.
- cbsks 6y agoI'd be satisfied with that if I was a reviewer in the code review. I'd want that (and the proofs) explicitly mentioned in the comment, or at the very least in the commit message. At first glance the example seems contrived to me. Assuming that the code is deterministic, wouldn't it be trivial to measure the memory requirement for a particular input?
- thaumasiotes 6y agoThere are a lot of potential inputs.
- pantalaimon 6y agoso why is 5 enough? could there be an input where the number needs to be 15? or 1005?
- thaumasiotes 6y agoThis doesn't make any sense as a response to my comment. We said that you know that 5 is sufficient, but not that it's necessary. What were you trying to ask?
- cbsks 6y agoBut surely it would be possible to measure the memory requirements for one of those potential inputs...
- deleted 6y ago[deleted]
- bena 6y agoI think the real resolution would be change the function that estimates the amount of memory needed would return it with the additional 5 added already. That way you can trust the estimator to always tell you at most how much memory you'd need.
- a1369209993 6y ago> What would you think if the following were true for a fairly generalized problem: > - It is easy to prove a particular upper bound on memory requirements That they should have included said proof in the source code (in a comment if the type system isn't expressive enough to run it).