Skip to content

sst_importer: Get Memory limit at the sst service initialization#18321

Merged
ti-chi-bot[bot] merged 4 commits intotikv:masterfrom
3pointer:stop_check_resource_on_write
Mar 21, 2025
Merged

sst_importer: Get Memory limit at the sst service initialization#18321
ti-chi-bot[bot] merged 4 commits intotikv:masterfrom
3pointer:stop_check_resource_on_write

Conversation

@3pointer
Copy link
Contributor

@3pointer 3pointer commented Mar 19, 2025

What is changed and how it works?

Issue Number: Close #18317
and close pingcap/tidb#60140

  1. Get memory limit multiple times is unnecessary.
  2. The previous memory checks's granularity was too fine, performing a check on every chunk. Since Lightning writes in 16KB chunks, the frequent checks resulted in noticeable overhead.

What's Changed:

  1. This PR change the behavior to only get memory limit once at beginning.
  2. This PR adjusts the memory check to be performed per request instead of per chunk
sst_importer: Get Memory limit at the sst service initialization #18321

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Release note

None

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 19, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 19, 2025
@3pointer 3pointer changed the title DNM: remove import resource check on sst write grpc service. [DNM]: remove import resource check on sst write grpc service. Mar 19, 2025
@ti-chi-bot ti-chi-bot bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 19, 2025
Signed-off-by: 3pointer <luancheng@pingcap.com>
@3pointer 3pointer force-pushed the stop_check_resource_on_write branch from 81828e6 to 24a20ce Compare March 19, 2025 06:12
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 19, 2025
@3pointer 3pointer changed the title [DNM]: remove import resource check on sst write grpc service. sst_importer: Reduce the Granularity of Memory Checks in the Import Interface Mar 19, 2025
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 19, 2025
@3pointer
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Mar 19, 2025
Signed-off-by: 3pointer <luancheng@pingcap.com>
Signed-off-by: 3pointer <luancheng@pingcap.com>
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 19, 2025
Signed-off-by: 3pointer <luancheng@pingcap.com>
@3pointer 3pointer force-pushed the stop_check_resource_on_write branch from ea32350 to b1374c2 Compare March 19, 2025 12:28
@3pointer 3pointer changed the title sst_importer: Reduce the Granularity of Memory Checks in the Import Interface sst_importer: Get Memory limit at the sst service initialization Mar 19, 2025
@3pointer 3pointer marked this pull request as ready for review March 19, 2025 13:08
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 19, 2025
@Tristan1900
Copy link
Contributor

Tristan1900 commented Mar 19, 2025

lgtm, thanks for the change! (I don't have permission to approve yet.)

I think for a quick bandaid it works but for the long term I feel like we could add a mem limit cache to our sys crate, and do background refresh every second or so, or just let next api call to update the cache. so not every call can trigger a sys call. That way we can get mem refresh not so often

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. needs-cherry-pick-release-9.0-beta.1 Should cherry pick this PR to release-9.0-beta.1 branch. labels Mar 21, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leavrth, YuJuncen

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm approved and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 21, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 21, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-03-21 05:35:48.944796245 +0000 UTC m=+593042.629032336: ☑️ agreed by Leavrth.
  • 2025-03-21 06:39:09.182440175 +0000 UTC m=+596842.866676256: ☑️ agreed by YuJuncen.

@ti-chi-bot ti-chi-bot bot merged commit af2d2c6 into tikv:master Mar 21, 2025
8 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Mar 21, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-9.0-beta.1: #18333.

ti-chi-bot bot pushed a commit that referenced this pull request Mar 21, 2025
) (#18333)

close #18317

sst_importer: Get Memory limit at the sst service initialization #18321

Signed-off-by: 3pointer <luancheng@pingcap.com>

Co-authored-by: 3pointer <luancheng@pingcap.com>
@YuJuncen YuJuncen added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Dec 9, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #19191.
But this PR has conflicts, please resolve them!

ti-chi-bot pushed a commit to ti-chi-bot/tikv that referenced this pull request Dec 9, 2025
close tikv#18317, close pingcap/tidb#60140

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot bot removed the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm needs-cherry-pick-release-9.0-beta.1 Should cherry pick this PR to release-9.0-beta.1 branch. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

5 participants