Permalink
Browse files

Make stack pool and size configurable

  • Loading branch information...
1 parent 75dce8b commit 794333e7bef83a297c7ee70e80373bc2a6fab6e8 @evanphx evanphx committed Jan 10, 2012
Showing with 29 additions and 10 deletions.
  1. +8 −0 lib/rubinius/configuration.rb
  2. +2 −2 vm/fiber_data.cpp
  3. +10 −2 vm/fiber_stack.cpp
  4. +8 −6 vm/fiber_stack.hpp
  5. +1 −0 vm/vm.cpp
@@ -109,6 +109,14 @@
"The password required to connect to the agent"
end
+ c.section "fiber" do |s|
+ s.vm_variable "stacks", 10,
+ "The number of stacks in each Threads stack pool"
+
+ s.vm_variable "stack_size", 128 * 1024,
+ "The size of each stack"
+ end
+
c.vm_variable "tool", :string,
:as => "tool_to_load",
:description => "Load a VM tool from a shared library"
View
@@ -168,7 +168,7 @@ namespace rubinius {
fiber_makectx(&dest, (void*)save_and_switch,
(void**)state->vm()->fiber_trampoline(),
- 4096);
+ FiberStacks::cTrampolineSize);
fiber_switch(from->machine(), &dest);
} else {
@@ -187,7 +187,7 @@ namespace rubinius {
fiber_makectx(&dest, (void*)save_and_switch,
(void**)state->vm()->fiber_trampoline(),
- 4096);
+ FiberStacks::cTrampolineSize);
fiber_switch(&dummy, &dest);
} else {
View
@@ -2,6 +2,8 @@
#include "fiber_stack.hpp"
#include "fiber_data.hpp"
+#include "configuration.hpp"
+
#include "bug.hpp"
#include <stdlib.h>
@@ -41,6 +43,12 @@ namespace rubinius {
dec_ref();
}
+ FiberStacks::FiberStacks(SharedState& shared)
+ : max_stacks_(shared.config.fiber_stacks)
+ , stack_size_(shared.config.fiber_stack_size)
+ , trampoline_(0)
+ {}
+
FiberStack* FiberStacks::allocate() {
for(Stacks::iterator i = stacks_.begin();
i != stacks_.end();
@@ -54,8 +62,8 @@ namespace rubinius {
FiberStack* stack = 0;
- if(stacks_.size() < cMaxStacks) {
- stacks_.push_back(FiberStack(cStackSize));
+ if(stacks_.size() < max_stacks_) {
+ stacks_.push_back(FiberStack(stack_size_));
stack = &stacks_.back();
stack->allocate();
View
@@ -60,18 +60,20 @@ namespace rubinius {
};
class FiberStacks {
- typedef std::list<FiberStack> Stacks;
- const static size_t cStackSize = 128 * 1024;
- const static size_t cMaxStacks = 1;
+ public:
const static size_t cTrampolineSize = 4096;
+ private:
+ typedef std::list<FiberStack> Stacks;
+
+ size_t max_stacks_;
+ size_t stack_size_;
+
Stacks stacks_;
void* trampoline_;
public:
- FiberStacks()
- : trampoline_(0)
- {}
+ FiberStacks(SharedState& shared);
FiberStack* allocate();
View
@@ -67,6 +67,7 @@ namespace rubinius {
, stack_start_(0)
, run_signals_(false)
, thread_step_(false)
+ , fiber_stacks_(shared)
, shared(shared)
, waiting_channel_(this, (Channel*)Qnil)

0 comments on commit 794333e

Please sign in to comment.