Skip to content

[Databuckets] Nested Caching#4917

Merged
Akkadius merged 9 commits intomasterfrom
akkadius/databuckets-nested-caching
Jun 25, 2025
Merged

[Databuckets] Nested Caching#4917
Akkadius merged 9 commits intomasterfrom
akkadius/databuckets-nested-caching

Conversation

@Akkadius
Copy link
Copy Markdown
Contributor

@Akkadius Akkadius commented Jun 11, 2025

Description

This PR dramatically improves databuckets performance in two ways

  • Nested Buckets - Even if a databucket was cached, the nested databucket access is not, which means the server has to recursively walk a json tree to find the nested value. This is computationally very expensive in hot paths. This is now cached in this PR
  • Scoped Bucket Cache By Default - Before, if you didn't have a bucket in the cache as a miss, we'd hit the database once before it was inserted as a miss and then the second ask was cached. Now, since we pre-load all cached scoped keys, we assume that if the entity doesn't have a key in the cache, it just simply doesn't have the key. This leads to a 1,000x speed improvement just in pure access speed and we also avoid potentially tons of database hits depending on a servers access patterns.

Benchmark - 5,000 iterations (1,000x speedup)

  • Before - 0.279923 seconds
  • After - 0.000295002

Type of change

  • Performance

Testing

===========================================
⚙️> Running DataBuckets Tests...
===========================================

[✅] Basic Key-Value Set/Get PASSED
[✅] Overwriting a Key PASSED
[✅] Deleting a Key PASSED
[✅] Setting a Key with an Expiration PASSED
[✅] Ensure Expired Key is Deleted PASSED
[✅] Cache Read/Write Consistency PASSED
[✅] Cache Clears on Key Deletion PASSED
[✅] Setting a Full JSON String PASSED
[✅] Overwriting JSON with a Simple String PASSED
[✅] Deleting Non-Existent Key PASSED
[✅] Basic Key-Value Set/Get PASSED
[✅] Nested Key Set/Get PASSED
[✅] Prevent Overwriting Objects PASSED
[✅] Delete Nested Key PASSED
[✅] Delete Parent Key PASSED
[✅] Expiration Ignored for Nested Keys PASSED
[✅] Cache Read/Write Consistency PASSED
[✅] Cache Clears on Parent Delete PASSED
[✅] Set and Retrieve Full JSON Structure PASSED
[✅] Delete Nested Key within JSON PASSED
[✅] Ensure Object Protection on Overwrite Attempt PASSED
[✅] Deleting Non-Existent Key Doesn't Break Existing Data PASSED
[✅] Get nested key value PASSED
[✅] Get nested key value deep PASSED
[✅] Retrieve Nested Key from Plain String PASSED
[✅] Store and Retrieve JSON Array PASSED
[✅] Retrieve Non-Existent Nested Key PASSED
[✅] Overwriting Parent Key Deletes Children PASSED
[✅] Store and Retrieve Empty JSON Object PASSED
[✅] Store and Retrieve JSON String PASSED
[✅] Deeply Nested Key Retrieval PASSED
[✅] Setting a nested key with an expiration protection test PASSED
[✅] Scoped Missing Key Returns Empty (Skips DB) PASSED
[✅] Nested Scoped Key Miss Returns Empty (Skips DB) PASSED
[✅] Initial Cache Miss Returns Empty PASSED
[✅] Overwrite After Cache Miss Works PASSED
[✅] Missed Nested Key Returns Empty PASSED
[✅] Nested Set After Miss Works PASSED
[✅] Cold Cache Scoped Key Returns Empty (Due to Skip DB) PASSED
[✅] Post-BulkLoad Scoped Key Returns Value PASSED
[✅] Post-BulkLoad Nested Scoped Key Returns Value PASSED
[✅] Post-Delete Nested Scoped Key Returns Empty PASSED

===========================================
✅ All DataBucket Tests Completed!
===========================================

Checklist

  • I have tested my changes
  • I have performed a self-review of my code. Ensuring variables, functions and methods are named in a human-readable way, comments are added only where naming of variables, functions and methods can't give enough context.
  • I own the changes of my code and take responsibility for the potential issues that occur

@Akkadius Akkadius force-pushed the akkadius/databuckets-nested-caching branch from a358c63 to aeb54a7 Compare June 16, 2025 21:51
@Akkadius Akkadius merged commit ea96cbf into master Jun 25, 2025
2 checks passed
@Akkadius Akkadius deleted the akkadius/databuckets-nested-caching branch June 25, 2025 17:47
@Akkadius Akkadius mentioned this pull request Jun 25, 2025
Akkadius added a commit that referenced this pull request Jun 28, 2025
Akkadius added a commit that referenced this pull request Jun 28, 2025
* [Databuckets] Revert Caching Changes of #4917

* Comment caching tests until addressed later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants