[clang] Introduce paged vector (PR #66430)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 26 03:10:34 PDT 2023
================
@@ -1625,6 +1625,39 @@ SmallVector has grown a few other minor advantages over std::vector, causing
and is no longer "private to the implementation". A name like
``SmallVectorHeader`` might be more appropriate.
+.. _dss_pagedvector:
+
+llvm/ADT/PagedVector.h
+^^^^^^^^^^^^^^^^^^^^^^
+
+``PagedVector<Type, PageSize>`` is a random access container that allocates
+(PageSize) elements of type Type when the first element of a page is accessed
+via the ``operator[]``. This is useful for the case in which the number of
+elements is known in advance and their actual initialization is expensive and
+sparse so that it's only done lazily when the element is accessed. When the
+number of used pages is small significant memory savings can be achieved.
----------------
vgvassilev wrote:
```suggestion
via the ``operator[]``. This is useful for cases where the number of
elements is known in advance; their actual initialization is expensive; and they are
sparsely used. This utility uses page-granular lazily initialization when the element is accessed. When the
number of used pages is small significant memory savings can be achieved.
```
Something along these lines. I am not sure if I understand the last sentence. Do you mean that if the page size is small? Or you mean if the usage is sparse then we can achieve savings. If the latter, I guess we say that in the previous sentence.
https://github.com/llvm/llvm-project/pull/66430
More information about the cfe-commits
mailing list