[nanomsg] Re: daily nng progress update. :-)

  • From: "Garrett D'Amore" <garrett@xxxxxxxxxx>
  • To: "nanomsg@xxxxxxxxxxxxx" <nanomsg@xxxxxxxxxxxxx>
  • Date: Mon, 23 Jan 2017 10:50:48 -0800

Ok, I’m not sure what exactly is “wrong” with the code I have there for
linked lists.  For my purposes it works beautifully.  The linked lists are
not designed to support iteration during modification; if that’s what you
need, you’ll have to add locking, and some kind of detection of iterator
state or reference counts on nodes so that the iterator can tell when the
node it is referencing is no longer valid (or you have to expose iterator
state to the thing modifying the list — especially deletion of nodes — so
that it can prevent the iterator from having an unsafe state.)

I don’t have any of those problems in the nng core, and I’d be very unhappy
to add a bunch of code to deal with this non-problem, as that would be
unneeded complexity and would probably have a negative performance impact.
 (All of my linked lists are carefully accessed under locks only, such as
the per-socket lock when adding to the list of endpoints or pipes, and I
have no need to support “external” iteration by code that isn’t already
holding the necessary lock.)

I guess what I’m trying to tell you is, don’t waste your time on trying to
make this code “better” for nng’s benefit.  That said if you want to take
the code I’ve written, and enhance it further for other uses in your own
code, you are welcome to do so — the code is licensed liberally enough that
you are welcome to do so.  Please do preserve my copyright notice, and also
add some notice that you’ve made further changes to the code though.

 - Garrett


On Mon, Jan 23, 2017 at 10:12 AM, omid shahraki <dreamstechgroup@xxxxxxxxx>
wrote:

Very thanks. I try to spend a while on it to make it more robust.
Unfortunately I am very busy. But, I will let you know when finished. I
know you are focusing on more important and key parts.

Omid

On Jan 23, 2017 20:34, "Garrett D'Amore" <garrett@xxxxxxxxxx> wrote:

Internally right now nng does use linked lists for some things, hash
tables for others, and arrays for still others.  But they are not part of
the public API.

Sent from my iPhone

On Jan 23, 2017, at 5:05 AM, Michael Powell <mwpowellhtx@xxxxxxxxx>
wrote:

Awhile back, Mr. D'Amore discussed the structures supporting nng, and
decided to run with arrays instead. So, lists are of no relevance to
the discussion, AFAIK, IMO.

Besides which, list/vector tutorials are well beyond the scope of this
mailing list, I should think.

Best of luck!

On Mon, Jan 23, 2017 at 7:31 AM, omid shahraki
<dreamstechgroup@xxxxxxxxx> wrote:
Sorry. But it was just on the go. I was thinking of using linked list
in
cases we have iterations on one side and list enrichment on the other
side.
And concerning nng linked list design and list.c for usage and test, I
think
it would need a bit adjustment. Could you provide a sample for it. For
example iterating through a container such as vector and inserting into
linked list.;-)

Bests,
Omid

On Jan 23, 2017 02:46, "Garrett D'Amore" <garrett@xxxxxxxxxx> wrote:

I am not sure I understand the question.  What is the relevance of
linked
lists here?

Sent from my iPhone

On Jan 22, 2017, at 12:03 PM, omid shahraki <
dreamstechgroup@xxxxxxxxx>
wrote:

Could you bring an example of using linked list in a loop? Such as
fetching requests through NIO and adding to linked list.

Omid

On Jan 22, 2017 14:09, "Garrett D'Amore" <garrett@xxxxxxxxxx> wrote:

Good news is that I’ve implemented NNG_OPT_SNDFD and NNG_OPT_RCVFD.

The bad news is that I’m not thrilled with the extra levels of
indirection
I’ve had to do have done to performance — the context switching
between
threads has a measurable impact — cutting my performance into about
half of
what it was before.

I have some ideas for how to fix this — including disabling
notifications
for cases where the caller hasn’t asked for them, and avoiding one
more
context switch even when I do notifications if the socket is buffered.
(Unbuffered sockets have to endure some pain — not sure how I can help
them.)

Anyway, optimizations aside, I’m reasonably comfortable with the API
now,
and all of the critical functionality required for the compatibility
layer
is now implemented.  I had hoped to have that layer implemented
tonight, but
its taken a while to debug the various event stuff on the different
platforms.

I’ll probably focus on finishing this functionality before I go back
to
work out the context switch related issues.

- Garrett






Other related posts: