Details
- Reviewers
Chia-hungDuan - Commits
- rGb3ca0f34cfc6: [scudo] Use MemMap in Vector
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/scudo/standalone/tests/vector_test.cpp | ||
---|---|---|
26–29 ↗ | (On Diff #555868) | This is way too big. It'll simply increase the running time of the tests without verifying many stuff. Given the use of vector is restricted and the static buffer is hard coded and which is small. I think the original size is good enough. |
compiler-rt/lib/scudo/standalone/vector.h | ||
27 | Can you move the destroy() to protected and only reset this to nullptr when it's using external buffer? Besides, we may want to call clear() before the buffer destruction | |
93 | I think it's fine to omit the comment here and below in this function. The code is self-explained pretty clear. | |
110–111 | I would merge the comment with the comment of VectorNoCtor and it will look like // A low-level vector based on map. To reduce memory overhead for small vectors, it'll // use a local buffer when available. Otherwise, a external memory buffer will be used. // The current implementation supports only POD types. |
compiler-rt/lib/scudo/standalone/tests/vector_test.cpp | ||
---|---|---|
26–29 ↗ | (On Diff #555868) | Thanks, the original size (1000 elements) ended up testing 4000 bytes (1 page*) or 8000 bytes (2 pages*), depending of whether the architecture is a 32 or 64 bit one. * = assuming that a page is 4096 bytes, which is not universally true I've modified the code so that it always tests with 2 pages on all platforms to address your performance concerns. This ensures that we always test both kinds of transitions:
|
compiler-rt/lib/scudo/standalone/vector.h | ||
27 |
|
compiler-rt/lib/scudo/standalone/tests/vector_test.cpp | ||
---|---|---|
26–29 ↗ | (On Diff #555868) | I'm not concerning the performance of this test. I'm thinking of the necessity of doing this and what's the frequency/cost of having bugs in this vector. This is not a general used vector and have very limited use cases. The scenarios you are trying to test depend on the buffer extension policy. What if we always prepare dynamic buffer with starting size 128K? Then we won't be able to cover the scenarios as mentioned. Again, this is not a general used vector (nor having complex functions). In addition, other tests that use this vector also verify the functions indirectly. I'm not sure what's the benefit of testing these scenarios at this moment |
compiler-rt/lib/scudo/standalone/vector.h | ||
27 | You're right, we can't use clear() directly here. Please ignore that suggestion. I'm not sure why we have to *poison* the Data. Like you said, use-after-destroy is not a case we have to worry here. As mentioned, this is designed to be generally used. The purpose of destroy() is ambiguous now. I would suggest that only use Vector and disallow the direct use of VectorNoCtor. I'm planning some changes on this but it has lower priority now anyway. |
compiler-rt/lib/scudo/standalone/tests/vector_test.cpp | ||
---|---|---|
26–29 ↗ | (On Diff #555868) | Done, I've removed all the changes to the test from this CL |
compiler-rt/lib/scudo/standalone/vector.h | ||
27 | Done, I've made init() and destroy() protected and explained that direct usage of VectorNoCtor is disallowed in the comment at the top |
Can you move the destroy() to protected and only reset this to nullptr when it's using external buffer? Besides, we may want to call clear() before the buffer destruction