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

Optimize cast(uuid as varchar) #10361

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Jul 1, 2024

  1. Optimize cast(uuid as varchar)

    Summary:
    boost::lexical_cast used to implement cast(uuid as varchar) is very slow.
    
    Replace with custom optimization.
    
    Microbenchmark shows 20x improvement.
    
    The benchmark compares uuid() with cast(uuid() as varchar). The latter includes the code of the former plus the cost of the cast. Before the change, uuid() + cast was 16s, 10s more than uuid() alone. After the change, uuid() + cast() is just 0.5s more.
    
    Before:
    
    ```
    ============================================================================
    [...]hmarks/ExpressionBenchmarkBuilder.cpp     relative  time/iter   iters/s
    ============================================================================
    cast##no_cast                                                6.33s   157.86m
    cast##as_varchar                                            16.54s    60.45m
    ```
    
    After:
    
    ```
    ============================================================================
    cast##no_cast                                                6.29s   159.10m
    cast##as_varchar                                             6.81s   146.74m
    ----------------------------------------------------------------------------
    ```
    
    Profile before the optimization:  {F1735048022}
    
    Differential Revision: D59229653
    mbasmanova authored and facebook-github-bot committed Jul 1, 2024
    Configuration menu
    Copy the full SHA
    3028732 View commit details
    Browse the repository at this point in the history