Commit 3fc29ad
committed
kv: resolve conflicting intents immediately for latency-sensitive requests
Fixes #50390.
Related to #60585.
Related to #103126.
Closes #64500, which was an earlier attempt to solve this issue using a similar
approach. This commit addresses the comments on that PR, which focused on the
pagination of intent resolution when bypassing the request batcher. We still
don't try to solve this issue, and instead limit the cases where intent
resolution bypasses the request batcher to those where pagination is not
necessary.
This commit adds a new `sendImmediately` option to the `IntentResolver`
`ResolveOptions`, which instructs the `IntentResolver` to send the provided
intent resolution requests immediately, instead of adding them to a batch and
waiting up to 10ms (defaultIntentResolutionBatchWait) for that batch to fill up
with other intent resolution requests. This can be used to avoid any
batching-induced latency and should be used only by foreground traffic that is
willing to trade off some throughput for lower latency.
The commit then sets this flag for single-key intent resolution requests initiated
by the `lockTableWaiter`. Unlike most calls into the `IntentResolver`, which are
performed by background tasks that are more than happy to trade increased
latency for increased throughput, the `lockTableWaiter` calls into the
`IntentResolver` on behalf of a foreground operation. It wants intent resolution
to complete as soon as possible, so it is willing to trade reduced throughput
for reduced latency.
I tested this out by writing 10,000 different intents in a normal-priority transaction
and then scanning over the table using a high-priority transaction. The test was
performed on a 3-node roachprod cluster to demonstrate the effect with realistic
network and disk latencies.
```
-- session 1
CREATE TABLE keys (k BIGINT NOT NULL PRIMARY KEY);
BEGIN; INSERT INTO keys SELECT generate_series(1, 10000);
-- session 2
BEGIN PRIORITY HIGH; SELECT count(*) FROM keys;
```
Without this change, the scan took 70.078s. With this change, the scan took
15.958s. This 78% speed up checks out. Each encountered intent is resolved
serially (see #103126), so the per-intent latency drops from 7ms to 1.6ms. This
improvement by about 5ms agrees with the `defaultIntentResolutionBatchIdle`,
which delays each resolution request that passes through a RequestBatcher. With
this change, these resolve intent requests are issued immediately and this delay
is not experienced.
While this is a significant improvement and will be important for Read Committed
transactions after #102014, this is still not quite enough to resolve #103126.
For that, we need to batch the resolve intent requests themselves using a form
of deferred intent resolution like we added in #49218 (for finalized transactions).
A similar improvement is seen for scans that encounter many abandoned intents
from many different transactions. This scenario bypasses the deferred intent
resolution path added in #49218, because the intents are each written by
different transactions. The speedup for this scenario was presented in #64500.
Release note (performance improvement): SQL statements that must clean up
intents from many different previously abandoned transactions now do so
moderately more efficiently.1 parent 11c3c83 commit 3fc29ad
1 file changed
Lines changed: 73 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
845 | 845 | | |
846 | 846 | | |
847 | 847 | | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
848 | 865 | | |
849 | 866 | | |
850 | 867 | | |
| |||
873 | 890 | | |
874 | 891 | | |
875 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
876 | 897 | | |
877 | 898 | | |
878 | | - | |
879 | | - | |
| 899 | + | |
880 | 900 | | |
881 | 901 | | |
882 | 902 | | |
883 | 903 | | |
884 | | - | |
885 | | - | |
| 904 | + | |
886 | 905 | | |
887 | 906 | | |
888 | 907 | | |
889 | 908 | | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
890 | 924 | | |
891 | 925 | | |
892 | | - | |
893 | | - | |
| 926 | + | |
894 | 927 | | |
895 | 928 | | |
896 | 929 | | |
897 | 930 | | |
898 | | - | |
899 | | - | |
| 931 | + | |
900 | 932 | | |
901 | 933 | | |
902 | 934 | | |
903 | 935 | | |
904 | | - | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
905 | 939 | | |
906 | 940 | | |
907 | 941 | | |
908 | | - | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
909 | 953 | | |
910 | 954 | | |
911 | | - | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
912 | 958 | | |
913 | 959 | | |
914 | 960 | | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
915 | 966 | | |
916 | 967 | | |
917 | 968 | | |
| |||
943 | 994 | | |
944 | 995 | | |
945 | 996 | | |
946 | | - | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
947 | 1008 | | |
948 | 1009 | | |
949 | 1010 | | |
| |||
0 commit comments