Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Caching of prepared queries #166

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

Merged
merged 4 commits into from
Apr 24, 2025
Merged

Caching of prepared queries #166

merged 4 commits into from
Apr 24, 2025

Conversation

adespawn
Copy link
Collaborator

@adespawn adespawn commented Mar 23, 2025

Cache prepared statements on the JS side within single call of batch and concurrent execute.

About 20% improvement on concurrent insert (both task clock and time elapsed).

Before (js-caching branch):

sudo perf stat node ./benchmark/logic/concurrent_insert.js scylladb-javascript-driver 1000000

 Performance counter stats for 'node ./benchmark/logic/concurrent_insert.js scylladb-javascript-driver 1000000':

         69,564.54 msec task-clock                       #    1.639 CPUs utilized             
         2,702,067      context-switches                 #   38.843 K/sec                     
            24,744      cpu-migrations                   #  355.698 /sec                      
           190,975      page-faults                      #    2.745 K/sec                     
   283,675,180,415      cycles                           #    4.078 GHz                       
    75,943,317,270      stalled-cycles-frontend          #   26.77% frontend cycles idle      
   238,391,112,023      instructions                     #    0.84  insn per cycle            
                                                  #    0.32  stalled cycles per insn   
    45,454,104,968      branches                         #  653.409 M/sec                     
     1,559,027,745      branch-misses                    #    3.43% of all branches           

      42.448039778 seconds time elapsed

      47.783400000 seconds user
      23.049097000 seconds sys

After:

sudo perf stat node ./benchmark/logic/concurrent_insert.js scylladb-javascript-driver 1000000

 Performance counter stats for 'node ./benchmark/logic/concurrent_insert.js scylladb-javascript-driver 1000000':

         54,311.66 msec task-clock                       #    1.619 CPUs utilized             
         1,910,653      context-switches                 #   35.179 K/sec                     
            18,347      cpu-migrations                   #  337.810 /sec                      
           213,348      page-faults                      #    3.928 K/sec                     
   225,277,325,784      cycles                           #    4.148 GHz                       
    59,589,673,035      stalled-cycles-frontend          #   26.45% frontend cycles idle      
   203,600,992,694      instructions                     #    0.90  insn per cycle            
                                                  #    0.29  stalled cycles per insn   
    38,835,678,700      branches                         #  715.052 M/sec                     
     1,230,468,744      branch-misses                    #    3.17% of all branches           

      33.556679150 seconds time elapsed

      37.259389000 seconds user
      17.954469000 seconds sys

@adespawn adespawn marked this pull request as ready for review March 24, 2025 14:14
@adespawn adespawn force-pushed the js-caching branch 2 times, most recently from be1ecb7 to 22072df Compare March 26, 2025 14:24
@adespawn adespawn force-pushed the js-caching branch 2 times, most recently from fe08398 to 5433075 Compare April 1, 2025 07:01
@adespawn adespawn marked this pull request as draft April 11, 2025 09:27
@adespawn
Copy link
Collaborator Author

Waiting for #155

@adespawn adespawn force-pushed the js-caching branch 5 times, most recently from 8cec285 to e7db7f1 Compare April 18, 2025 09:20
@adespawn adespawn changed the base branch from js-caching to second-iteration April 18, 2025 09:26
@adespawn adespawn changed the base branch from second-iteration to js-caching April 18, 2025 09:42
Base automatically changed from js-caching to second-iteration April 19, 2025 12:36
@adespawn adespawn marked this pull request as ready for review April 23, 2025 09:03
@adespawn adespawn requested a review from wprzytula April 23, 2025 09:04
Update client so it is possible to manually prepare queries,
and execute already prepared queries. For now this is just part
of the internal client API, but may be considered
to extend it to public API.

The goal of this change is to allow concurrent inserts
to prepare only once repeated queries, as even if
rust cashing session is used, it significantly improves performance,
by reducing how many round trips are required.
Introduce caching of repeating queries within
single executeConcurrent call.

While not perfect, it significantly improves performance.
To make it even more effective, we may consider exposing
bulk prepare from the rust part of the code.
@adespawn adespawn merged commit 2105dee into second-iteration Apr 24, 2025
8 checks passed
@adespawn adespawn deleted the caching2 branch April 24, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.