Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Refactor Tasks to use builders. Do not replicate startup DDL. #1594

Closed
wants to merge 18 commits into from

Conversation

lmwnshn
Copy link
Contributor

@lmwnshn lmwnshn commented May 27, 2021

Heading

Refactor Tasks to use builders. Do not replicate startup DDL.

Description

Fix #1576 per current understanding, we may decide in the future to add startup SQL that does get replicated, but right now everything is internal tables. Also create everything in the default noisepage database instead of in database 0 aka INVALID_DB_OID.

Mainly going from constructors like this

    task_manager->AddTask(std::make_unique<task::TaskDML>(
        catalog::INVALID_DATABASE_OID, "SELECT * FROM noisepage_forecast_frequencies",
        std::make_unique<optimizer::TrivialCostModel>(), std::move(params), std::move(param_types), freq_check, nullptr,
        settings, false, true, std::nullopt, common::ManagedPointer(&sync)));

to this

    task_manager->AddTask(task::TaskDML::Builder()
                              .SetDatabaseOid(task_manager->GetDatabaseOid())
                              .SetQueryText("SELECT * FROM noisepage_forecast_frequencies")
                              .SetFuture(common::ManagedPointer(&sync))
                              .SetParameters(std::move(params))
                              .SetParameterTypes(std::move(param_types))
                              .SetTupleFn(std::move(freq_check))
                              .SetShouldSkipQueryCache(true)
                              .SetExecutionSettings(settings)
                              .Build());

Fell down a rabbit hole of making it easier to specify additional properties for tasks in the future.

  • Refactor TaskDDL and TaskDML to use builders.
  • Track default database OID in catalog, expose via GetDefaultDatabaseOid.
  • Refuse INVALID_DB_OID to force callers to do the right thing, i.e., explicitly specify what database they are interacting with.
  • Change TryLoadStartupDDL to fail loudly instead of silently.
  • Disable replication of TryLoadStartupDDL.
  • Add TransactionPolicy arg to QueryExecUtil::BeginTransaction.
  • Change a const unique_ptr<> & to a ManagedPointer.
  • Allow SetReplicationPolicy(DISABLE) if DurabilityPolicy is also DISABLE.
  • Nitpick at function docstrings in QueryExecUtil.
  • Question: what should DurabilityPolicy be for internal table tasks?
  • Found bug, see DurabilityPolicy::DISABLE doesn't seem to work. #1595.

Remaining tasks

Seeing if it passes CI. I am surprised replication tests did not fail sooner.

- Refactor TaskDDL and TaskDML to use builders.
- Track default database OID in catalog, expose via GetDefaultDatabaseOid.
- Refuse INVALID_DB_OID to force callers to do the right thing, i.e.,
  explicitly specify what database they are interacting with.
- Change TryLoadStartupDDL to fail loudly instead of silently.
- Disable replication of TryLoadStartupDDL.
@lmwnshn lmwnshn added in-progress This PR is being actively worked on and not ready to be reviewed or merged. Mark PRs with this. ready-for-ci Indicate that this build should be run through CI. labels May 27, 2021
@lmwnshn lmwnshn self-assigned this May 27, 2021
- Add TransactionPolicy arg to QueryExecUtil::BeginTransaction.
- Change a const unique_ptr<> & to a ManagedPointer.
- Allow SetReplicationPolicy(DISABLE) if DurabilityPolicy is also DISABLE.
- Nitpick at function docstrings in QueryExecUtil.
- Question: what should DurabilityPolicy be for internal table tasks?
- Found bug, see cmu-db#1595.
@noisepage-checks
Copy link

Performance Boost!

Nice job! This PR has increased the throughput of the system.

Could not find any performance results to compare for this commit.

1 similar comment
@noisepage-checks
Copy link

Performance Boost!

Nice job! This PR has increased the throughput of the system.

Could not find any performance results to compare for this commit.

@lmwnshn lmwnshn added ready-for-review This PR passes all checks and is ready to be reviewed. Mark PRs with this. and removed in-progress This PR is being actively worked on and not ready to be reviewed or merged. Mark PRs with this. labels Jun 4, 2021
@noisepage-checks
Copy link

Performance Boost!

Nice job! This PR has increased the throughput of the system.

Could not find any performance results to compare for this commit.

@noisepage-checks
Copy link

Major Decrease in Performance

STOP: this PR has a major negative performance impact

tps (%change) benchmark_type wal_device details
-0.74% tpcc RAM disk
Detailsmaster tps=22192.31, commit tps=22027.57, query_mode=extended, benchmark_type=tpcc, scale_factor=32.0000, terminals=32, client_time=60, weights={'Payment': 43, 'Delivery': 4, 'NewOrder': 45, 'StockLevel': 4, 'OrderStatus': 4}, wal_device=RAM disk, max_connection_threads=32
-2.9% tpcc None
Detailsmaster tps=29640.72, commit tps=28780.82, query_mode=extended, benchmark_type=tpcc, scale_factor=32.0000, terminals=32, client_time=60, weights={'Payment': 43, 'Delivery': 4, 'NewOrder': 45, 'StockLevel': 4, 'OrderStatus': 4}, wal_device=None, max_connection_threads=32
-2.15% tpcc HDD
Detailsmaster tps=21889.82, commit tps=21419.65, query_mode=extended, benchmark_type=tpcc, scale_factor=32.0000, terminals=32, client_time=60, weights={'Payment': 43, 'Delivery': 4, 'NewOrder': 45, 'StockLevel': 4, 'OrderStatus': 4}, wal_device=HDD, max_connection_threads=32
-1.45% tatp RAM disk
Detailsmaster tps=6430.86, commit tps=6337.63, query_mode=extended, benchmark_type=tatp, scale_factor=1.0000, terminals=16, client_time=60, weights={'GetAccessData': 35, 'UpdateLocation': 14, 'GetNewDestination': 10, 'GetSubscriberData': 35, 'DeleteCallForwarding': 2, 'InsertCallForwarding': 2, 'UpdateSubscriberData': 2}, wal_device=RAM disk, max_connection_threads=32
-7.7% tatp None
Detailsmaster tps=7417.62, commit tps=6846.65, query_mode=extended, benchmark_type=tatp, scale_factor=1.0000, terminals=16, client_time=60, weights={'GetAccessData': 35, 'UpdateLocation': 14, 'GetNewDestination': 10, 'GetSubscriberData': 35, 'DeleteCallForwarding': 2, 'InsertCallForwarding': 2, 'UpdateSubscriberData': 2}, wal_device=None, max_connection_threads=32
1.25% tatp HDD
Detailsmaster tps=6302.21, commit tps=6381.28, query_mode=extended, benchmark_type=tatp, scale_factor=1.0000, terminals=16, client_time=60, weights={'GetAccessData': 35, 'UpdateLocation': 14, 'GetNewDestination': 10, 'GetSubscriberData': 35, 'DeleteCallForwarding': 2, 'InsertCallForwarding': 2, 'UpdateSubscriberData': 2}, wal_device=HDD, max_connection_threads=32

@turingcompl33t turingcompl33t self-requested a review June 5, 2021 01:07
Copy link
Contributor

@turingcompl33t turingcompl33t left a comment

Choose a reason for hiding this comment

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

LGTM. Some interesting C++ required to implement a builder when using inheritance-based runtime polymorphism!

src/include/task/task.h Show resolved Hide resolved
src/include/task/task.h Show resolved Hide resolved
src/include/task/task.h Show resolved Hide resolved
src/main/db_main.cpp Show resolved Hide resolved
src/main/db_main.cpp Show resolved Hide resolved
src/self_driving/planning/pilot_util.cpp Outdated Show resolved Hide resolved
src/task/task.cpp Show resolved Hide resolved
src/task/task.cpp Show resolved Hide resolved
src/task/task.cpp Show resolved Hide resolved
src/task/task.cpp Show resolved Hide resolved
Copy link
Member

@linmagit linmagit left a comment

Choose a reason for hiding this comment

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

The refactoring looks great! Appreciate it, @lmwnshn! Just some small clarifications and comments. The main thing that I'm wondering though, is that have you tried running the internal query trace recording and the pilot with your refactor? Since we don't have tests for them in CI yet, the only way to make sure that they're not broken is to run them locally.

src/main/db_main.cpp Show resolved Hide resolved
src/self_driving/planning/pilot_util.cpp Outdated Show resolved Hide resolved
src/util/self_driving_recording_util.cpp Show resolved Hide resolved
@noisepage-checks
Copy link

Major Decrease in Performance

STOP: this PR has a major negative performance impact

tps (%change) benchmark_type wal_device details
-2.11% tpcc RAM disk
Detailsmaster tps=22501.62, commit tps=22027.57, query_mode=extended, benchmark_type=tpcc, scale_factor=32.0000, terminals=32, client_time=60, weights={'Payment': 43, 'Delivery': 4, 'NewOrder': 45, 'StockLevel': 4, 'OrderStatus': 4}, wal_device=RAM disk, max_connection_threads=32
-0.71% tpcc None
Detailsmaster tps=28985.3, commit tps=28780.82, query_mode=extended, benchmark_type=tpcc, scale_factor=32.0000, terminals=32, client_time=60, weights={'Payment': 43, 'Delivery': 4, 'NewOrder': 45, 'StockLevel': 4, 'OrderStatus': 4}, wal_device=None, max_connection_threads=32
-1.24% tpcc HDD
Detailsmaster tps=21689.03, commit tps=21419.65, query_mode=extended, benchmark_type=tpcc, scale_factor=32.0000, terminals=32, client_time=60, weights={'Payment': 43, 'Delivery': 4, 'NewOrder': 45, 'StockLevel': 4, 'OrderStatus': 4}, wal_device=HDD, max_connection_threads=32
-0.78% tatp RAM disk
Detailsmaster tps=6387.57, commit tps=6337.63, query_mode=extended, benchmark_type=tatp, scale_factor=1.0000, terminals=16, client_time=60, weights={'GetAccessData': 35, 'UpdateLocation': 14, 'GetNewDestination': 10, 'GetSubscriberData': 35, 'DeleteCallForwarding': 2, 'InsertCallForwarding': 2, 'UpdateSubscriberData': 2}, wal_device=RAM disk, max_connection_threads=32
-6.33% tatp None
Detailsmaster tps=7309.67, commit tps=6846.65, query_mode=extended, benchmark_type=tatp, scale_factor=1.0000, terminals=16, client_time=60, weights={'GetAccessData': 35, 'UpdateLocation': 14, 'GetNewDestination': 10, 'GetSubscriberData': 35, 'DeleteCallForwarding': 2, 'InsertCallForwarding': 2, 'UpdateSubscriberData': 2}, wal_device=None, max_connection_threads=32
3.45% tatp HDD
Detailsmaster tps=6168.58, commit tps=6381.28, query_mode=extended, benchmark_type=tatp, scale_factor=1.0000, terminals=16, client_time=60, weights={'GetAccessData': 35, 'UpdateLocation': 14, 'GetNewDestination': 10, 'GetSubscriberData': 35, 'DeleteCallForwarding': 2, 'InsertCallForwarding': 2, 'UpdateSubscriberData': 2}, wal_device=HDD, max_connection_threads=32

@noisepage-checks
Copy link

Performance Boost!

Nice job! This PR has increased the throughput of the system.

Could not find any performance results to compare for this commit.

@lmwnshn
Copy link
Contributor Author

lmwnshn commented Jun 8, 2021

Thanks for reviews! Going to call this blocked on #1566 as I hope to get that in.. for real.. in the near future..

Specifically, blocked on testing (though note that task manager test does work)

@lmwnshn lmwnshn added blocked This issue or pull request is in progress, but dependent on another task being completed first. ready-to-merge This PR is ready to be merged. Mark PRs with this. and removed ready-for-review This PR passes all checks and is ready to be reviewed. Mark PRs with this. labels Jun 8, 2021
@mbutrovich mbutrovich removed the ready-for-ci Indicate that this build should be run through CI. label Jul 16, 2021
@mbutrovich mbutrovich removed the ready-to-merge This PR is ready to be merged. Mark PRs with this. label Jul 27, 2021
@lmwnshn
Copy link
Contributor Author

lmwnshn commented Aug 10, 2021

While I would like this to get in, I guess this will not get in until we get the pilot in CI.

@lmwnshn lmwnshn closed this Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked This issue or pull request is in progress, but dependent on another task being completed first.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Startup SQL interactions with replication.
4 participants