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

Avoid cycling searchers & leafs in ReservoirSampler; prefer source lookups #15078

Closed
wants to merge 1 commit into from

Conversation

mfussenegger
Copy link
Member

So far the sampling was done in two steps:

  1. Sample docIds
  2. Load values for docIds

The sampled docIds could hit many different readers and they weren't
processed in order, which could multiply the number of times a reader
needed to be loaded, and was taxing the fs cache.

Further, this switches to use source lookups, since on large tables only
a small subset of values is actually read. It avoids loading doc-values,
and should interact better with the rate-limiting setting.

…okups

So far the sampling was done in two steps:

1. Sample docIds
2. Load values for docIds

The sampled docIds could hit many different readers and they weren't
processed in order, which could multiply the number of times a reader
needed to be loaded, and was taxing the fs cache.

Further, this switches to use source lookups, since on large tables only
a small subset of values is actually read. It avoids loading doc-values,
and should interact better with the rate-limiting setting.
Copy link
Contributor

@BaurzhanSakhariev BaurzhanSakhariev left a comment

Choose a reason for hiding this comment

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

Thanks!

Added a question about change entry

docs/appendices/release-notes/5.6.0.rst Show resolved Hide resolved
@mfussenegger
Copy link
Member Author

I took some profiles using JFR with a custom profile that captures all disk events

Old version:

/data/nodes/0/indices/D_VOJsdQTGCKqFRD-wrNBg
    1/index
        17
            fdt 15,589    15.2 MB
            fdx  5,838     4.3 MB
        j
            fdt  12,118    11.8 MB
            fdx   4,711     3.2 MB
    0/index
        m
            fdt  12,145    11.9 MB
            fdx   4,693     3.2 MB
        10
            fdt 11,603    11.3 MB
            fdx  4,484     3.0 MB
    2/index
        14
            fdt 10,428    10.2 MB
            fdx  3,907     2.4 MB
        p
            fdt   8,606     8.4 MB
            fdx   3,285     1.7 MB
    3/index
        19
            fdt  8,629     8.4 MB
            fdx  3,289     1.7 MB
        z
            fdt   8,475     8.3 MB
            fdx   3,232     1.8 MB
        1l
            fdt  5,940     5.8 MB
            fdx  2,260   925.0 kB
        r
            fdt   3,001     2.9 MB
            fdx   1,145   256.9 kB

New Version:

/data/nodes/0/indices
    D_VOJsdQTGCKqFRD-wrNBg
        1/index
            17
                fdt 14,985    14.6 MB
                fdx     17    13.1 kB
            j
                fdt  12,021    11.7 MB
                fdx      25    16.2 kB
        0/index
            10
                fdt 11,399    11.1 MB
                fdx     21    13.4 kB
            m
                fdt  11,038    10.8 MB
                fdx      17    11.0 kB
        2/index
            14
                fdt  9,768     9.5 MB
                fdx      6     3.9 kB
            p
                fdt   8,338     8.1 MB
                fdx       3     2.1 kB
        3/index
            z
                fdt   8,583     8.4 MB
                fdx       4     3.3 kB
            19
                fdt  8,410     8.2 MB
                fdx      3     2.1 kB
            1l
                fdt  5,647     5.5 MB
                fdx      2     1.6 kB
            r
                fdt   3,112     3.0 MB
                fdx       2  888 bytes

So it does look like an improvement to me.
I'll do some more tests with a larger data set to be sure.

mfussenegger added a commit that referenced this pull request Nov 22, 2023
Subset of #15078
I couldn't verify if the segment access optimization has any impact

I also couldn't get realiable outputs with JFR FileRead sampling
anymore. So, this instead shows the dstat output, recorded while the
analyze was running.

The first column is the status-quo, the second column is _this_ commit,
the third column is the linked PR.

    -dsk/total-      -dsk/total-       -dsk/total-
     read  writ       read  writ        read  writ
      38M   45M        39M   45M         37M   45M
       0   664k         0   272k          0     0
       0     0       6584k   63M          0     0
       0     0       1016k   59M          0   584k
    7056k  102M        16k    0           0    24k
       0     0          0     0           0     0
      16k    0          0     0           0   232k
      68M    0          0     0           0     0
    1317M    0        126M 1056k         16k 8488k
    4250M  512k      2024M    0           0     0
    3748M  584k      1787M    0           0     0
    3818M  136k      1605M    0        6744k 6272k
    3819M    0       1497M    0           0  1488k
    3872M  392k      1248M  912k         16k 2024k
    3790M    0       1095M    0          91M    0
    3778M  584k       946M    0         587M    0
    3710M    0        807M    0        1562M  504k
    3650M    0        729M    0        1593M    0
    3130M    0        419M  136k       1370M    0
    2619M    0        120M   11M       1039M    0
    2223M  584k         0   664k        929M    0
    1715M    0          0  1328k        599M    0
     678M    0                         2914M    0
     118M 2312k                        1088M 1032k
       0     0                         9008k   26M
       0   584k                           0     0
                                          0     0
mfussenegger added a commit that referenced this pull request Nov 27, 2023
Subset of #15078
I couldn't verify if the segment access optimization has any impact

I also couldn't get realiable outputs with JFR FileRead sampling
anymore. So, this instead shows the dstat output, recorded while the
analyze was running.

The first column is the status-quo, the second column is _this_ commit,
the third column is the linked PR.

    -dsk/total-      -dsk/total-       -dsk/total-
     read  writ       read  writ        read  writ
      38M   45M        39M   45M         37M   45M
       0   664k         0   272k          0     0
       0     0       6584k   63M          0     0
       0     0       1016k   59M          0   584k
    7056k  102M        16k    0           0    24k
       0     0          0     0           0     0
      16k    0          0     0           0   232k
      68M    0          0     0           0     0
    1317M    0        126M 1056k         16k 8488k
    4250M  512k      2024M    0           0     0
    3748M  584k      1787M    0           0     0
    3818M  136k      1605M    0        6744k 6272k
    3819M    0       1497M    0           0  1488k
    3872M  392k      1248M  912k         16k 2024k
    3790M    0       1095M    0          91M    0
    3778M  584k       946M    0         587M    0
    3710M    0        807M    0        1562M  504k
    3650M    0        729M    0        1593M    0
    3130M    0        419M  136k       1370M    0
    2619M    0        120M   11M       1039M    0
    2223M  584k         0   664k        929M    0
    1715M    0          0  1328k        599M    0
     678M    0                         2914M    0
     118M 2312k                        1088M 1032k
       0     0                         9008k   26M
       0   584k                           0     0
                                          0     0
@mfussenegger
Copy link
Member Author

Closing this in favour of #15087

@mfussenegger mfussenegger deleted the j/analyze branch November 27, 2023 08:00
mergify bot pushed a commit that referenced this pull request Nov 27, 2023
Subset of #15078
I couldn't verify if the segment access optimization has any impact

I also couldn't get realiable outputs with JFR FileRead sampling
anymore. So, this instead shows the dstat output, recorded while the
analyze was running.

The first column is the status-quo, the second column is _this_ commit,
the third column is the linked PR.

    -dsk/total-      -dsk/total-       -dsk/total-
     read  writ       read  writ        read  writ
      38M   45M        39M   45M         37M   45M
       0   664k         0   272k          0     0
       0     0       6584k   63M          0     0
       0     0       1016k   59M          0   584k
    7056k  102M        16k    0           0    24k
       0     0          0     0           0     0
      16k    0          0     0           0   232k
      68M    0          0     0           0     0
    1317M    0        126M 1056k         16k 8488k
    4250M  512k      2024M    0           0     0
    3748M  584k      1787M    0           0     0
    3818M  136k      1605M    0        6744k 6272k
    3819M    0       1497M    0           0  1488k
    3872M  392k      1248M  912k         16k 2024k
    3790M    0       1095M    0          91M    0
    3778M  584k       946M    0         587M    0
    3710M    0        807M    0        1562M  504k
    3650M    0        729M    0        1593M    0
    3130M    0        419M  136k       1370M    0
    2619M    0        120M   11M       1039M    0
    2223M  584k         0   664k        929M    0
    1715M    0          0  1328k        599M    0
     678M    0                         2914M    0
     118M 2312k                        1088M 1032k
       0     0                         9008k   26M
       0   584k                           0     0
                                          0     0
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.

None yet

2 participants