Skip to content

Conversation

@poodlewars
Copy link
Collaborator

The setup_cache creates two libraries, one with the tail of the version chain deleted. We used to write both libraries with Arctic APIs.

I change it here to write most of the versions of one library with Arctic APIs, up to the point where we want to delete the symbol, then copy that state with shutil.copytree. This roughly halves the amount of time spent in setup_cache, from ~17 minutes down to ~8 on my machine.

I also change the benchmarks to control their number of runs with sample_time rather than number. The high number was introduced for some benchmarks that run very quickly and so are noisy, but doing that across all the benchmarks isn't suitable as others are slow and stable.

@poodlewars poodlewars added patch Small change, should increase patch version no-release-notes This PR shouldn't be added to release notes. labels Dec 31, 2025
@maxim-morozov
Copy link
Collaborator

Nice idea to speed it up.


adb._ext.unset_config_int("VersionMap.ReloadInterval")
shutil.rmtree("version_chain_deleted", ignore_errors=True)
shutil.copytree("version_chain", "version_chain_tail_deleted")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We're removing version_chain_deleted but copying to version_chain_tail_deleted.

Maybe add constants for directory names so it's harder to make such error:

DIR_UNDELETED = "version_chain"
DIR_TAIL_DELETED = "version_chain_tail_deleted"
CONNECTION_STRING_UNDELETED = f"lmdb://{DIR_UNDELETED}"
CONNECTION_STRING_TAIL_DELETED = f"lmdb://{DIR_TAIL_DELETED}"

assert len(lib.list_versions(symbol)) == num_versions - deletion_point

adb._ext.unset_config_int("VersionMap.ReloadInterval")
print("IterateVersionChain: Setup cache took (s) :", time.time() - start_time, file=sys.stderr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: We're printing the time two times. Here and in setup_cache. Maybe just keep one?

if deleted:
ac = Arctic(IterateVersionChain.CONNECTION_STRING_UNDELETED)
else:
ac = Arctic(IterateVersionChain.CONNECTION_STRING_TAIL_DELETED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe if and else should be the other way round?

assert len(lib.list_versions(symbol)) == num_versions - deletion_point

adb._ext.unset_config_int("VersionMap.ReloadInterval")
print("IterateVersionChain: Setup cache took (s) :", time.time() - start_time, file=sys.stderr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Also remove the corresponding start time

@poodlewars poodlewars merged commit d3bc062 into master Jan 6, 2026
218 checks passed
@poodlewars poodlewars deleted the aseaton/asv/version-chain-slowness branch January 6, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release-notes This PR shouldn't be added to release notes. patch Small change, should increase patch version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants