You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
update_requested_specs_in_json was round-tripping conda-meta JSON through serde_json::Value, which uses BTreeMap internally (no preserve_order feature in this crate), so every rewrite came back with alphabetically-sorted keys.
That's a problem because MinimalPrefixRecord's parser stops early once it has seen both files and requested_specs. After the rewrite, sha256 ('s') ends up after requested_specs ('r') alphabetically and is never parsed. On the next pixi install, MinimalPrefixRecord.sha256 is None while RepoDataRecord.sha256 is Some — describe_same_content sees a mismatch and forces a full PrefixRecord reload, permanently defeating the fast-path optimization. This repeats on every subsequent run.
..., sha256, ..., files, ..., requested_specs
^^^^^^ read correctly before early termination
Fix: replace the serde_json::Value round-trip with PrefixRecord::from_path + write_to_path. Serde serializes in struct-field order so key ordering is stable, and write_to_path uses an atomic temp-file rename — also fixing a secondary risk of file corruption on process kill.
Fixes #NA
How Has This Been Tested?
Manually verified by:
Running pixi install on an environment with numpy/requests
Confirming the rewritten conda-meta JSONs now preserve original key order (sha256 appears before requested_specs)
Running pixi install a second time and confirming no full PrefixRecord reload is triggered (fast path holds)
AI Disclosure
This PR contains AI-generated content.
I have tested any AI-generated content in my PR.
I take responsibility for any AI-generated content in my PR.
Tools: Chatgpt ,Claude
Checklist:
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation
I have added sufficient tests to cover my changes.
The main issue is preserve_order uses insertion order, so for files that don't already have requested_specs, it'd still get appended at the end (same problem). It also pulls in indexmap as a dep and since serde_json is workspace-level, it'd silently flip behavior for every crate using it, felt like too broad a side effect for a targeted fix.
Going through the actual PrefixRecord struct felt cleaner to me, serde handles the field order automatically and we also get the atomic write from write_to_path for free, which the old approach was missing. Fewer moving parts overall.
That said, happy to hear your thoughts if you think preserve_order is still the better path here!🙂
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
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.
Description
update_requested_specs_in_jsonwas round-tripping conda-meta JSON throughserde_json::Value, which usesBTreeMapinternally (nopreserve_orderfeature in this crate), so every rewrite came back with alphabetically-sorted keys.That's a problem because
MinimalPrefixRecord's parser stops early once it has seen bothfilesandrequested_specs. After the rewrite,sha256('s') ends up afterrequested_specs('r') alphabetically and is never parsed. On the nextpixi install,MinimalPrefixRecord.sha256isNonewhileRepoDataRecord.sha256isSome—describe_same_contentsees a mismatch and forces a fullPrefixRecordreload, permanently defeating the fast-path optimization. This repeats on every subsequent run.Before (alphabetical key order after rewrite):
After (struct-field order preserved):
Fix: replace the
serde_json::Valueround-trip withPrefixRecord::from_path+write_to_path. Serde serializes in struct-field order so key ordering is stable, andwrite_to_pathuses an atomic temp-file rename — also fixing a secondary risk of file corruption on process kill.Fixes #NA
How Has This Been Tested?
Manually verified by:
pixi installon an environment with numpy/requestssha256appears beforerequested_specs)pixi installa second time and confirming no fullPrefixRecordreload is triggered (fast path holds)AI Disclosure
Tools: Chatgpt ,Claude
Checklist: