Stabilize EDA filter serialization for improved caching#1625
Open
Stabilize EDA filter serialization for improved caching#1625
Conversation
EDA computation results are cached on the backend based on a hash of their configuration JSON. Set-type filter values (stringSet, numberSet, dateSet, multiFilter subFilters) were stored in user click-order, causing cache misses when different users selected the same values in a different order. Similarly, react-query client-side cache keys were order-sensitive. Changes: - Add sortFilters() utility that sorts the value arrays inside each set-type filter and sorts the filters array by entityId/variableId/type - Wrap setFilters in useAnalysisState to normalise on every update (covers client-side react-query keys and persisted analysis state) - Sort filters at the ComputeClient boundary (postJobStatus and getComputedVariableMetadata) as a safety net for analyses loaded from storage that haven't been re-saved yet - Sort groupA/groupB LabeledRange arrays by label in both differentialExpression and differentialabundance plugins, including the swap-groups handler https://claude.ai/code/session_01RF8FbzBHq9ownjsqLrV81X
bobular
commented
Feb 27, 2026
Member
Author
bobular
left a comment
There was a problem hiding this comment.
Looks good to me. Will test of course.
Wonder if a console warning should alert the developer to future filter types that aren't handled in the sort function (switch... default)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves cache hit rates by ensuring filters are serialized deterministically. Filter value arrays are now sorted consistently, and the filters array itself is sorted by entityId, variableId, and type. This stabilizes JSON representations sent to backend endpoints and react-query serialized keys on the client.
Key Changes
sortFilters(): Sorts value arrays within set-type filters (stringSet, numberSet, dateSet) and the filters array itself. Handles nested subFilters in multiFilter types while leaving range filters unchanged.useAnalysisStatehook: Wrapped thesetFilterssetter to automatically applysortFilters()to all filter updates, ensuring consistency throughout the analysis state management.ComputeClient: AddedsortComputeSpecFilters()helper to sort filters before sending compute requests to the backend, stabilizing the hash of configuration JSON for improved backend caching.differentialExpression.tsxanddifferentialabundance.tsxto sort group value options when selected and when swapping groups, ensuring deterministic ordering in the UI state.Implementation Details
sortFilters()function returns a new array without mutating the input, following functional programming principles.localeCompare) for string fields and numeric comparison for number fields.https://claude.ai/code/session_01RF8FbzBHq9ownjsqLrV81X