forked from open-policy-agent/opa
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage/inmem: Avoid unnecessary read operation
While writing data to the in-memory store via truncate op, OPA reads data at the current path before adding new data to the store to ensure the path exists. A bundle that contains data files at non-root locations will trigger a read on the store for each file and hence for a large bundle this can cause an increase in the bundle activation time and also resource usage. This change attempts to avoid multiple read ops by merging all the data in the bundle and performing a single write on the store. This fix was tested by observing the bundle activation time and cpu usage during bundle activation. The test bundle consisted of multiple data files at non-root locations. The bundle structure was something like: a/b/data.json, a/c/data.json etc. Improvements were seen in both cpu usage and activation time as compared to the older approach of doing a read while writing each file. This can be attributed to not reading all data under "a" in the test bundle for every write which was the case earlier. Fixes: open-policy-agent#4898 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
- Loading branch information
1 parent
5204239
commit 89e22df
Showing
2 changed files
with
94 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters