Subject: [Anima] Review comments on draft-ietf-anima-grasp-api

From: "Liguangpeng (Roc, Network Technology Laboratory)" <[email-masked]>
Date: Wed, 18 Sep 2019 06:22:23 +0000

Hi authors,

I read the draft. I think the API list for grasp is complete and good. But I have some comments on section 2.2.

2.2. Asynchronous Operations

'... there are two main techniques for such parallel operations: multi-threading, or a polling or 'event loop' structure.'

According to my knowledge, 'multi-threading' is a different thing with asynchronous programming mechanism. So I prefer to 'asynchronous programming mechanisms with multi-threading' here. The main techniques for asynchronous programming discussed in draft should be 'polling', however, polling is not so efficient. The more efficient one is 'call back' mechanism.

'session_nonce' parameter may be useful for polling, but 'call back function pointer( or reference in some programming language)' is normally used as parameter of invoked functions. All logics should be executed in call back functions which will be called when some events occur, for example receiving response message for the request, or message timeout.

Best regards,
Guangpeng Li

---

From: Brian E Carpenter <[email-masked]>
Date: Thu, 19 Sep 2019 08:38:34 +1200

On 18-Sep-19 18:22, Liguangpeng (Roc, Network Technology Laboratory) wrote:
> According to my knowledge, 'multi-threading' is a different thing with asynchronous programming mechanism. So I prefer to 'asynchronous programming mechanisms with multi-threading' here.

OK, will rephrase.

> The main techniques for asynchronous programming discussed in draft should be 'polling', however, polling is not so efficient. The more efficient one is 'call back' mechanism.

Yes, we certainly need to discuss callbacks. I'm not sure it is always more efficient, because that depends on the underlying implementation.

> 'session_nonce' parameter may be useful for polling, but 'call back function pointer( or reference in some programming language)' is normally used as parameter of invoked functions. All logics shou…

Yes. However, if you have two simultaneous negotiations, you will still need the session_nonce in the callback, I believe.

Thanks very much,

    Brian

---

From: "Liguangpeng (Roc, Network Technology Laboratory)" <[email-masked]>
Date: Thu, 19 Sep 2019 01:23:44 +0000

Please see inline.

> -----Original Message-----
> From: Brian E Carpenter [mailto:[email-masked]]
> Sent: Thursday, September 19, 2019 4:39 AM
> To: Liguangpeng (Roc, Network Technology Laboratory)
> <[email-masked]>; [email-masked]
> Subject: Re: Review comments on draft-ietf-anima-grasp-api
> 
> > '... there are two main techniques for such parallel operations:
> multi-threading, or a polling or 'event loop' structure.'
> >
> > According to my knowledge, 'multi-threading' is a different thing with
> asynchronous programming mechanism. So I prefer to 'asynchronous
> programming mechanisms with multi-threading' here.
> 
> OK, will rephrase.
> 
> > The main techniques for asynchronous programming discussed in draft should
> be 'polling', however, polling is not so efficient. The more efficient one is 'call
> back' mechanism.
> 
> Yes, we certainly need to discuss callbacks. I'm not sure it is always more
> efficient, because that depends on the underlying implementation.
> 
Agree that all performance rely on the implementation. Generally saying, polling will consume CPU resource to query response again and again until timeout occurs. In other hand, every implement of agent based on polling mechanism library will couple with the library. That means most time different programmers will write the code respectively for the agent and library. It's more hard to guarantee achieve the best performance. Compared to polling, call back mechanism decouples the whole workflow. Only the library programmer need to care about the asynchronous part performance. The agent programmers just need to implement logics according to 'call back' mechanism then everyone can get the same performance provided by the same library.

> > 'session_nonce' parameter may be useful for polling, but 'call back function
> pointer( or reference in some programming language)' is normally used as
> parameter of invoked functions. All logics should be executed in call back
> functions which will be called when some events occur, for example receiving
> response message for the request, or message timeout.
> 
> Yes. However, if you have two simultaneous negotiations, you will still need the
> session_nonce in the callback, I believe.

Yes or not, I think. If the library is implemented based on call back mechanism, the agent programmer don't need to know anything about 'session-nonce'. This means there needn't be this parameter in this kind of API. Indeed, the implementer of library need to consider 'session_nonce' carefully if its name is still 'session_nonce'. So, my opinion is 'session_nonce' is necessary parameter for polling-based API, but not for call-back-based API.

> > Guangpeng Li
Best regards,
Guangpeng

---

From: Brian E Carpenter <[email-masked]>
Date: Thu, 19 Sep 2019 14:12:43 +1200

> Yes or not, I think. If the library is implemented based on call back mechanism, the agent programmer don't need to know anything about 'session-nonce'. This means there needn't be this parameter i…

Sorry to insist, but I really disagree. I'm thinking about how I would code the callback function for a resource allocator, and I'm sure it would need some sort of identifier for the particular resource request, since it might be handling many resource requests in parallel. In GRASP terms that is a session identifier.

Regards
    Brian

---

From: "Liguangpeng (Roc, Network Technology Laboratory)" <[email-masked]>
Date: Thu, 19 Sep 2019 06:34:01 +0000

> Sorry to insist, but I really disagree. I'm thinking about how I would code the
> callback function for a resource allocator, and I'm sure it would need some sort
> of identifier for the particular resource request, since it might be handling many
> resource requests in parallel. In GRASP terms that is a session identifier.

I agree there must be a session identifier in GRASP. However I think this draft is about to define the GRASP API for ASA. The ASA invokes functions through these APIs, and a grasp library implement APIs which includes encapsulating GRASP messages, send out them and wait for receiving response messages. So for call-back approach, all the magic is in the library, the library is responsible for mapping session identifier in messages to correct call-back threads. The ASA just need to tell library which call-back function would be executed when invoke a asynchronous API, the ASA knows nothing about the session identifier used in the messages, thus donot need 'session-nonce' parameter in the API.

Best regards,
Guangpeng

> Sent: Thursday, September 19, 2019 10:13 AM
> >>> I read the draft. I think the API list for grasp is complete and
> >>> good. But I have
> >> some comments on section 2.2.
> >>>
> >> be 'polling', however, polling is not so efficient. The more
> >> efficient one is 'call back' mechanism.
> >>
> >> Yes, we certainly need to discuss callbacks. I'm not sure it is
> >> always more efficient, because that depends on the underlying
> implementation.
> >>
> > Agree that all performance rely on the implementation. Generally saying,
> polling will consume CPU resource to query response again and again until
> timeout occurs. In other hand, every implement of agent based on polling
> mechanism library will couple with the library. That means most time different
> programmers will write the code respectively for the agent and library. It's
> more hard to guarantee achieve the best performance. Compared to polling,
> call back mechanism decouples the whole workflow. Only the library
> programmer need to care about the asynchronous part performance. The
> agent programmers just need to implement logics according to 'call back'
> mechanism then everyone can get the same performance provided by the
> same library.
> >
> >> pointer( or reference in some programming language)' is normally used
> >> as parameter of invoked functions. All logics should be executed in
> >> call back functions which will be called when some events occur, for
> >> example receiving response message for the request, or message timeout.
> >>
> >> Yes. However, if you have two simultaneous negotiations, you will
> >> still need the session_nonce in the callback, I believe.
> >
> > Yes or not, I think. If the library is implemented based on call back mechanism,
> the agent programmer don't need to know anything about 'session-nonce'. This
> means there needn't be this parameter in this kind of API. Indeed, the
> implementer of library need to consider 'session_nonce' carefully if its name is
> still 'session_nonce'. So, my opinion is 'session_nonce' is necessary parameter
> for polling-based API, but not for call-back-based API.
> 
> Sorry to insist, but I really disagree. I'm thinking about how I would code the
> callback function for a resource allocator, and I'm sure it would need some sort
> of identifier for the particular resource request, since it might be handling many
> resource requests in parallel. In GRASP terms that is a session identifier.
> 
> Regards
>     Brian
> 
> >
> >> Thanks very much,
> >>
> >>     Brian
> >>
> >>>
> >>> Best regards,
> >>>
> >>> Guangpeng Li
> >>
> > Best regards,
> > Guangpeng
> >

---

From: Brian E Carpenter <[email-masked]>
Date: Fri, 20 Sep 2019 14:25:58 +1200

Hi Guangpeng,

I will try to explain it in much more detail in the new draft. You are quite correct
that the ASA doesn't need to know any details of the session ID, but the problem
comes when the same function is used as the callback for multiple sessions.

Regards
   Brian Carpenter

---

From: "Liguangpeng (Roc, Network Technology Laboratory)" <[email-masked]>
Date: Fri, 20 Sep 2019 07:11:31 +0000

Hi Brian,

The same function can be executed in different threads simultaneous. How to map sessions to correct thread is responsibility of GRASP module(Maybe by an internal table consist of session id and function pointer). This is why I insist there is no need to use 'session_nonce' as parameter for GRASP module's API(When the GRASP is implemented with call-back mechanism). The workflow below shows how this work to call the same call-back-function A.
              _____________________________
  Messages:   |        GRASP Module       |
Session ID1 -------|-->thread1(call-back function A)----|--->ASA-1
Session ID 2-------|-->thread2(call-back function A)----|--->ASA-2
              |                     (GRASP API here)
              _____________________________

Best regards,
Guangpeng

> Sent: Friday, September 20, 2019 10:26 AM
> that the ASA doesn't need to know any details of the session ID, but the
> problem comes when the same function is used as the callback for multiple
> sessions.
> 
> Regards
>    Brian Carpenter
> 
> >> Sorry to insist, but I really disagree. I'm thinking about how I
> >> would code the callback function for a resource allocator, and I'm
> >> sure it would need some sort of identifier for the particular
> >> resource request, since it might be handling many resource requests in
> parallel. In GRASP terms that is a session identifier.
> >
> > I agree there must be a session identifier in GRASP. However I think this draft
> is about to define the GRASP API for ASA. The ASA invokes functions through
> these APIs, and a grasp library implement APIs which includes encapsulating
> GRASP messages, send out them and wait for receiving response messages. So
> for call-back approach, all the magic is in the library, the library is responsible
> for mapping session identifier in messages to correct call-back threads. The
> ASA just need to tell library which call-back function would be executed when
> invoke a asynchronous API, the ASA knows nothing about the session identifier
> used in the messages, thus donot need 'session-nonce' parameter in the API.
> >
> > Best regards,
> > Guangpeng
> >
> >>>> On 18-Sep-19 18:22, Liguangpeng (Roc, Network Technology
> >>>> Laboratory)
> >> wrote:
> >>>>> Hi authors,
> >>>>>
> >> polling will consume CPU resource to query response again and again
> >> until timeout occurs. In other hand, every implement of agent based
> >> on polling mechanism library will couple with the library. That means
> >> most time different programmers will write the code respectively for
> >> the agent and library. It's more hard to guarantee achieve the best
> >> performance. Compared to polling, call back mechanism decouples the
> >> whole workflow. Only the library programmer need to care about the
> >> asynchronous part performance. The agent programmers just need to
> implement logics according to 'call back'
> >>>> pointer( or reference in some programming language)' is normally
> >>>> used as parameter of invoked functions. All logics should be
> >>>> executed in call back functions which will be called when some
> >>>> events occur, for example receiving response message for the request, or
> message timeout.
> >>>>
> >> the agent programmer don't need to know anything about
> >> 'session-nonce'. This means there needn't be this parameter in this
> >> kind of API. Indeed, the implementer of library need to consider
> >> 'session_nonce' carefully if its name is still 'session_nonce'. So,
> >> my opinion is 'session_nonce' is necessary parameter for polling-based API,
> but not for call-back-based API.
> >>
> >> Sorry to insist, but I really disagree. I'm thinking about how I
> >> would code the callback function for a resource allocator, and I'm
> >> sure it would need some sort of identifier for the particular
> >> resource request, since it might be handling many resource requests in
> parallel. In GRASP terms that is a session identifier.
> >>
> >> Regards
> >>     Brian
> >>
> >>>
> >>>> Thanks very much,
> >>>>
> >>>>     Brian
> >>>>
> >>>>>
> >>>>> Best regards,
> >>>>>
> >>>>> Guangpeng Li
> >>>>
> >>> Best regards,
> >>> Guangpeng
> >>>