Use ImmutableMap for single namespaces 64/87164/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 27 Jan 2020 11:31:15 +0000 (12:31 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 27 Jan 2020 12:49:14 +0000 (12:49 +0000)
commit9a4dfc2b5823fb7cd7008845fe2555face4029f2
tree54d8fb85b533658d29b75cbfce2fe332baccc64d
parentee44f486a50361ed50bab4e82853ee4da5312fce
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