8000 feat: make gc less freq · RustPython/RustPython@3a79613 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a79613

Browse files
committed
feat: make gc less freq
1 parent 9e7ca37 commit 3a79613

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

vm/src/frame.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,13 @@ impl ExecutingFrame<'_> {
350350
flame_guard!(format!("Frame::run({})", self.code.obj_name));
351351
// Execute until return or exception:
352352
let instrs = &self.code.instructions;
353+
let mut gc_cnt = 0;
353354
loop {
354-
crate::object::try_gc();
355+
gc_cnt += 1;
356+
if gc_cnt > 1000 {
357+
crate::object::try_gc();
358+
gc_cnt = 0;
359+
}
355360
let idx = self.lasti() as usize;
356361
self.update_lasti(|i| *i += 1);
357362
let instr = &instrs[idx];

vm/src/object/gc/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl Collector {
454454
return false;
455455
}
456456
let mut last_gc_time = self.last_gc_time.lock();
457-
if last_gc_time.elapsed().as_millis() >= 100 {
457+
if last_gc_time.elapsed().as_secs() >= 1 {
458458
*last_gc_time = Instant::now();
459459
true
460460
} else {

0 commit comments

Comments
 (0)
0