Use ImmutableMap for single namespaces 61/87161/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 27 Jan 2020 11:31:15 +0000 (12:31 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 27 Jan 2020 12:09:44 +0000 (13:09 +0100)
commit23ddbaeb5437a1c289c71bdceaf4ff55ea531af6
treeb37a5094f29178204238536366c56e9440c1b2c5
parent083e882554f745039f4dd7f8db99264c6fb1fa07
Use ImmutableMap for single namespaces

It is extremely common for statement contexts to have exactly one
namespace (i.e. ChildSchemaNodeNamespace). Tracking that in a HashMap
is not very memory-efficient (nor performance-efficient), as we will
end up allocating all the HashMap internals.

Separate out the single-namespace case and use an ImmutableMap singleton
to hold the namespace -- which saves ~65MiB in a reference test case
accounding for ~6% of scratch memory used (~3% total used).

JIRA: YANGTOOLS-652
Change-Id: Ie2b1faeb4c966c20be0818d3b54aa7c8367f0c58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/NamespaceStorageSupport.java