Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Weak references. Does node-weak and other simliar libraries, add significant overhead?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  15 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Fredrik O  
View profile  
 More options Oct 22 2012, 12:05 pm
From: Fredrik O <evoo...@gmail.com>
Date: Mon, 22 Oct 2012 09:05:03 -0700 (PDT)
Local: Mon, Oct 22 2012 12:05 pm
Subject: Weak references. Does node-weak and other simliar libraries, add significant overhead?

Hi,

Does anyone know if it is safe, for performance reasons to heavily use the
npm module: "node-weak" and similar libraries? Does it add significant
overhead?

Thanks in advance


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Diogo Resende  
View profile  
 More options Oct 22 2012, 12:52 pm
From: Diogo Resende <drese...@thinkdigital.pt>
Date: Mon, 22 Oct 2012 17:52:05 +0100
Local: Mon, Oct 22 2012 12:52 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

You could use ES6 WeakMaps.

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_...

--
Diogo Resende


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Rajlich  
View profile  
 More options Oct 22 2012, 1:53 pm
From: Nathan Rajlich <nat...@tootallnate.net>
Date: Mon, 22 Oct 2012 10:52:18 -0700
Local: Mon, Oct 22 2012 1:52 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?
I've only really used it for testing and tracking down memory leaks,
but I know that "hook.io" has used it as a dependency in the past, and
that "dnode" does currently. What exactly is your use case?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fedor Indutny  
View profile  
 More options Oct 22 2012, 2:22 pm
From: Fedor Indutny <fe...@indutny.com>
Date: Mon, 22 Oct 2012 22:21:31 +0400
Local: Mon, Oct 22 2012 2:21 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

This actually depends on how much are you going to use them.

Few thousands objects are probably ok, but millions will slow down GC
significantly.

Cheers,
Fedor.

On Mon, Oct 22, 2012 at 9:52 PM, Nathan Rajlich <nat...@tootallnate.net>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fredrik O  
View profile  
 More options Oct 22 2012, 5:23 pm
From: Fredrik O <evoo...@gmail.com>
Date: Mon, 22 Oct 2012 14:22:59 -0700 (PDT)
Local: Mon, Oct 22 2012 5:22 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

Thanks for your responses, all!

I use it too support a simple (C++) RAII functionally, to reclaim
resources, both external and internal resources. I believe it is good idea.
It allows a resource, even if an exception get thrown be reclaimed. I
simply code in mind that a exception can get thrown almost anywhere. For
example this code is not safe:

var obj = pool.create(); //may be a connection pool
// code here which may throw an exception
pool.release(obj); //may not ever be reached, if the code before thrown an
exception, therefore not safe

The regular exception handling will not be a solution, because of the
asynchronous design of node.js. However, if I use weak references, I can
ignore the call to "release" if I want too. This feature is specially
useful for implementing multiple design patterns, for example flyweight:

//copy of C++ boost.flyweight, but in JavaScript
var obj = flyweight("This string will only exist once in memory, so even if
I create thousands of them, will no memory increase significantly
happen");//may be of any type
console.log(obj); //we can treat the object just like the object we
constructed it with: "string", with the exception it is read-only.

When all references dies will the object be released automatically, and
when we want to create a new instance will the library create a new cheap
reference to the value already in memory. This would never be possible
without weak references. I have actually created a module like this, which
I plans to release to the public some time.

So in conclusion, I have started to use it whenever there I believe it
fits, in multiple places, but I wonder if I need to worry about any
significant performance degradation?

PS. How would weak maps be used to call a custom function on garbage
collection?

What are your thoughts?

Thanks in advance!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Waldron  
View profile  
 More options Oct 22 2012, 7:20 pm
From: Rick Waldron <waldron.r...@gmail.com>
Date: Mon, 22 Oct 2012 19:20:02 -0400
Local: Mon, Oct 22 2012 7:20 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

On Monday, October 22, 2012 at 5:22 PM, Fredrik O wrote:

> PS. How would weak maps be used to call a custom function on garbage collection?

I think you've misunderstood, WeakMaps don't facilitate this

Rick


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fredrik O  
View profile  
 More options Oct 24 2012, 10:28 am
From: Fredrik O <evoo...@gmail.com>
Date: Wed, 24 Oct 2012 07:28:06 -0700 (PDT)
Local: Wed, Oct 24 2012 10:28 am
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

Thank you Rick, it was good to know.

Just for curiosity, what do you people thought, to emulate RAII within
JavaScript for those object which need some clean up? Am I doing it
completely wrong? I mean, an exception can easily get thrown in JavaScript
and try..catch cannot catch error within callbacks. And domains just feel
wrong. For those who does not know what RAII is, it is an automatic way to
invoke a destructor when the object get out of reach, by normal control
flow or an exception get thrown. See wikipedia:
http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization

And Nathan (or if there is someone else which can do a serious guess),
because you have not answered I assume it will be fine to use your library
heavily. With heavily do I mean having around 10 000 concurrent weak
objects alive. If you believe it would not be case, please let me know.

Thanks in advance.

Den tisdagen den 23:e oktober 2012 kl. 01:20:19 UTC+2 skrev Rick Waldron:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Rajlich  
View profile  
 More options Oct 24 2012, 11:11 am
From: Nathan Rajlich <nat...@tootallnate.net>
Date: Wed, 24 Oct 2012 08:11:00 -0700
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?
I mean try it and find out :) If you run into problems, let us know!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Rogers  
View profile  
 More options Oct 24 2012, 2:15 pm
From: Marco Rogers <marco.rog...@gmail.com>
Date: Wed, 24 Oct 2012 11:15:49 -0700 (PDT)
Local: Wed, Oct 24 2012 2:15 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

Can you elaborate on "domains just feel wrong". I'm interested in how the
domains api comes across. I've expressed my concerns with it in the past.

:Marco


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bradley Meck  
View profile  
 More options Oct 24 2012, 2:55 pm
From: Bradley Meck <bradley.m...@gmail.com>
Date: Wed, 24 Oct 2012 11:55:53 -0700 (PDT)
Local: Wed, Oct 24 2012 2:55 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

Take it to a different topic if it becomes unrelated also.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Waldron  
View profile  
 More options Oct 24 2012, 3:39 pm
From: Rick Waldron <waldron.r...@gmail.com>
Date: Wed, 24 Oct 2012 15:38:06 -0400
Local: Wed, Oct 24 2012 3:38 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

WeakRefs are on the table for ES6... if someone here wants to write up a
proposal (I'm looking at Nate) I will gladly champion it at the next TC39
meeting.

Rick

On Wed, Oct 24, 2012 at 2:55 PM, Bradley Meck <bradley.m...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fredrik O  
View profile  
 More options Oct 25 2012, 11:43 am
From: Fredrik O <evoo...@gmail.com>
Date: Thu, 25 Oct 2012 08:43:41 -0700 (PDT)
Local: Thurs, Oct 25 2012 11:43 am
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

I have created a new thread for this, see:
https://groups.google.com/forum/?fromgroups=#!topic/nodejs/p7kfwcbJBxE

Den onsdagen den 24:e oktober 2012 kl. 20:15:49 UTC+2 skrev Marco Rogers:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Rajlich  
View profile  
 More options Oct 25 2012, 1:04 pm
From: Nathan Rajlich <nat...@tootallnate.net>
Date: Thu, 25 Oct 2012 10:03:48 -0700
Local: Thurs, Oct 25 2012 1:03 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?
Rick, is there a template for proposals I should base it off of?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Waldron  
View profile  
 More options Oct 25 2012, 1:38 pm
From: Rick Waldron <waldron.r...@gmail.com>
Date: Thu, 25 Oct 2012 13:37:15 -0400
Local: Thurs, Oct 25 2012 1:37 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

On Thu, Oct 25, 2012 at 1:03 PM, Nathan Rajlich <nat...@tootallnate.net>wrote:

> Rick, is there a template for proposals I should base it off of?

Not really, a gist in markdown will be more then sufficient.

Include a rationale (this is probably the easiest part) and ideally a
summary of your experience with weak refs, v8 and how you made the two work
together (ie. anything valuable that you learned here:
https://github.com/TooTallNate/node-weak/blob/master/src/weakref.cc).

Then a rough outline of a "possible" API, keep in mind this sort of thing
will be grilled and bikeshedding will happen. Finally, a composition of
proposed semantics.

Looking forward to seeing what you produce and I'll make sure its on the
Nov meeting agenda

Rick


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Waldron  
View profile  
 More options Oct 25 2012, 1:46 pm
From: Rick Waldron <waldron.r...@gmail.com>
Date: Thu, 25 Oct 2012 13:45:17 -0400
Local: Thurs, Oct 25 2012 1:45 pm
Subject: Re: [nodejs] Weak references. Does node-weak and other simliar libraries, add significant overhead?

Also, take a look at these...

http://wiki.ecmascript.org/doku.php?id=strawman:weak_references
http://wiki.ecmascript.org/doku.php?id=strawman:weak_refs

Perhaps there is something that can built on top of, or an aspect you can
prove/disprove?

Rick

On Thu, Oct 25, 2012 at 1:03 PM, Nathan Rajlich <nat...@tootallnate.net>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »