NetNameResolver graph of primitive senders

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

NetNameResolver graph of primitive senders

Ben Coman
Following up discussion on the Catalog sometimes delaying Spotter in locations with poor network

Just sharing a poke I had at understanding the name resolution call chain down to the primitives. 
Attached is a Roassal/Artefact generated PDF based on "methods" and "links" from this...

methods := NetNameResolver class methods select: [:m | m selector beginsWith: 'prim']. "start with primitives"
methods := methods asSet.
prevMethods := #() asSet.
links := Set new.
3 timesRepeat: [
|newMethods todo|
newMethods := methods difference: prevMethods. 
prevMethods := methods copy.
todo := newMethods collect: [:m|
|senders| 
((((m methodClass inheritsFrom: TestAsserter) 
or: [m selector = #new])
or: [m methodClass printString beginsWith: 'SmaCC'])
or: [m selector printString beginsWith: '#init'])
ifTrue: [m -> #()] 
ifFalse: [m -> (m senders collect: [:rgmd| rgmd compiledMethod])].
].
todo := todo select: [:sendersOf| sendersOf value size > 0]. "remove fluff"
todo := todo sorted: [:sendersOf1 :sendersOf2| sendersOf1 value size > sendersOf2 value size]. "helps debugging"
todo do: [:sendersOf| 
sendersOf value do: [:sender| 
methods add: sender.
links add: (sender->sendersOf key).  
].
].
methods copy do: [:m| links detect: [:l| (m = l key) or: [ m = l value] ] ifNone: [ methods remove: m]]. "remove fluff"



After loading Roassal from the Catalog into 60411 
I started with Mondrian to graph like this...

b := RTMondrian new.
b shape box.
b nodes: methods forEach: [:each|
b shape 
withText: [:m| m methodClass printString, String cr, m selector printString];
withTextColor: Color black.
b nodes: { each }.
b layout 
]. 
b shape arrowedLine withShorterDistanceAttachPoint.
links do: [:l| b edges connectFrom: l value to: l key].
b layout horizontalDominanceTree horizontalGap: 100.
b build.
b view inspect 

But I wanted to fine tune the layout by moving around a few subtrees
and couldn't work out how to add RTDraggableChildren to the Mondrian edges.

So I tried Roassal direct like this...
    v := RTView new.
    v @ RTDraggableView.
    labelTemplate := (RTLabel new text: [:m | m methodClass printString, String cr, m selector printString]). 

    els := labelTemplate elementsOn: methods. "also see alternative below"
    v addAll: els.
    eb := RTEdgeBuilder new
view: v;
  elements: els.

    links do: [:l| eb connectFrom: l value to: l key].
    RTHorizontalDominanceTreeLayout  on: els.
    els @ RTDraggableChildren.
    v inspect.

But couldn't work out how to put a border around the RTLabel, nor change its background colour. 
I saw RTShape>>#fillColor: and #fillColorElement: but couldn't determine how to make use of them. 

The best I could come up with is the following alternative that replaces 
the code in the middle that assigns "els" and "eb" with...
   els := RTBox elementsOn: methods.
   v addAll: els.
   RTNest new
for: els
add: [ :group :method | 
group
addAll: (labelTemplate elementsOn: {method})].
   eb := RTEdgeBuilder new
view: v;
elements: els.
 
cheers -ben

NetNameResolver-3level-primitive-senders.pdf (46K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: NetNameResolver graph of primitive senders

Sven Van Caekenberghe-2
Ben,

Nice work !

So the conclusion is that only #addressForName:[timeout:] is used a lot and its counterpart #nameForAddress:[timeout:] just a little bit. Right ?

What was your goal in doing this analysis ?

Sven

> On 27 Feb 2017, at 15:40, Ben Coman <[hidden email]> wrote:
>
> Following up discussion on the Catalog sometimes delaying Spotter in locations with poor network
> http://forum.world.st/Catalog-loading-in-Spotter-td4934969.html#a4935842
>
> Just sharing a poke I had at understanding the name resolution call chain down to the primitives.
> Attached is a Roassal/Artefact generated PDF based on "methods" and "links" from this...
>
> methods := NetNameResolver class methods select: [:m | m selector beginsWith: 'prim']. "start with primitives"
> methods := methods asSet.
> prevMethods := #() asSet.
> links := Set new.
> 3 timesRepeat: [
> |newMethods todo|
> newMethods := methods difference: prevMethods.
> prevMethods := methods copy.
> todo := newMethods collect: [:m|
> |senders|
> ((((m methodClass inheritsFrom: TestAsserter)
> or: [m selector = #new])
> or: [m methodClass printString beginsWith: 'SmaCC'])
> or: [m selector printString beginsWith: '#init'])
> ifTrue: [m -> #()]
> ifFalse: [m -> (m senders collect: [:rgmd| rgmd compiledMethod])].
> ].
> todo := todo select: [:sendersOf| sendersOf value size > 0]. "remove fluff"
> todo := todo sorted: [:sendersOf1 :sendersOf2| sendersOf1 value size > sendersOf2 value size]. "helps debugging"
> todo do: [:sendersOf|
> sendersOf value do: [:sender|
> methods add: sender.
> links add: (sender->sendersOf key).  
> ]
> ].
> ].
> methods copy do: [:m| links detect: [:l| (m = l key) or: [ m = l value] ] ifNone: [ methods remove: m]]. "remove fluff"
>
>
>
> After loading Roassal from the Catalog into 60411
> I started with Mondrian to graph like this...
>
> b := RTMondrian new.
> b shape box.
> b nodes: methods forEach: [:each|
> b shape
> withText: [:m| m methodClass printString, String cr, m selector printString];
> withTextColor: Color black.
> b nodes: { each }.
> b layout
> ].
> b shape arrowedLine withShorterDistanceAttachPoint.
> links do: [:l| b edges connectFrom: l value to: l key].
> b layout horizontalDominanceTree horizontalGap: 100.
> b build.
> b view inspect
>
> But I wanted to fine tune the layout by moving around a few subtrees
> and couldn't work out how to add RTDraggableChildren to the Mondrian edges.
>
> So I tried Roassal direct like this...
>     v := RTView new.
>     v @ RTDraggableView.
>     labelTemplate := (RTLabel new text: [:m | m methodClass printString, String cr, m selector printString]).
>
>     els := labelTemplate elementsOn: methods. "also see alternative below"
>     v addAll: els.
>     eb := RTEdgeBuilder new
>                   view: v;
>                   elements: els.
>
>     links do: [:l| eb connectFrom: l value to: l key].
>     RTHorizontalDominanceTreeLayout  on: els.
>     els @ RTDraggableChildren.
>     v inspect.
>
> But couldn't work out how to put a border around the RTLabel, nor change its background colour.
> I saw RTShape>>#fillColor: and #fillColorElement: but couldn't determine how to make use of them.
>
> The best I could come up with is the following alternative that replaces
> the code in the middle that assigns "els" and "eb" with...
>    els := RTBox elementsOn: methods.
>    v addAll: els.
>    RTNest new
> for: els
> add: [ :group :method |
> group
> addAll: (labelTemplate elementsOn: {method})].
>    eb := RTEdgeBuilder new
> view: v;
> elements: els.
>  
> cheers -ben
> <NetNameResolver-3level-primitive-senders.pdf>


Reply | Threaded
Open this post in threaded view
|

Re: NetNameResolver graph of primitive senders

Stephane Ducasse-3
Thanks Ben. 
I would love that we can address this timeout. It is ruining first contact with Pharo. And this year the university set up here was even worse.

Stef. 

On Mon, Feb 27, 2017 at 8:18 PM, Sven Van Caekenberghe <[hidden email]> wrote:
Ben,

Nice work !

So the conclusion is that only #addressForName:[timeout:] is used a lot and its counterpart #nameForAddress:[timeout:] just a little bit. Right ?

What was your goal in doing this analysis ?

Sven

> On 27 Feb 2017, at 15:40, Ben Coman <[hidden email]> wrote:
>
> Following up discussion on the Catalog sometimes delaying Spotter in locations with poor network
> http://forum.world.st/Catalog-loading-in-Spotter-td4934969.html#a4935842
>
> Just sharing a poke I had at understanding the name resolution call chain down to the primitives.
> Attached is a Roassal/Artefact generated PDF based on "methods" and "links" from this...
>
> methods := NetNameResolver class methods select: [:m | m selector beginsWith: 'prim']. "start with primitives"
> methods := methods asSet.
> prevMethods := #() asSet.
> links := Set new.
> 3 timesRepeat: [
>       |newMethods todo|
>       newMethods := methods difference: prevMethods.
>       prevMethods := methods copy.
>       todo := newMethods collect: [:m|
>               |senders|
>               ((((m methodClass inheritsFrom: TestAsserter)
>                       or: [m selector = #new])
>                       or: [m methodClass printString beginsWith: 'SmaCC'])
>                       or: [m selector printString beginsWith: '#init'])
>                       ifTrue: [m -> #()]
>                       ifFalse: [m -> (m senders collect: [:rgmd| rgmd compiledMethod])].
>               ].
>       todo := todo select: [:sendersOf| sendersOf value size > 0]. "remove fluff"
>       todo := todo sorted: [:sendersOf1 :sendersOf2| sendersOf1 value size > sendersOf2 value size]. "helps debugging"
>       todo do: [:sendersOf|
>               sendersOf value do: [:sender|
>                       methods add: sender.
>                       links add: (sender->sendersOf key).
>                       ]
>               ].
> ].
> methods copy do: [:m| links detect: [:l| (m = l key) or: [ m = l value] ] ifNone: [ methods remove: m]]. "remove fluff"
>
>
>
> After loading Roassal from the Catalog into 60411
> I started with Mondrian to graph like this...
>
>       b := RTMondrian new.
>       b shape box.
>       b nodes: methods forEach: [:each|
>               b shape
>                       withText: [:m| m methodClass printString, String cr, m selector printString];
>                       withTextColor: Color black.
>               b nodes: { each }.
>               b layout
>               ].
>       b shape arrowedLine withShorterDistanceAttachPoint.
>       links do: [:l| b edges connectFrom: l value to: l key].
>       b layout horizontalDominanceTree horizontalGap: 100.
>       b build.
>       b view inspect
>
> But I wanted to fine tune the layout by moving around a few subtrees
> and couldn't work out how to add RTDraggableChildren to the Mondrian edges.
>
> So I tried Roassal direct like this...
>     v := RTView new.
>     v @ RTDraggableView.
>     labelTemplate := (RTLabel new text: [:m | m methodClass printString, String cr, m selector printString]).
>
>     els := labelTemplate elementsOn: methods. "also see alternative below"
>     v addAll: els.
>     eb := RTEdgeBuilder new
>                   view: v;
>                   elements: els.
>
>     links do: [:l| eb connectFrom: l value to: l key].
>     RTHorizontalDominanceTreeLayout  on: els.
>     els @ RTDraggableChildren.
>     v inspect.
>
> But couldn't work out how to put a border around the RTLabel, nor change its background colour.
> I saw RTShape>>#fillColor: and #fillColorElement: but couldn't determine how to make use of them.
>
> The best I could come up with is the following alternative that replaces
> the code in the middle that assigns "els" and "eb" with...
>    els := RTBox elementsOn: methods.
>    v addAll: els.
>    RTNest new
>               for: els
>               add: [ :group :method |
>                       group
>                               addAll: (labelTemplate elementsOn: {method})].
>    eb := RTEdgeBuilder new
>       view: v;
>       elements: els.
>
> cheers -ben
> <NetNameResolver-3level-primitive-senders.pdf>



Reply | Threaded
Open this post in threaded view
|

Re: NetNameResolver graph of primitive senders

Ben Coman
In reply to this post by Sven Van Caekenberghe-2
The over-arching goal is to udnerstand and maybe fix this timeout issue.  
I first jumped straight to reviewing sqUnixSocket.c but at 2250 lines it wasn't clear where to start.
Then I noticed the following primitives were not called from the Image...
    primGetAddressInfoFamily
    primGetAddressInfoNext
    primGetNameInfoServiceSize
    primGetAddressInfoSize
    primGetAddressInfoHost:service:flags:family:type:protocol:
    primGetNameInfoHostResult:
    primGetNameInfoServiceResult:
    primGetAddressInfoResult:
    primGetAddressInfoType
    primGetNameInfoHostSize
    primGetAddressInfoProtocol

and just wanted to get a better feel for how things fit together.
For example...
   primNameResolverError is called by resolverError but this has no senders in the Image.


Now btw, was it Linux images that were locking up? And/or other platforms?


cheers -ben


On Tue, Feb 28, 2017 at 3:18 AM, Sven Van Caekenberghe <[hidden email]> wrote:
Ben,

Nice work !

So the conclusion is that only #addressForName:[timeout:] is used a lot and its counterpart #nameForAddress:[timeout:] just a little bit. Right ?

What was your goal in doing this analysis ?

Sven

> On 27 Feb 2017, at 15:40, Ben Coman <[hidden email]> wrote:
>
> Following up discussion on the Catalog sometimes delaying Spotter in locations with poor network
> http://forum.world.st/Catalog-loading-in-Spotter-td4934969.html#a4935842
>
> Just sharing a poke I had at understanding the name resolution call chain down to the primitives.
> Attached is a Roassal/Artefact generated PDF based on "methods" and "links" from this...
>
> methods := NetNameResolver class methods select: [:m | m selector beginsWith: 'prim']. "start with primitives"
> methods := methods asSet.
> prevMethods := #() asSet.
> links := Set new.
> 3 timesRepeat: [
>       |newMethods todo|
>       newMethods := methods difference: prevMethods.
>       prevMethods := methods copy.
>       todo := newMethods collect: [:m|
>               |senders|
>               ((((m methodClass inheritsFrom: TestAsserter)
>                       or: [m selector = #new])
>                       or: [m methodClass printString beginsWith: 'SmaCC'])
>                       or: [m selector printString beginsWith: '#init'])
>                       ifTrue: [m -> #()]
>                       ifFalse: [m -> (m senders collect: [:rgmd| rgmd compiledMethod])].
>               ].
>       todo := todo select: [:sendersOf| sendersOf value size > 0]. "remove fluff"
>       todo := todo sorted: [:sendersOf1 :sendersOf2| sendersOf1 value size > sendersOf2 value size]. "helps debugging"
>       todo do: [:sendersOf|
>               sendersOf value do: [:sender|
>                       methods add: sender.
>                       links add: (sender->sendersOf key).
>                       ]
>               ].
> ].
> methods copy do: [:m| links detect: [:l| (m = l key) or: [ m = l value] ] ifNone: [ methods remove: m]]. "remove fluff"
>
>
>
> After loading Roassal from the Catalog into 60411
> I started with Mondrian to graph like this...
>
>       b := RTMondrian new.
>       b shape box.
>       b nodes: methods forEach: [:each|
>               b shape
>                       withText: [:m| m methodClass printString, String cr, m selector printString];
>                       withTextColor: Color black.
>               b nodes: { each }.
>               b layout
>               ].
>       b shape arrowedLine withShorterDistanceAttachPoint.
>       links do: [:l| b edges connectFrom: l value to: l key].
>       b layout horizontalDominanceTree horizontalGap: 100.
>       b build.
>       b view inspect
>
> But I wanted to fine tune the layout by moving around a few subtrees
> and couldn't work out how to add RTDraggableChildren to the Mondrian edges.
>
> So I tried Roassal direct like this...
>     v := RTView new.
>     v @ RTDraggableView.
>     labelTemplate := (RTLabel new text: [:m | m methodClass printString, String cr, m selector printString]).
>
>     els := labelTemplate elementsOn: methods. "also see alternative below"
>     v addAll: els.
>     eb := RTEdgeBuilder new
>                   view: v;
>                   elements: els.
>
>     links do: [:l| eb connectFrom: l value to: l key].
>     RTHorizontalDominanceTreeLayout  on: els.
>     els @ RTDraggableChildren.
>     v inspect.
>
> But couldn't work out how to put a border around the RTLabel, nor change its background colour.
> I saw RTShape>>#fillColor: and #fillColorElement: but couldn't determine how to make use of them.
>
> The best I could come up with is the following alternative that replaces
> the code in the middle that assigns "els" and "eb" with...
>    els := RTBox elementsOn: methods.
>    v addAll: els.
>    RTNest new
>               for: els
>               add: [ :group :method |
>                       group
>                               addAll: (labelTemplate elementsOn: {method})].
>    eb := RTEdgeBuilder new
>       view: v;
>       elements: els.
>
> cheers -ben
> <NetNameResolver-3level-primitive-senders.pdf>