Skip to content

Utility methods for FlatKV cache#3055

Merged
cody-littley merged 8 commits intomainfrom
cjl/cache-utils
Mar 12, 2026
Merged

Utility methods for FlatKV cache#3055
cody-littley merged 8 commits intomainfrom
cjl/cache-utils

Conversation

@cody-littley
Copy link
Contributor

Describe your changes and provide context

Implements several utilities needed for the FlatKV cache.

Testing performed to validate your change

Unit tests, tested on branch that has integrated cache

@github-actions
Copy link

github-actions bot commented Mar 11, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 12, 2026, 2:23 PM

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 86.79245% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.36%. Comparing base (04faa6c) to head (e6ec6f4).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/common/threading/adhoc_pool.go 45.45% 4 Missing and 2 partials ⚠️
sei-db/common/threading/elastic_pool.go 86.48% 4 Missing and 1 partial ⚠️
sei-db/common/threading/fixed_pool.go 91.89% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3055      +/-   ##
==========================================
+ Coverage   58.26%   58.36%   +0.10%     
==========================================
  Files        2072     2082      +10     
  Lines      171414   171146     -268     
==========================================
+ Hits        99882    99897      +15     
+ Misses      62602    62313     -289     
- Partials     8930     8936       +6     
Flag Coverage Δ
sei-chain-pr 67.12% <86.79%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/common/threading/chan_utils.go 100.00% <100.00%> (ø)
sei-db/wal/wal.go 64.67% <100.00%> (-4.51%) ⬇️
sei-db/common/threading/fixed_pool.go 91.89% <91.89%> (ø)
sei-db/common/threading/elastic_pool.go 86.48% <86.48%> (ø)
sei-db/common/threading/adhoc_pool.go 45.45% <45.45%> (ø)

... and 248 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

// The work pool shuts down when the context is done.
ctx context.Context,
// The name of the work pool. Used for metrics.
name string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems currently not being used, are we gonna add metrics for that in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the plan was to add metrics, but I didn't get to that as a part of this PR. I still want to add them eventually, though.

What is your preference? I'm ok with either deleting this until we need (not that much work to add later), or leaving it in as a placeholder.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, if we plan to add metrics in the future, let's keep the name there

Comment on lines +17 to +19
ZB = EB * 1024
// YB is the number of bytes in a yottabyte.
YB = ZB * 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any attempt to assign them to a standard integer variable (e.g., var x int64 = unit.ZB) will fail at compile time, this might be a bit confusing, do you think we would need to use that unit at all? Or shall we just remove them for now and add them when we really need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, very good point. I've removed the ZB and YB constants.

}

func (p *adHocPool) Submit(_ context.Context, task func()) error {
go task()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • fixedPool and elasticPool both return an error for nil tasks but adHocPool launches go task() directly. consider adding a nil check.
  • the passed in context cancellation is ignored

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ixedPool and elasticPool both return an error for nil tasks but adHocPool launches go task() directly. consider adding a nil check.

check added

the passed in context cancellation is ignored

This now checks to see if the context is done before invoking

@cody-littley cody-littley enabled auto-merge (squash) March 11, 2026 20:29
@cody-littley cody-littley added this pull request to the merge queue Mar 12, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2026
@cody-littley cody-littley enabled auto-merge March 12, 2026 13:10
@cody-littley cody-littley added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit 2f6c4e5 Mar 12, 2026
39 of 40 checks passed
@cody-littley cody-littley deleted the cjl/cache-utils branch March 12, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants