AlinsRan opened a new pull request, #13757:
URL: https://github.com/apache/apisix/pull/13757
### Description
`merge_consumer_route` runs on every request that hits a consumer, and it
deep-copies the whole `route_conf`:
```lua
local new_route_conf = core.table.deepcopy(route_conf)
```
then overwrites `new_route_conf.value.plugins[name] = conf` entry by entry.
Deep-copying the `value.plugins` subtree — usually the largest part of a route
— is wasted work, since every entry that matters is replaced right after.
This adds an `opts.shallow_prefix` option to `core.table.deepcopy` that
shallow-copies members whose parent path starts with the given prefix, and uses
`{ shallow_prefix = "self.value.plugins" }` in `merge_consumer_route`.
It is semantically equivalent: the `plugins` container is still a fresh
table (so overwriting keys does not touch the original), and only the plugin
confs that are *not* overwritten stay as shared references — and those are
read-only here (`merge_consumer_route` always replaces a key, never mutates a
shared conf in place).
### Which issue(s) this PR fixes
Removes one deep copy of the largest part of a route on the consumer-auth
hot path.
### Checklist
- [x] I have explained the need for this PR and the problem it solves
- [x] I have explained the changes or the new features added to this PR
- [x] I have added tests corresponding to this change (`t/core/table.t` TEST
13)
- [x] I have updated the documentation accordingly
- [ ] I have verified locally (full CI covers the rest)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]