aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-03-28 11:08:52 -0400
committerJack Lloyd <[email protected]>2019-03-28 11:08:52 -0400
commita8316c17d3db4087bf4933502f205a92c9232c79 (patch)
tree63b4d7e1014354699f4f259a2aead8a240790064 /src
parenta7d273d8caf5bb9d0fef6acaa0263babee87faee (diff)
Add some more todos for Memory_Pool
Diffstat (limited to 'src')
-rw-r--r--src/lib/utils/mem_pool/mem_pool.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/utils/mem_pool/mem_pool.cpp b/src/lib/utils/mem_pool/mem_pool.cpp
index 98997a38a..9542ecbfa 100644
--- a/src/lib/utils/mem_pool/mem_pool.cpp
+++ b/src/lib/utils/mem_pool/mem_pool.cpp
@@ -62,8 +62,28 @@ namespace Botan {
* and that page being writable again, maximizing chances of crashing after a
* use-after-free.
*
+* Future work
+* -------------
+*
+* The allocator is protected by a global lock. It would be good to break this
+* up, since almost all of the work can actually be done in parallel especially
+* when allocating objects of different sizes (which can't possibly share a
+* bucket).
+*
* It may be worthwhile to optimize deallocation by storing the Buckets in order
* (by pointer value) which would allow binary search to find the owning bucket.
+*
+* A useful addition would be to randomize the allocations. Memory_Pool would be
+* changed to receive also a RandomNumberGenerator& object (presumably the system
+* RNG, or maybe a ChaCha_RNG seeded with system RNG). Then the bucket to use and
+* the offset within the bucket would be chosen randomly, instead of using first fit.
+*
+* Right now we don't make any provision for threading, so if two threads both
+* allocate 32 byte values one after the other, the two allocations will likely
+* share a cache line. Ensuring that distinct threads will (tend to) use distinct
+* buckets would reduce this.
+*
+* Supporting a realloc-style API may be useful.
*/
namespace {