Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model serialize/parse speed up (migrate to json-ld?) #218

Open
juztas opened this issue Oct 8, 2022 · 3 comments
Open

Model serialize/parse speed up (migrate to json-ld?) #218

juztas opened this issue Oct 8, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@juztas
Copy link
Collaborator

juztas commented Oct 8, 2022

Currently SiteRM<->Orchestrator depends on turtle format for model parse and serialize. Just noticed, that once model becomes big (e.g. enable all vlans on switch - and model becomes ~2MB Size) - load time is way too long:

Load Runtime: 2.5498993396759033
Serialize turtle: 68.14802598953247 Parse from turtle: 2.6531870365142822
turtle Encoding: 0.007528066635131836 Decoding: 0.01204061508178711
Serialize xml: 1.0920462608337402 Parse from xml: 4.955417156219482
xml Encoding: 0.011453866958618164 Decoding: 0.02042531967163086
Serialize json-ld: 1.842646598815918 Parse from json-ld: 3.2983763217926025
json-ld Encoding: 0.012243032455444336 Decoding: 0.021676063537597656
Serialize ntriples: 0.32485270500183105 Parse from ntriples: 2.2749462127685547
ntriples Encoding: 0.015148639678955078 Decoding: 0.028528928756713867
Serialize n3: 71.7072274684906 Parse from n3: 2.732438564300537
n3 Encoding: 0.0065119266510009766 Decoding: 0.012822151184082031
Serialize trig: 70.98702788352966 Parse from trig: 2.7944655418395996
trig Encoding: 0.006345033645629883 Decoding: 0.012744665145874023

Test Script:

import sys
import time
from DTNRMLibs.MainUtilities import encodebase64, decodebase64
from rdflib import Graph

ts1 = time.time()
modelIn = 'model-input.ttl'
currentGraph = Graph()
currentGraph.parse(modelIn, format='turtle')
ts2 = time.time()

print('Load Runtime: %s' % float(ts2 - ts1))

for key in ['turtle', 'xml', 'json-ld', 'ntriples', 'n3', 'trig']:
    ts1 = time.time()
    currentGraph.serialize(format=key)
    ts2 = time.time()
    with open('test-%s' % key, "w", encoding='utf-8') as fd:
        fd.write(currentGraph.serialize(format=key))
    ngraph = Graph()
    ts3 = time.time()
    ngraph.parse('test-%s' % key, format=key)
    ts4 = time.time()
    vals = currentGraph.serialize(format=key)
    ts5 = time.time()
    tmpEnc = encodebase64(vals)
    ts6 = time.time()
    ts7 = time.time()
    decodebase64(tmpEnc)
    ts8 = time.time()
    print('Serialize %s: %s Parse from %s: %s' % (key, float(ts2 - ts1), key, float(ts4 - ts3)))
    print('%s Encoding: %s Decoding: %s' % (key, float(ts6 - ts5), float(ts8 - ts7)))

Move all internals to json-ld (which is also easy to represent in GUI)? Also - API to get model allows to specify model type (currently only turtle). We should allow to specify 'turtle', 'xml', 'json-ld'.

@juztas juztas added the enhancement New feature or request label Oct 8, 2022
@juztas
Copy link
Collaborator Author

juztas commented Oct 8, 2022

Why we noticed that? Arista in LA had this parameter:

interface Port-Channel501
   description Port Channel to Caltech
   mtu 9214
   switchport trunk allowed vlan 1-3872,3874-4094
   switchport mode trunk
!

Which adds all VLANs and their labels from 1 to 3872 into the model, and the model gets big. So for this, there are two fixes:

@juztas
Copy link
Collaborator Author

juztas commented Oct 20, 2023

This happens if we go with a very very big model. As it is in working version - I would leave this as a feature and in future to implement it via configuration parameter - if we see one or another site being slow in model generation.

Closing for now.

@juztas juztas closed this as completed Oct 20, 2023
@juztas juztas added this to the 1.4.10 milestone Jun 8, 2024
@juztas juztas reopened this Jun 8, 2024
@juztas juztas removed this from the 1.4.10 milestone Nov 5, 2024
@juztas
Copy link
Collaborator Author

juztas commented Nov 5, 2024

postponing after SC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant