Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Performace issue in createInstance method
September 16, 2024
17:59, EEST
Avatar
jyotisathe
Member
Members
Forum Posts: 3
Member Since:
September 16, 2024
sp_UserOfflineSmall Offline

We are facing performance issue while adding custom type nodes into ChangingContentFolderType.

Model:
P.S.
1. Bolded part where we see performance issue.
2. ChangingContentFolderType is an extension of the FolderType and it was created for requirement of dynamically added nodes.
For e.g. We are publishing data over NATS which is consumed by our application and it’s data is added to the CustomTypes under ChangingContentFolderType.

Objects (Level1 1)
| -> RootEntities (Level 2)
| -> ObjectNode (CustomType) (Level 3)
|-> Object Node(FolderType) (Level 4)
|-> Object Node(FolderType) (Level 4)
|-> Object Node(ChangingContentFolderType) (Level 4)
|-> Object Node(FolderType) (Level 4)
|-> Variable Node (Level 4)
|-> Object Node(FolderType) (Level 4)
|-> Variable Node (Level 4)
|-> Object Node(ChangingContentFolderType) (Level 4)
|-> Object Node(Custom Type 1) (Level 5)
|-> Variable Node (Level 6)
|-> Object Node (ChangingContentFolderType) (Level 6)
|-> Object Node (Custom Type 2) (Level 7)
|-> 4 Variable Nodes (Level 8)
|-> Object Node (Custom Type 3) -> 5 Variable Nodes (Level 8)
|-> Variable Node (Level 6)

|-> Variable Node (Level 4)

Code Setup:
1. We have added implementations for createAndreferenceInstance as below, which we use to create custom type nodes(CustomType1)

public T createAndReferenceInstance(Class type, String browseName, FolderTypeNode parentNode) {
final var instance = parentNode.getNodeManager().createInstance(type, browseName, NodeId.randomGUID(nameSpaceIndex));

if (instance instanceof BaseNode) {
((BaseNode) instance).initNodeVersion();
}

if (instance != null) {
parentNode.addComponent(instance);
}

return instance;
}

2. We get ChangingContentFolderType Node from customTypeNode using getter method.
3. For creating custom type nodes(CustomType2) under this ChangingContentFolderType we use below createInstance() method.

public T createInstance(Class type, String browseName, FolderTypeNode parentNode) {
return parentNode.getNodeManager().createInstance(type, browseName, NodeId.randomGUID(atoNamespaceIndex));
}

Issue Description & Investigation:
We are adding custom type nodes(CustomType2) into ChangingContentFolderType, which are around 3100 nodes which is taking ~119489400-131519100 nanoseconds per node to be added into ChanginContentFolderType.

We tried to reproduce the issue with Sample Code but no luck. We tried to add Object Node(.i.e under RootEntities) to MyObjectsFolder and tried to add 3100 nodes as per our namespace to respective ChangineContentFolderType. With sample code it takes ~12-14 seconds.

Prosys Version:
prosys-opc-ua-sdk-for-java-5.2.2-139-client-server SDK.

September 17, 2024
10:03, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

119489400 ns = ~120ms
131519100 ns = ~130ms

Depends of course on the hardware used (?) and the complexity of the type (?), but generally speaking on normal hardware that sounds way longer than it should. Though, OPC UA’s instantiation rules are somewhat complicated and our implementation does use the real node-graph on the address space for calculating the so called InstanceDeclarationHierarchy of the type, but that is cached of first createInstance per type. So the first one is slower than the rest (unless you reset the cache).

Just as an example, a modified MyNodeManager.createAlarmNode:
for (int i = 0; i < 10000; i++) {
myAlarm = createInstance(ExclusiveLevelAlarmTypeNode.class, name + i);
getNodeManagerTable().getNodeManagerRoot().getObjectsFolder().addOrganizes(myAlarm);
}
would take in total about 5-6 seconds on my dev machine (Ryzen 5950X).

Could you run some Profiler tool (e.g. https://visualvm.github.io/) to see CPU times? Though it is important to note that depending on the tooling options, do use a ‘sampling mode’, not an ‘instrumentation mode’, since the instrumentation mode would skew the times since there is very many methods calls involved. If that doesn’t tell the source of the issue (which could potentially be somewhere in your code since it doesn’t happen with the sample), maybe you can send a screenshot of the CPU times graph (of a Profiler tool) to uajava-support@prosysopc.com.

September 18, 2024
10:18, EEST
Avatar
jyotisathe
Member
Members
Forum Posts: 3
Member Since:
September 16, 2024
sp_UserOfflineSmall Offline

We are facing performance issue for both addition and deletion of nodes.

I am using Intellij Profiler for profiling, I have sent mail of profiling details for both addition and deletion of nodes.

Currently I am testing on Windows 10.

Edition Windows 10 Enterprise
Version 22H2
OS build 19045.4780
Experience Windows Feature Experience Pack 1000.19060.1000.0
Processor 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz 3.00 GHz
Installed RAM 32.0 GB (31.7 GB usable)
System type 64-bit operating system, x64-based processor

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
54 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 734

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1523

Posts: 6449

Newest Members:

christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16, edgardo3518

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1