Loading a config with a large tag node, such as a prefix-list with many rules, takes time proportional to the square of its size: at boot and on load. A 10,000-rule list made the boot-time config load take 50 minutes.
Root cause.
- Cstore::add_tag (src/cstore/cstore.cpp) lists every existing value of the tag node, through the session's unionfs-fuse mount, each time it adds a value.
- The list is used only to enforce a tag limit, and that limit is 0 (off) for almost every node.
- Adding n values therefore reads about n²/2 directory entries.
Measurements
| before | after | |
|---|---|---|
| boot-time load, 10,000-rule list (parser PR 1 installed in both) | 50 min 13 s | 37.4 s |
| load, 4,000 rules | 474.4 s | 16.3 s |
| load, 2,000 rules | 122.9 s | 8.6 s |
Fix direction. Call get_all_child_node_names only when tlimit > 0, the only case that uses the result. Behaviour is unchanged for nodes with and without a limit.