readd namespace cache

This commit is contained in:
Olof hagsand 2020-03-30 22:07:46 +02:00
parent 0fd71ec372
commit 5535239363
3 changed files with 31 additions and 26 deletions

View file

@ -458,12 +458,12 @@ xml2ns(cxobj *x,
}
#endif
}
#if 0 /* Dont auto-populate all caches, eg startup doesnt need a cache */
/* Set default namespace cache (since code is at this point,
* no cache was found */
* no cache was found
* If not, this is devastating when populating deep yang structures
*/
if (ns && nscache_set(x, prefix, ns) < 0)
goto done;
#endif
ok:
if (namespace)
*namespace = ns;

View file

@ -12,24 +12,35 @@ APPNAME=example
cfg=$dir/scaling-conf.xml
fyang=$dir/scaling.yang
# NOTE, added a deep yang structure (x0,x1,x2) to expose performance due to turned off caching.
cat <<EOF > $fyang
module scaling{
yang-version 1.1;
namespace "urn:example:clixon";
prefix ip;
container x {
list y {
key "a";
leaf a {
type int32;
}
leaf b {
type int32;
}
}
leaf-list c {
type string;
}
container "x0" {
container x1 {
list x2 {
key "name";
leaf name {
type string;
}
container x {
list y {
key "a";
leaf a {
type int32;
}
leaf b {
type int32;
}
}
leaf-list c {
type string;
}
}
}
}
}
}
EOF
@ -65,11 +76,11 @@ fi
# Use it latter to generate startup-db in xml, tree formats
tmpx=$dir/tmp.xml
new "generate large startup config ($tmpx) with $perfnr entries"
echo -n "<config><x xmlns=\"urn:example:clixon\">" > $tmpx
echo -n "<config><x0 xmlns=\"urn:example:clixon\"><x1><x2><name>ip</name><x>" > $tmpx
for (( i=0; i<$perfnr; i++ )); do
echo -n "<y><a>$i</a><b>$i</b></y>" >> $tmpx
done
echo "</x></config>" >> $tmpx
echo "</x></x2></x1></x0></config>" >> $tmpx
if false; then # XXX JSON dont work as datastore yet
# Then generate large JSON file (cant translate namespace - long story)
@ -90,7 +101,7 @@ fi
# Loop over mode and format
for mode in startup running; do
file=$dir/${mode}_db
for format in tree xml; do # json - something w namespaces
for format in xml; do # json - something w namespaces
sudo rm -f $file
sudo touch $file
sudo chmod 666 $file
@ -102,17 +113,11 @@ for mode in startup running; do
json)
cp $tmpj $file
;;
tree)
echo "clixon_util_datastore -d ${mode} -f tree -y $fyang -b $dir -x $tmpx put create"
clixon_util_datastore -d ${mode} -f tree -y $fyang -b $dir -x $tmpx put create
;;
esac
new "Startup format: $format mode:$mode"
# echo "time sudo $clixon_backend -F1 -D $DBG -s $mode -f $cfg -y $fyang -o CLICON_XMLDB_FORMAT=$format"
# Cannot use start_backend here due to expected error case
{ time -p sudo $clixon_backend -F1 -D $DBG -s $mode -f $cfg -y $fyang -o CLICON_XMLDB_FORMAT=$format 2> /dev/null; } 2>&1 | awk '/real/ {print $2}'
done
done

View file

@ -69,8 +69,8 @@ cat <<EOF > $fyang
}
EOF
# No args
testrun(){
# Initial data (default y not given)
XML='<a xmlns="urn:example:default"><b><c>0</c></b></a>'