Commit 4644765
committed
persistent_state: Bound the memory used during index creation
During index creation, we parallelize the work in case we need to
create multiple indexes. We do this in a way where we create a mpsc
channel to pass the deserialized row data to the index creation
threads.
For btree indexes, we define our own comparator function, aka
make_compare_keys!. This function needs to perform extra work such
deserialization of keys, comparison of keys, ...
In comparison to hashmap indexes, btree indexes are slower to create
by the inner threads.
In such situation, where the inner threads are falling behind, we
end up storing an excessive amount of data in the channel, sometimes
even loading almost all table into memory.
This commit changes the channel to a sync channel, where we limit the
amount of data (rows) that can be in the buffer.
Fixes: REA-5767
Closes: #1528
Release-Note-Core: Fixed an issue where a CREATE CACHE using a range
condition (Btree index) could consume excessive memory.
Change-Id: I7c70d4b4a398ee6c4c5891bdce23806e5c5e6db6
Reviewed-on: https://gerrit.readyset.name/c/readyset/+/9674
Reviewed-by: Sidney Cammeresi <sac@readyset.io>
Tested-by: Buildkite CI1 parent 6af3fdc commit 4644765
1 file changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
1836 | 1836 | | |
1837 | 1837 | | |
1838 | 1838 | | |
1839 | | - | |
| 1839 | + | |
1840 | 1840 | | |
1841 | 1841 | | |
1842 | 1842 | | |
1843 | | - | |
| 1843 | + | |
1844 | 1844 | | |
1845 | 1845 | | |
1846 | 1846 | | |
| |||
1916 | 1916 | | |
1917 | 1917 | | |
1918 | 1918 | | |
| 1919 | + | |
1919 | 1920 | | |
1920 | 1921 | | |
1921 | 1922 | | |
| |||
0 commit comments