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

Port TPL behavior for float literals. Change print behavior for REAL. #1586

Merged
merged 5 commits into from
May 23, 2021

Conversation

lmwnshn
Copy link
Contributor

@lmwnshn lmwnshn commented May 20, 2021

Heading

Port TPL behavior for float literals. Change print behavior for REAL.

Description

@tpan496 found a bug where values outside of float range were treated as 0 or inf.

We were casting doubles down into floats in the bytecode_generator.
Something we missed when porting TPL2 and making the "64-bit instead of 32-bit by default" change.

It's another one of those "fixed in TPL" things so I went and yoinked that code.

This also changes the default behavior of printing real values, e.g., SELECT 0.3333;.

  • A. The old behavior of to_string is to always print to 6 decimal places.
    • Failure case: prints 0.333333333 as 0.333333.
  • B. The fmt lib will print as many decimal places as are available, but will not be able to print trailing 0s.
    • Failure case: prints 0.333000 as 0.333.
  • C. If we want to print trailing 0s, we can use stringstream and std::fixed.
    • Failure case: prints 0.333 as 0.333000.

In general, there is no good solution here. Given a REAL, we don't know if it was float or double initially. If precision matters, revive the decimal PR.
Going with B. for now.

I hope this does not blow up float SQL-based tests...

The old behavior of to_string is to always print to 6 decimal places.
Failure case: prints 0.333333333 as 0.333333.
The fmt lib will print as many decimal places as are available, but
will not be able to print trailing 0s.
Failure case: prints 0.333000 as 0.333.
If we want to print trailing 0s, we can use stringstream and std::fixed.
Failure case: prints 0.333 as 0.333000.

In general, there is no good solution here.
If precision matters, revive the decimal PR.
@lmwnshn lmwnshn added bug Something isn't working (correctness). Mark issues with this. 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 20, 2021
@lmwnshn lmwnshn self-assigned this May 20, 2021
@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.61% tpcc RAM disk
Detailsmaster tps=22554.9, commit tps=21967.0, 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
1.13% tpcc None
Detailsmaster tps=28904.05, commit tps=29229.8, 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.18% tpcc HDD
Detailsmaster tps=21953.18, commit tps=21474.99, 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
-2.23% tatp RAM disk
Detailsmaster tps=6500.06, commit tps=6355.35, 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.35% tatp None
Detailsmaster tps=7421.06, commit tps=6875.95, 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.49% tatp HDD
Detailsmaster tps=6446.34, commit tps=6542.3, 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

@codecov
Copy link

codecov bot commented May 22, 2021

Codecov Report

Merging #1586 (b3d8fc1) into master (7f83ef8) will increase coverage by 0.41%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1586      +/-   ##
==========================================
+ Coverage   81.32%   81.73%   +0.41%     
==========================================
  Files         706      739      +33     
  Lines       49981    52045    +2064     
==========================================
+ Hits        40645    42541    +1896     
- Misses       9336     9504     +168     
Impacted Files Coverage Δ
src/execution/vm/bytecode_generator.cpp 84.20% <75.00%> (-0.03%) ⬇️
src/network/postgres/postgres_packet_writer.cpp 75.87% <100.00%> (ø)
src/network/network_io_wrapper.cpp 82.25% <0.00%> (-3.23%) ⬇️
src/include/storage/sql_table.h 97.67% <0.00%> (-2.33%) ⬇️
src/execution/sema/sema_decl.cpp 79.24% <0.00%> (-1.89%) ⬇️
src/storage/data_table.cpp 97.15% <0.00%> (-1.14%) ⬇️
src/include/catalog/index_schema.h 95.96% <0.00%> (-0.79%) ⬇️
src/execution/sema/sema_expr.cpp 76.13% <0.00%> (-0.57%) ⬇️
src/execution/sql/sorter.cpp 96.73% <0.00%> (-0.55%) ⬇️
src/execution/compiler/codegen.cpp 87.48% <0.00%> (-0.24%) ⬇️
... and 50 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f83ef8...b3d8fc1. Read the comment docs.

@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 May 23, 2021
@lmwnshn lmwnshn requested a review from tpan496 May 23, 2021 02:56
Copy link
Contributor

@tpan496 tpan496 left a comment

Choose a reason for hiding this comment

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

LGTM. Should we be worried about the performance guard?

@lmwnshn lmwnshn merged commit 33bc907 into cmu-db:master May 23, 2021
@lmwnshn lmwnshn deleted the double_fix branch May 23, 2021 06:56
@lmwnshn
Copy link
Contributor Author

lmwnshn commented May 23, 2021

Nah, that thing is super noisy.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working (correctness). Mark issues with this. ready-for-ci Indicate that this build should be run through CI. ready-for-review This PR passes all checks and is ready to be reviewed. Mark PRs with this.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants