Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid loading DB for commands where it's not necessary. #8783

Merged
merged 22 commits into from
Feb 3, 2025

Conversation

nicktobey
Copy link
Contributor

This PR avoids loading dolt DBs at startup, instead waiting for either DoltEnv.ReloadDB or MultiRepoEnv.ReloadDBs to be called.

Based on the specific subcommand being run:

  • MultiRepoEnv.ReloadDBs is called prior to command execution if the command will always need DB access.
  • Commands that conditionally require a DB can choose whether to call DoltEnv.ReloadDB
  • Commands that never need the DB will never load it.

Commands that make use of CliContext don't need to load the DB, as the underlying query engine will load the DB if it needs database access. As a result, commands that are implemented purely in terms of the CliContext will load the DB when Dolt is runnning an embedded SQL engine, and will skip loading the DB when Dolt is connecting to a running server.

@nicktobey nicktobey force-pushed the nicktobey/lazy-load branch from 9358401 to 5355928 Compare January 22, 2025 22:54
@nicktobey nicktobey requested a review from macneale4 January 22, 2025 22:54
@coffeegoddd
Copy link
Contributor

@nicktobey DOLT

comparing_percentages
100.000000 to 100.000000
version result total
5355928 ok 5937457
version total_tests
5355928 5937457
correctness_percentage
100.0

go/libraries/doltcore/env/environment.go Outdated Show resolved Hide resolved
go/cmd/dolt/dolt.go Outdated Show resolved Hide resolved
go/cmd/dolt/commands/branch.go Outdated Show resolved Hide resolved
go/cmd/dolt/commands/show.go Outdated Show resolved Hide resolved
go/cmd/dolt/dolt.go Outdated Show resolved Hide resolved
Copy link
Contributor

@macneale4 macneale4 left a comment

Choose a reason for hiding this comment

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

still a few questions. Overall, this is definitely an improvement.

Also, looks like all the tests are failing. Maybe because of the infinite recurssion?

go/libraries/doltcore/env/environment.go Outdated Show resolved Hide resolved
go/libraries/doltcore/env/multi_repo_env.go Outdated Show resolved Hide resolved
go/libraries/doltcore/merge/schema_integration_test.go Outdated Show resolved Hide resolved
go/libraries/doltcore/migrate/integration_test.go Outdated Show resolved Hide resolved
go/libraries/doltcore/sqle/dsess/session.go Outdated Show resolved Hide resolved
@coffeegoddd
Copy link
Contributor

@nicktobey DOLT

comparing_percentages
100.000000 to 100.000000
version result total
f78cc0d ok 5937457
version total_tests
f78cc0d 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Contributor

@nicktobey DOLT

comparing_percentages
100.000000 to 100.000000
version result total
8b10e7f ok 5937457
version total_tests
8b10e7f 5937457
correctness_percentage
100.0

Copy link
Contributor

@macneale4 macneale4 left a comment

Choose a reason for hiding this comment

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

Only remaining concern is that we'll have multiple threads initializing the DB at the same time. Convince me that's not the case, or guard against it.

go/libraries/doltcore/env/environment.go Outdated Show resolved Hide resolved
go/libraries/doltcore/sqle/testutil.go Show resolved Hide resolved
@coffeegoddd
Copy link
Contributor

@nicktobey DOLT

comparing_percentages
100.000000 to 100.000000
version result total
d27b998 ok 5937457
version total_tests
d27b998 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Contributor

@nicktobey DOLT

comparing_percentages
100.000000 to 100.000000
version result total
b1aa361 ok 5937457
version total_tests
b1aa361 5937457
correctness_percentage
100.0

@macneale4 macneale4 self-requested a review February 3, 2025 18:15
@coffeegoddd
Copy link
Contributor

@nicktobey DOLT

comparing_percentages
100.000000 to 100.000000
version result total
2911085 ok 5937457
version total_tests
2911085 5937457
correctness_percentage
100.0

Copy link
Contributor

@macneale4 macneale4 left a comment

Choose a reason for hiding this comment

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

LGTM! There is a Doltgres integration test failing which you should fix before you ship it.

@nicktobey nicktobey merged commit b4b6d71 into main Feb 3, 2025
20 of 21 checks passed
@nicktobey nicktobey deleted the nicktobey/lazy-load branch February 3, 2025 23:03
Copy link

github-actions bot commented Feb 4, 2025

@coffeegoddd DOLT

test_name detail row_cnt sorted mysql_time sql_mult cli_mult
batching LOAD DATA 10000 1 0.06 1.67
batching batch sql 10000 1 0.08 1.5
batching by line sql 10000 1 0.08 1.5
blob 1 blob 200000 1 0.89 3.99 4.71
blob 2 blobs 200000 1 0.89 4.43 4.93
blob no blob 200000 1 0.92 2.4 2.82
col type datetime 200000 1 0.85 2.39 2.68
col type varchar 200000 1 0.74 3.16 3.59
config width 2 cols 200000 1 0.83 2.41 2.78
config width 32 cols 200000 1 1.87 2.07 2.77
config width 8 cols 200000 1 1 2.35 2.7
pk type float 200000 1 0.9 2.27 3.01
pk type int 200000 1 0.82 2.45 2.72
pk type varchar 200000 1 3.01 0.86 0.91
row count 1.6mm 1600000 1 5.73 2.92 2.92
row count 400k 400000 1 1.49 2.77 2.88
row count 800k 800000 1 2.94 2.82 2.85
secondary index four index 200000 1 3.76 1.33 1.23
secondary index no secondary 200000 1 0.92 2.43 2.82
secondary index one index 200000 1 1.18 2.35 2.42
secondary index two index 200000 1 2.06 1.7 1.8
sorting shuffled 1mm 1000000 0 4.93 2.9 2.77
sorting sorted 1mm 1000000 1 4.81 2.96 2.84

Copy link

github-actions bot commented Feb 4, 2025

@coffeegoddd DOLT

name detail mean_mult
dolt_blame_basic system table 1.22
dolt_blame_commit_filter system table 2.98
dolt_commit_ancestors_commit_filter system table 0.66
dolt_commits_commit_filter system table 1.05
dolt_diff_log_join_from_commit system table 2.77
dolt_diff_log_join_to_commit system table 2.74
dolt_diff_table_from_commit_filter system table 1.2
dolt_diff_table_to_commit_filter system table 1.18
dolt_diffs_commit_filter system table 1.06
dolt_history_commit_filter system table 1.37
dolt_log_commit_filter system table 1.05

Copy link

github-actions bot commented Feb 4, 2025

@coffeegoddd DOLT

name add_cnt delete_cnt update_cnt latency
adds_only 60000 0 0 1.12
adds_updates_deletes 60000 60000 60000 4.45
deletes_only 0 60000 0 2.41
updates_only 0 0 60000 2.99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants