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

perf(api): speed up simple column accesses by avoiding dereferencing #9156

Merged
merged 2 commits into from
May 8, 2024

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented May 8, 2024

Avoid the full dereference computation in the simple field access case, e.g., t["a"] or t[0].

@cpcloud cpcloud added this to the 9.1 milestone May 8, 2024
@cpcloud cpcloud added the performance Issues related to ibis's performance label May 8, 2024
@cpcloud cpcloud requested review from gforsyth and kszucs May 8, 2024 13:10
@cpcloud cpcloud force-pushed the single-column-access-perf branch from 40c4647 to 121c57d Compare May 8, 2024 13:10
@cpcloud
Copy link
Member Author

cpcloud commented May 8, 2024

Benchmark comparison:

-------------------------------------------------------------------------------- benchmark 'test_column_access[attr]': 2 tests ---------------------------------------------------------------------------------
Name (time in us)                               Min                Max               Mean            StdDev             Median               IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_column_access[attr] (0001_022d094)     12.2840 (1.0)      28.0130 (1.04)     12.9317 (1.0)      0.6494 (1.03)     12.8340 (1.0)      0.2400 (1.70)      378;500       77.3295 (1.0)       12211           1
test_column_access[attr] (NOW)              12.7140 (1.04)     27.0010 (1.0)      13.1502 (1.02)     0.6293 (1.0)      13.0550 (1.02)     0.1410 (1.0)       463;863       76.0444 (0.98)      18164           1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------- benchmark 'test_column_access[int]': 2 tests -----------------------------------------------------------------------------------
Name (time in ms)                               Min                 Max                Mean             StdDev              Median                IQR            Outliers          OPS            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_column_access[int] (0001_022d094)     157.3464 (>1000.0)  213.8952 (>1000.0)  180.3918 (>1000.0)  30.4235 (>1000.0)  158.6153 (>1000.0)  55.3601 (>1000.0)       2;0       5.5435 (0.00)          5           1
test_column_access[int] (NOW)                0.0321 (1.0)        0.0539 (1.0)        0.0334 (1.0)       0.0012 (1.0)        0.0330 (1.0)       0.0009 (1.0)       614;570  29,976.2958 (1.0)       10307           1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------- benchmark 'test_column_access[str]': 2 tests -----------------------------------------------------------------------------------
Name (time in ms)                               Min                 Max                Mean             StdDev              Median                IQR            Outliers          OPS            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_column_access[str] (0001_022d094)     157.9610 (>1000.0)  212.6186 (>1000.0)  188.8913 (>1000.0)  28.5787 (>1000.0)  210.9883 (>1000.0)  53.4910 (>1000.0)       3;0       5.2941 (0.00)          7           1
test_column_access[str] (NOW)                0.0130 (1.0)        0.0240 (1.0)        0.0135 (1.0)       0.0006 (1.0)        0.0134 (1.0)       0.0002 (1.0)      900;1441  73,982.5499 (1.0)       33777           1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
====================================================================================== 3 passed in 3.88s =======================================================================================

image

@gforsyth
Copy link
Member

gforsyth commented May 8, 2024

So... a 4900x speedup? We could use this in a disingenuous blog post about performance

Copy link
Member

@gforsyth gforsyth left a comment

Choose a reason for hiding this comment

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

:shipit:

@gforsyth gforsyth merged commit c770fa1 into ibis-project:main May 8, 2024
83 checks passed
@cpcloud cpcloud deleted the single-column-access-perf branch May 8, 2024 13:51
@kszucs
Copy link
Member

kszucs commented May 9, 2024

We could also speed up the dereferencing by caching the derefmap for table expressions. We can also maintain a smaller mapping by skipping items where key == value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issues related to ibis's performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants