Skip to content

feat(inkless): add bytes limit to cache#544

Merged
jeqo merged 1 commit intomainfrom
jeqo/add-cache-bytes-limit-v2
Mar 20, 2026
Merged

feat(inkless): add bytes limit to cache#544
jeqo merged 1 commit intomainfrom
jeqo/add-cache-bytes-limit-v2

Conversation

@jeqo
Copy link
Copy Markdown
Contributor

@jeqo jeqo commented Mar 17, 2026

Add a new limiting configuration for cache sizing based on bytes instead of entries.

Historically, previous caching library only supported sizing based on entries. With Caffeine, sizing can now be defined by both entries and max bytes using weigher.

@jeqo jeqo force-pushed the jeqo/add-cache-bytes-limit-v2 branch 2 times, most recently from 00eb6a3 to 7861e9c Compare March 17, 2026 15:44
@jeqo jeqo requested a review from Copilot March 17, 2026 15:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional byte-based sizing limit for the in-memory consume cache, leveraging Caffeine’s weighted eviction, and wires the new configuration through Inkless config, docs, and tests.

Changes:

  • Introduce consume.cache.max.bytes / inkless.consume.cache.max.bytes config and expose it via InklessConfig.cacheMaxBytes().
  • Pass the optional max-bytes limit into cache initialization (SharedStateCaffeineCache) and update tests to match the new constructor.
  • Document the new configuration option in docs/inkless/configs.rst.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
storage/inkless/src/main/java/io/aiven/inkless/cache/CaffeineCache.java Adds OptionalLong max-bytes support via maximumWeight + weigher.
storage/inkless/src/main/java/io/aiven/inkless/config/InklessConfig.java Adds new config key + getter returning OptionalLong.
storage/inkless/src/main/java/io/aiven/inkless/common/SharedState.java Wires cacheMaxBytes() into cache construction.
storage/inkless/src/test/java/io/aiven/inkless/consume/FetchPlannerTest.java Updates CaffeineCache constructor calls to include OptionalLong.empty().
storage/inkless/src/test/java/io/aiven/inkless/config/InklessConfigTest.java Adds coverage for parsing/presence of cache.max.bytes.
docs/inkless/configs.rst Documents consume.cache.max.bytes and updates max-count description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeqo jeqo force-pushed the jeqo/add-cache-bytes-limit-v2 branch 2 times, most recently from 6c7b2a9 to 6d3b403 Compare March 17, 2026 17:56
@jeqo jeqo requested a review from Copilot March 17, 2026 17:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for sizing the Inkless consume cache by total bytes (in addition to entry count) by introducing a new configuration and wiring it into the Caffeine cache implementation.

Changes:

  • Add consume.cache.max.bytes config (default -1) with validation and documentation.
  • Update CaffeineCache to use maximumWeight + weigher when a bytes limit is configured.
  • Update shared initialization and tests to pass the new constructor argument.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
storage/inkless/src/main/java/io/aiven/inkless/cache/CaffeineCache.java Adds bytes-based eviction via Caffeine weight/weigher and updates constructor signature.
storage/inkless/src/main/java/io/aiven/inkless/config/InklessConfig.java Introduces consume.cache.max.bytes config definition, validation, and accessor.
storage/inkless/src/main/java/io/aiven/inkless/common/SharedState.java Wires the new config value into CaffeineCache construction.
storage/inkless/src/test/java/io/aiven/inkless/config/InklessConfigTest.java Adds config parsing/validation tests for consume.cache.max.bytes.
storage/inkless/src/test/java/io/aiven/inkless/consume/FetchPlannerTest.java Updates CaffeineCache instantiations for the new constructor signature.
docs/inkless/configs.rst Documents the new consume.cache.max.bytes setting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeqo jeqo force-pushed the jeqo/add-cache-bytes-limit-v2 branch 3 times, most recently from 88fcbb9 to 0318965 Compare March 18, 2026 14:14
@jeqo jeqo requested a review from Copilot March 18, 2026 14:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new cache sizing configuration to Inkless so the in-memory consume cache can be limited by bytes (using Caffeine weight-based eviction) in addition to the existing entry-count limit.

Changes:

  • Introduce consume.cache.max.bytes config (default 0 = disabled) and wire it into cache initialization.
  • Update CaffeineCache to use maximumWeight(...).weigher(...) when the bytes limit is enabled.
  • Add/adjust tests and update documentation for the new config.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
storage/inkless/src/main/java/io/aiven/inkless/cache/CaffeineCache.java Adds byte-based eviction via Caffeine weight+weigher (but currently has a generic typing issue).
storage/inkless/src/main/java/io/aiven/inkless/config/InklessConfig.java Defines consume.cache.max.bytes config + accessor.
storage/inkless/src/main/java/io/aiven/inkless/common/SharedState.java Passes the new cacheMaxBytes() value into CaffeineCache.
storage/inkless/src/test/java/io/aiven/inkless/cache/CaffeineCacheTest.java New tests covering count-based vs byte-based eviction behavior.
storage/inkless/src/test/java/io/aiven/inkless/config/InklessConfigTest.java Extends config parsing/validation tests for the new setting.
storage/inkless/src/test/java/io/aiven/inkless/consume/FetchPlannerTest.java Updates cache construction calls to include the new constructor parameter.
docs/inkless/configs.rst Documents consume.cache.max.bytes and updates consume.cache.max.count wording.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeqo jeqo force-pushed the jeqo/add-cache-bytes-limit-v2 branch from 0318965 to 4330cf1 Compare March 18, 2026 15:06
@jeqo jeqo requested a review from Copilot March 18, 2026 15:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new cache sizing configuration to Inkless so the in-memory consume cache can be limited by total cached bytes (using Caffeine weight-based eviction) in addition to the existing entry-count limit.

Changes:

  • Introduce consume.cache.max.bytes config (default 0 = disabled) and wire it into SharedState cache creation.
  • Update CaffeineCache to use maximumWeight(...).weigher(...) when the bytes limit is enabled; otherwise keep maximumSize(...).
  • Add/adjust unit tests and documentation for the new configuration.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
storage/inkless/src/main/java/io/aiven/inkless/cache/CaffeineCache.java Add byte-based eviction support via Caffeine weigher/maximumWeight and a test-only cleanup hook.
storage/inkless/src/main/java/io/aiven/inkless/common/SharedState.java Pass cacheMaxBytes() into the CaffeineCache constructor.
storage/inkless/src/main/java/io/aiven/inkless/config/InklessConfig.java Define consume.cache.max.bytes config and expose cacheMaxBytes() accessor.
storage/inkless/src/test/java/io/aiven/inkless/cache/CaffeineCacheTest.java New tests covering count-based vs byte-based eviction behavior.
storage/inkless/src/test/java/io/aiven/inkless/config/InklessConfigTest.java Extend config parsing/validation tests to include consume.cache.max.bytes.
storage/inkless/src/test/java/io/aiven/inkless/consume/FetchPlannerTest.java Update test cache instantiations for the new constructor signature.
docs/inkless/configs.rst Document the new consume.cache.max.bytes config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeqo jeqo force-pushed the jeqo/add-cache-bytes-limit-v2 branch from 4330cf1 to 7d80d80 Compare March 18, 2026 15:23
@jeqo jeqo requested a review from Copilot March 18, 2026 15:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Inkless consume-cache sizing option that limits cache capacity by total cached payload bytes (via Caffeine maximumWeight + weigher), in addition to the existing entry-count limit.

Changes:

  • Introduce consume.cache.max.bytes config (default 0 = disabled) and wire it into cache initialization.
  • Update CaffeineCache to choose between count-based eviction (maximumSize) and bytes-based eviction (maximumWeight + weigher).
  • Extend tests and generated config docs to cover the new configuration and behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
storage/inkless/src/main/java/io/aiven/inkless/cache/CaffeineCache.java Adds bytes-based eviction path using a Weigher and exposes cleanUp() for tests.
storage/inkless/src/main/java/io/aiven/inkless/config/InklessConfig.java Defines the new consume.cache.max.bytes configuration and accessor.
storage/inkless/src/main/java/io/aiven/inkless/common/SharedState.java Wires cacheMaxBytes() into CaffeineCache construction.
storage/inkless/src/test/java/io/aiven/inkless/cache/CaffeineCacheTest.java New unit tests validating count- vs bytes-based eviction selection.
storage/inkless/src/test/java/io/aiven/inkless/config/InklessConfigTest.java Adds coverage for parsing/defaults/range validation of consume.cache.max.bytes.
storage/inkless/src/test/java/io/aiven/inkless/consume/FetchPlannerTest.java Updates CaffeineCache constructor calls to include the new bytes parameter.
docs/inkless/configs.rst Documents the new config key in the generated config docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add a new limiting configuration for cache sizing based on bytes instead
of entries.

Historically, previous caching library only supported sizing based on
entries. With Caffeine, sizing can now be defined by both entries and
max bytes using weigher.

When bytes limit is configured, weight-based eviction takes precedence
over count-based eviction. Caffeine does not support both simultaneously.
@jeqo jeqo force-pushed the jeqo/add-cache-bytes-limit-v2 branch from 7d80d80 to 3dbe698 Compare March 18, 2026 16:23
@jeqo jeqo marked this pull request as ready for review March 19, 2026 11:13
@jeqo jeqo merged commit cbfdff5 into main Mar 20, 2026
7 checks passed
@jeqo jeqo deleted the jeqo/add-cache-bytes-limit-v2 branch March 20, 2026 13:49
AnatolyPopov pushed a commit that referenced this pull request Mar 23, 2026
Add a new limiting configuration for cache sizing based on bytes instead
of entries.

Historically, previous caching library only supported sizing based on
entries. With Caffeine, sizing can now be defined by both entries and
max bytes using weigher.

When bytes limit is configured, weight-based eviction takes precedence
over count-based eviction. Caffeine does not support both simultaneously.

(cherry picked from commit cbfdff5)
jeqo added a commit that referenced this pull request Mar 23, 2026
Add a new limiting configuration for cache sizing based on bytes instead
of entries.

Historically, previous caching library only supported sizing based on
entries. With Caffeine, sizing can now be defined by both entries and
max bytes using weigher.

When bytes limit is configured, weight-based eviction takes precedence
over count-based eviction. Caffeine does not support both simultaneously.
jeqo added a commit that referenced this pull request Mar 23, 2026
Add a new limiting configuration for cache sizing based on bytes instead
of entries.

Historically, previous caching library only supported sizing based on
entries. With Caffeine, sizing can now be defined by both entries and
max bytes using weigher.

When bytes limit is configured, weight-based eviction takes precedence
over count-based eviction. Caffeine does not support both simultaneously.

(cherry picked from commit cbfdff5)
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