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

[improvement](function) add timezone cache for convert_tz #14616

Merged
merged 3 commits into from
Nov 29, 2022

Conversation

mrhhsg
Copy link
Member

@mrhhsg mrhhsg commented Nov 27, 2022

Proposed changes

cctz::fixed_time_zone will lock&unlock the mutex in each call, this is a non-negligible performance cost.
This PR adds a map to cache the timezone to avoid finding the same timezone repeatedly.

Problem summary

Describe your changes.

Checklist(Required)

  1. Does it affect the original behavior:
    • Yes
    • No
    • I don't know
  2. Has unit tests been added:
    • Yes
    • No
    • No Need
  3. Has document been added or modified:
    • Yes
    • No
    • No Need
  4. Does it need to update dependencies:
    • Yes
    • No
  5. Are there any changes that cannot be rolled back:
    • Yes (If Yes, please explain WHY)
    • No

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@github-actions github-actions bot added area/sql/function Issues or PRs related to the SQL functions area/vectorization labels Nov 27, 2022
@hello-stephen
Copy link
Contributor

hello-stephen commented Nov 27, 2022

TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 34.99 seconds
load time: 431 seconds
storage size: 17123343163 Bytes
https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221129052741_clickbench_pr_54768.html

@yiguolei yiguolei added dev/1.1.5 usercase Important user case type label labels Nov 28, 2022
@mrhhsg mrhhsg force-pushed the cache_time_zone branch 2 times, most recently from 2697030 to d764011 Compare November 28, 2022 04:35
Yukang-Lian
Yukang-Lian previously approved these changes Nov 28, 2022
Copy link
Collaborator

@Yukang-Lian Yukang-Lian left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@Yukang-Lian
Copy link
Collaborator

Before this PR
perf

After this PR
perf3

@@ -47,6 +51,10 @@ struct ConvertTZImpl {
const ColumnString* from_tz_column, const ColumnString* to_tz_column,
ReturnColumnType* result_column, NullMap& result_null_map,
size_t input_rows_count) {
auto convert_ctx = reinterpret_cast<ConvertTzCtx*>(
context->get_function_state(FunctionContext::FunctionStateScope::THREAD_LOCAL));
std::map<StringRef, cctz::time_zone> time_zone_cache_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
std::map<StringRef, cctz::time_zone> time_zone_cache_;
std::map<StringRef, cctz::time_zone> time_zone_cache;

Copy link
Member Author

Choose a reason for hiding this comment

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

time_zone_cache_ is a temporary map.
time_zone_cache is a reference to the map.

Copy link
Contributor

@Gabriel39 Gabriel39 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sql/function Issues or PRs related to the SQL functions area/vectorization dev/1.1.5-merged kind/test reviewed usercase Important user case type label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants