Showing with 11 additions and 9 deletions.
  1. +7 −2 src/node_buffer.h
  2. +2 −1 src/slab_allocator.h
  3. +1 −3 src/stream_wrap.cc
  4. +1 −3 src/udp_wrap.cc
@@ -68,8 +68,13 @@ class NODE_EXTERN Buffer: public ObjectWrap {
// mirrors deps/v8/src/objects.h
static const unsigned int kMaxLength = 0x3fffffff;

// exported in lib/buffer.js as Buffer.poolSize
static const unsigned int kPoolSize = 32768;
// Exported in lib/buffer.js as Buffer.poolSize. It's this big for two
// reasons:
//
// 1) It reduces the number of mmap() syscalls we have to make.
// 2) It gives the kernel a fighting chance to map it as two huge pages
// instead of myriads of 4 kB pages.
static const unsigned int kPoolSize = 8 * 1024 * 1024;

static v8::Persistent<v8::FunctionTemplate> constructor_template;

@@ -19,13 +19,14 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "node_buffer.h" // Buffer::kPoolSize
#include "v8.h"

namespace node {

class SlabAllocator {
public:
SlabAllocator(unsigned int size = 10485760); // default to 10M
SlabAllocator(unsigned int size = Buffer::kPoolSize);
~SlabAllocator();

// allocate memory from slab, attaches the slice to `obj`
@@ -32,8 +32,6 @@
#include <stdlib.h> // abort()
#include <limits.h> // INT_MAX

#define SLAB_SIZE (1024 * 1024)


namespace node {

@@ -91,7 +89,7 @@ void StreamWrap::Initialize(Handle<Object> target) {
if (initialized) return;
initialized = true;

slab_allocator = new SlabAllocator(SLAB_SIZE);
slab_allocator = new SlabAllocator;
AtExit(DeleteSlabAllocator, NULL);

HandleScope scope;
@@ -28,8 +28,6 @@

#include <stdlib.h>

#define SLAB_SIZE (1024 * 1024)


using namespace v8;

@@ -67,7 +65,7 @@ UDPWrap::~UDPWrap() {
void UDPWrap::Initialize(Handle<Object> target) {
HandleWrap::Initialize(target);

slab_allocator = new SlabAllocator(SLAB_SIZE);
slab_allocator = new SlabAllocator;
AtExit(DeleteSlabAllocator, NULL);

HandleScope scope;