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

feat: Replace tz implementation from date with LLVM implementation #12422

Closed

Conversation

kevinwilfong
Copy link
Contributor

@kevinwilfong kevinwilfong commented Feb 21, 2025

Summary:
We currently use (slightly modified versions of) the tz.h/tz.cpp (along with ios.h/tz_private.h) files
from https://github.com/HowardHinnant/date to handle time zone conversions. A version of this
API was voted into the C++20 standard. Since then further support/development of the library has
been limited.

In particular it has a known limitation when daylight savings time rules used to determine transition
dates/times into the distant future are not supported in the library. This means Velox only supports
datetimes in time zones with DST up to the year 2037.

LLVM has an implementation of the new C++20 standard that is heavily based on that in the date
repo. It is not finished yet, and still considered "experimental" but it already provides some notable
improvements, e.g. support of DST into the distant future.

In order to take advantage of this and prepare us to adopt the C++20 library once it's available,
I've replace the tz.h/tz.cpp files with the set of files from LLVM that implement the API in
std::chrono in C++20.

This first PR simply pulls in the files from LLVM, removes some libcpp specific macros, replaces C++20-isms with C++17 equivalents, and updates namespaces and includes. The only meaningful code change in these files is I ported the logic to find the necessary zoneinfo files/directories on Mac from the date library as LLVM only supports finding them in Linux systems.

Beyond that I updated includes/namspaces in the rest of the velox codebase to use the new files. I commented out/modified some code (mostly tests) that are broken by the change, in case I include a comment indicating the follow up PR that addresses the issue and restores the code. I will land these as a single stack, I did this to simplify the review process and ensure each PR individually builds and passes tests.

Note that we still use the date.h and ios_week.h files from https://github.com/HowardHinnant/date
for two reasons:

  1. These were not fully adopted by the C++20 standard and we use some of the types that did not
    make it into the standard.
  2. There's some discussion of supporting a range of years beyond what std::year supports to
    match Presto Java's behavior, which will require forking these anyway.

Differential Revision: D69997637

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 21, 2025
Copy link

netlify bot commented Feb 21, 2025

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 7940436
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/67cf23b7bf3d800008411299

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

@kevinwilfong kevinwilfong marked this pull request as draft February 21, 2025 18:56
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 21, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 21, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 21, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 21, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 25, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 26, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 27, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 27, 2025
…/4] (facebookincubator#12422)

Summary:
Pull Request resolved: facebookincubator#12422

TODO

Differential Revision: D69997637
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 28, 2025
…/4] (facebookincubator#12422)

Summary:
Pull Request resolved: facebookincubator#12422

TODO

Differential Revision: D69997637
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Feb 28, 2025
…/4] (facebookincubator#12422)

Summary:
Pull Request resolved: facebookincubator#12422

TODO

Differential Revision: D69997637
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Mar 5, 2025
…/4] (facebookincubator#12422)

Summary:
Pull Request resolved: facebookincubator#12422

We currently use (slightly modified versions of) the tz.h/tz.cpp (along with ios.h/tz_private.h) files
from https://github.com/HowardHinnant/date to handle time zone conversions.  A version of this
API was voted into the C++20 standard. Since then further support/development of the library has
been limited.

In particular it has a known limitation when daylight savings time rules used to determine transition
dates/times into the distant future are not supported in the library. This means Velox only supports
datetimes in time zones with DST up to the year 2037.

LLVM has an implementation of the new C++20 standard that is heavily based on that in the date
repo. It is not finished yet, and still considered "experimental" but it already provides some notable
improvements, e.g. support of DST into the distant future.

In order to take advantage of this and prepare us to adopt the C++20 library once it's available,
I've replace the tz.h/tz.cpp files with the set of files from LLVM that implement the API in
std::chrono in C++20.

This first PR simply pulls in the files from LLVM, removes some libcpp specific macros, replaces C++20-isms with C++17 equivalents, and updates namespaces and includes.  The only meaningful code change in these files is I ported the logic to find the necessary zoneinfo files/directories on Mac from the date library as LLVM only supports finding them in Linux systems.

Beyond that I updated includes/namspaces in the rest of the velox codebase to use the new files.  I commented out/modified some code (mostly tests) that are broken by the change, in case I include a comment indicating the follow up PR that addresses the issue and restores the code.  I will land these as a single stack, I did this to simplify the review process and ensure each PR individually builds and passes tests.

Note that we still use the date.h and ios_week.h files from https://github.com/HowardHinnant/date
for two reasons:
1) These were not fully adopted by the C++20 standard and we use some of the types that did not
make it into the standard.
2) There's some discussion of supporting a range of years beyond what std::year supports to
match Presto Java's behavior, which will require forking these anyway.

Differential Revision: D69997637
@kevinwilfong kevinwilfong marked this pull request as ready for review March 5, 2025 19:30
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Mar 5, 2025
…/4] (facebookincubator#12422)

Summary:
Pull Request resolved: facebookincubator#12422

We currently use (slightly modified versions of) the tz.h/tz.cpp (along with ios.h/tz_private.h) files
from https://github.com/HowardHinnant/date to handle time zone conversions.  A version of this
API was voted into the C++20 standard. Since then further support/development of the library has
been limited.

In particular it has a known limitation when daylight savings time rules used to determine transition
dates/times into the distant future are not supported in the library. This means Velox only supports
datetimes in time zones with DST up to the year 2037.

LLVM has an implementation of the new C++20 standard that is heavily based on that in the date
repo. It is not finished yet, and still considered "experimental" but it already provides some notable
improvements, e.g. support of DST into the distant future.

In order to take advantage of this and prepare us to adopt the C++20 library once it's available,
I've replace the tz.h/tz.cpp files with the set of files from LLVM that implement the API in
std::chrono in C++20.

This first PR simply pulls in the files from LLVM, removes some libcpp specific macros, replaces C++20-isms with C++17 equivalents, and updates namespaces and includes.  The only meaningful code change in these files is I ported the logic to find the necessary zoneinfo files/directories on Mac from the date library as LLVM only supports finding them in Linux systems.

Beyond that I updated includes/namspaces in the rest of the velox codebase to use the new files.  I commented out/modified some code (mostly tests) that are broken by the change, in case I include a comment indicating the follow up PR that addresses the issue and restores the code.  I will land these as a single stack, I did this to simplify the review process and ensure each PR individually builds and passes tests.

Note that we still use the date.h and ios_week.h files from https://github.com/HowardHinnant/date
for two reasons:
1) These were not fully adopted by the C++20 standard and we use some of the types that did not
make it into the standard.
2) There's some discussion of supporting a range of years beyond what std::year supports to
match Presto Java's behavior, which will require forking these anyway.

Differential Revision: D69997637
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Mar 5, 2025
…/4] (facebookincubator#12422)

Summary:
Pull Request resolved: facebookincubator#12422

We currently use (slightly modified versions of) the tz.h/tz.cpp (along with ios.h/tz_private.h) files
from https://github.com/HowardHinnant/date to handle time zone conversions.  A version of this
API was voted into the C++20 standard. Since then further support/development of the library has
been limited.

In particular it has a known limitation when daylight savings time rules used to determine transition
dates/times into the distant future are not supported in the library. This means Velox only supports
datetimes in time zones with DST up to the year 2037.

LLVM has an implementation of the new C++20 standard that is heavily based on that in the date
repo. It is not finished yet, and still considered "experimental" but it already provides some notable
improvements, e.g. support of DST into the distant future.

In order to take advantage of this and prepare us to adopt the C++20 library once it's available,
I've replace the tz.h/tz.cpp files with the set of files from LLVM that implement the API in
std::chrono in C++20.

This first PR simply pulls in the files from LLVM, removes some libcpp specific macros, replaces C++20-isms with C++17 equivalents, and updates namespaces and includes.  The only meaningful code change in these files is I ported the logic to find the necessary zoneinfo files/directories on Mac from the date library as LLVM only supports finding them in Linux systems.

Beyond that I updated includes/namspaces in the rest of the velox codebase to use the new files.  I commented out/modified some code (mostly tests) that are broken by the change, in case I include a comment indicating the follow up PR that addresses the issue and restores the code.  I will land these as a single stack, I did this to simplify the review process and ensure each PR individually builds and passes tests.

Note that we still use the date.h and ios_week.h files from https://github.com/HowardHinnant/date
for two reasons:
1) These were not fully adopted by the C++20 standard and we use some of the types that did not
make it into the standard.
2) There's some discussion of supporting a range of years beyond what std::year supports to
match Presto Java's behavior, which will require forking these anyway.

Differential Revision: D69997637
…/4] (facebookincubator#12422)

Summary:
Pull Request resolved: facebookincubator#12422

We currently use (slightly modified versions of) the tz.h/tz.cpp (along with ios.h/tz_private.h) files
from https://github.com/HowardHinnant/date to handle time zone conversions.  A version of this
API was voted into the C++20 standard. Since then further support/development of the library has
been limited.

In particular it has a known limitation when daylight savings time rules used to determine transition
dates/times into the distant future are not supported in the library. This means Velox only supports
datetimes in time zones with DST up to the year 2037.

LLVM has an implementation of the new C++20 standard that is heavily based on that in the date
repo. It is not finished yet, and still considered "experimental" but it already provides some notable
improvements, e.g. support of DST into the distant future.

In order to take advantage of this and prepare us to adopt the C++20 library once it's available,
I've replace the tz.h/tz.cpp files with the set of files from LLVM that implement the API in
std::chrono in C++20.

This first PR simply pulls in the files from LLVM, removes some libcpp specific macros, replaces C++20-isms with C++17 equivalents, and updates namespaces and includes.  The only meaningful code change in these files is I ported the logic to find the necessary zoneinfo files/directories on Mac from the date library as LLVM only supports finding them in Linux systems.

Beyond that I updated includes/namspaces in the rest of the velox codebase to use the new files.  I commented out/modified some code (mostly tests) that are broken by the change, in case I include a comment indicating the follow up PR that addresses the issue and restores the code.  I will land these as a single stack, I did this to simplify the review process and ensure each PR individually builds and passes tests.

Note that we still use the date.h and ios_week.h files from https://github.com/HowardHinnant/date
for two reasons:
1) These were not fully adopted by the C++20 standard and we use some of the types that did not
make it into the standard.
2) There's some discussion of supporting a range of years beyond what std::year supports to
match Presto Java's behavior, which will require forking these anyway.

Reviewed By: kgpai, yuandagits

Differential Revision: D69997637
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69997637

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 16e4460.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants