Skip to content

Commit

Permalink
fix: add vacuum_delay_point (tensorchord#31)
Browse files Browse the repository at this point in the history
Signed-off-by: usamoi <usamoi@outlook.com>
  • Loading branch information
usamoi authored Oct 28, 2024
1 parent c9f305a commit 38679a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/algorithm/vacuum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::algorithm::tuples::*;
use crate::postgres::Relation;
use base::search::Pointer;

pub fn vacuum(relation: Relation, callback: impl Fn(Pointer) -> bool) {
pub fn vacuum(relation: Relation, delay: impl Fn(), callback: impl Fn(Pointer) -> bool) {
// step 1: vacuum height_0_tuple
{
let h1_firsts = {
Expand Down Expand Up @@ -42,6 +42,7 @@ pub fn vacuum(relation: Relation, callback: impl Fn(Pointer) -> bool) {
for first in h0_firsts {
let mut current = first;
while current != u32::MAX {
delay();
let mut h0_guard = relation.write(current);
for i in 1..=h0_guard.get().len() {
let h0_tuple = h0_guard
Expand Down Expand Up @@ -97,6 +98,7 @@ pub fn vacuum(relation: Relation, callback: impl Fn(Pointer) -> bool) {
meta_tuple.vectors_first
};
while current != u32::MAX {
delay();
let read = relation.read(current);
let flag = 'flag: {
for i in 1..=read.get().len() {
Expand Down
8 changes: 7 additions & 1 deletion src/index/am.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,13 @@ pub unsafe extern "C" fn ambulkdelete(
}
let callback = callback.unwrap();
let callback = |p: Pointer| unsafe { callback(&mut pointer_to_ctid(p), callback_state) };
algorithm::vacuum::vacuum(unsafe { Relation::new((*info).index) }, callback);
algorithm::vacuum::vacuum(
unsafe { Relation::new((*info).index) },
|| unsafe {
pgrx::pg_sys::vacuum_delay_point();
},
callback,
);
stats
}

Expand Down

0 comments on commit 38679a1

Please sign in to comment.