-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cache): update cache with O(1) data structures #780
fix(cache): update cache with O(1) data structures #780
Conversation
ed2a8c5
to
d97cfc8
Compare
src/cache_test.ts
Outdated
expect(cache.get('name1')).to.equal(list[0]); | ||
expect(cache.get('name2')).to.equal(list[1]); | ||
expect(cache.get('name1', 'default')).to.equal(list[0]); | ||
expect(cache.get('name2', 'default')).to.equal(list[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the test here to take the default
namespace. The old logic didn't make much sense and it seemed like it was supposed to return undefined
if the name and namespace did not match. From a consumer perspective I would expect the namespace to only be optional if the resource is global like a namespace
or pv
. Let me know I should restore the old behavior of finding the first object with a matching name regardless of what namespace its in if no namespace is provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of this test, the objects are global, they are V1Namespace
so I think this test shouldn't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see this test incorrectly puts namespace
in the mocked responses so the namespace objects have namespaces. I'll split this into two tests one for namespace objects and one for unnamespaced objects.
The prior implementation used arrays to store cached objects. This meant that updates were O(n). In a controller I developed that managed ~70k PV and ~70k pvc 99.9% of CPU time was spent in cache updates pegging the entire process. This new implementation doesn't even have cache updates show up in the profiles and is using ~25m cpu for the same number of objects.
…th O(1) data structures
15e74b9
to
a589f36
Compare
/lgtm Thanks for the PR! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bbatha, brendandburns The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The prior implementation used arrays to store cached objects. This meant
that updates were O(n). In a controller I developed that managed ~70k PV
and ~70k pvc 99.9% of CPU time was spent in cache updates pegging the
entire process. This new implementation doesn't even have cache updates
show up in the profiles and is using ~25m cpu for the same number of
objects.