lablup / lablup/mlxcel

refactor(server): hoist the duplicated INITIAL_HASH_CAPACITY_LIMIT into store_budget

Open Beginner friendly
#1,665 0 comments 0 reactions 0 assignees View on GitHub
priority:low status:ready type:refactor
Dominant language
Rust
Stars
467
Forks
54
Avg merge
4h 25m
Merged PRs (30d)
310

Description

## Summary

`const INITIAL_HASH_CAPACITY_LIMIT: usize = 4096;` is declared verbatim in both bounded server stores, which already share a helper module built for exactly this kind of thing. Move it to the shared module.

## Background

The two bounded stores each keep their own copy of the constant and use it identically to cap the initial `HashMap` capacity. Both already import from `src/server/store_budget.rs`, whose module docstring reads "Shared helpers for bounded in-memory server stores", so that is the natural home for the constant.

## Proposed Solution

Move the constant into `store_budget.rs` and import it from both stores. No behavior change; the compiler verifies the result.

## Implementation Notes

- `src/server/conversation_store.rs:36` and `src/server/responses_store.rs:50` declare the identical constant, used at `conversation_store.rs:71` and `responses_store.rs:81` respectively (`HashMap::with_capacity(max_entries.min(INITIAL_HASH_CAPACITY_LIMIT))`).
- Both stores already import `LruKey` and `serialized_json_len_saturating` from `store_budget`, so adding the constant to the same import is a small change.

## Acceptance Criteria

- [ ] One definition of the constant remains, in the shared module
- [ ] Both stores compile against it unchanged

---

## Original Suggestion

### Title: refactor(server): hoist the duplicated INITIAL_HASH_CAPACITY_LIMIT into store_budget

`const INITIAL_HASH_CAPACITY_LIMIT: usize = 4096;` is declared verbatim in both bounded server stores, which already share a helper module built for exactly this kind of thing.

## Evidence

- `src/server/conversation_store.rs:36` and `src/server/responses_store.rs:50` — identical constant, used identically at lines 71 and 81 respectively
- Both stores already import from `src/server/store_budget.rs`, whose module docstring reads "Shared helpers for bounded in-memory server stores"

## Suggested fix

Move the constant into `store_budget.rs` and import it from both stores. Three-line change, no behavior change, compiler-verified.

## Acceptance criteria

- [ ] One definition of the constant remains, in the shared module
- [ ] Both stores compile against it unchanged

Contributor guide

Open the contributing guide

Research direction

Start with src/server/store_budget.rs, then inspect the duplicate declarations and imports in src/server/conversation_store.rs and src/server/responses_store.rs. Move the shared constant there and update both stores to use it unchanged. Run the compiler to verify both stores compile and confirm only one definition remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Refactor
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
92/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.