Skip to content

Commit

Permalink
FIX: issue idle GC only once post execution
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Feb 4, 2025
1 parent cbeafce commit edaa9e8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
- 0.17.0.pre12 - 23-07-2025
- 0.17.0.pre13 - 04-02-2025
- Only issue idle GC once post dispatch - reduces CPU usage for auto cleanup - Sam Saffron

- 0.17.0.pre12 - 23-01-2025
- Corrected off-by-one error with object serialization - Ben Noordhuis

- 0.17.0.pre11 - 21-01-2025
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby

require "bundler/setup"
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "mini_racer"

# You can add fixtures and/or initialization code here to make experimenting
Expand Down
6 changes: 5 additions & 1 deletion ext/mini_racer_extension/mini_racer_extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ static void dispatch(Context *c)
void v8_thread_main(Context *c, struct State *pst)
{
struct timespec deadline;
bool issued_idle_gc = true;

c->pst = pst;
barrier_wait(&c->late_init);
Expand All @@ -737,15 +738,18 @@ void v8_thread_main(Context *c, struct State *pst)
if (c->idle_gc > 0) {
deadline = deadline_ms(c->idle_gc);
pthread_cond_timedwait(&c->cv, &c->mtx, &deadline);
if (deadline_exceeded(deadline))
if (deadline_exceeded(deadline) && !issued_idle_gc) {
v8_low_memory_notification(c->pst);
issued_idle_gc = true;
}
} else {
pthread_cond_wait(&c->cv, &c->mtx);
}
}
if (!c->req.len)
continue; // spurious wakeup or quit signal from other thread
dispatch(c);
issued_idle_gc = false;
pthread_cond_signal(&c->cv);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/mini_racer/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module MiniRacer
VERSION = "0.17.0.pre12"
VERSION = "0.17.0.pre13"
LIBV8_NODE_VERSION = "~> 22.7.0.4"
end

0 comments on commit edaa9e8

Please sign in to comment.