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

importinto: optimize write ingest step and fix oom #48047

Merged
merged 30 commits into from
Oct 31, 2023

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Oct 27, 2023

What problem does this PR solve?

Issue Number: ref #47572, close #47643

Problem Summary:

What is changed and how it works?

  • add option checkHotspot to allow read each file using single reader.
  • adjust concurrency of LoadIngestData depends on number of data-files when we disable checkHotspot, after this, we can have more concurrency to load ingest data.
  • send loaded ingestData immediately to reduce memory usage, now we can hold at most 1 DataAndRange per LoadIngestData routine
  • adjust WorkerConcurrency for import-into on global-sort based on thread-cnt to avoid oom see external engine oom on loadIngestData #47643
  • display total file size in IEC unit
  • refine logs

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    • NOTE: below test all set this:
set global tidb_server_memory_limit_gc_trigger=0.99;
set global tidb_server_memory_limit='88%';
  • test a add-index case of 100M rows(sbtest1) using 1 node and global-sort, this pr takes 5 min 30.47 (5 min 38.94 on master). KS3 speed is not that stable, the speed varies a little.
  • test import-into of 150G using 1 node and global-sort, this pr takes 26m (45m on master)
  • test import-into on 1T 1 node and global-sort, success
  • No need to test
    • I checked and no code files have been changed.

Side effects

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

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 27, 2023
@tiprow
Copy link

tiprow bot commented Oct 27, 2023

Hi @D3Hunter. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #48047 (d1483d8) into master (2b18f64) will increase coverage by 1.2056%.
Report is 2 commits behind head on master.
The diff coverage is 80.9160%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48047        +/-   ##
================================================
+ Coverage   71.5890%   72.7947%   +1.2056%     
================================================
  Files          1400       1423        +23     
  Lines        405903     412372      +6469     
================================================
+ Hits         290582     300185      +9603     
+ Misses        95511      93283      -2228     
+ Partials      19810      18904       -906     
Flag Coverage Δ
integration 42.3672% <0.0000%> (?)
unit 71.5999% <80.9160%> (+0.0109%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9874% <ø> (-0.0629%) ⬇️
parser ∅ <ø> (∅)
br 48.6654% <84.8484%> (-4.2266%) ⬇️

// is unbuffered).
if size > LargeRegionSplitDataThreshold {
readRateHist.Observe(float64(size) / 1024.0 / 1024.0 / time.Since(batchStartTs).Seconds())
readDurHist.Observe(time.Since(batchStartTs).Seconds())
Copy link
Member

Choose a reason for hiding this comment

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

The duration may not be correct. We can ignore the time during sendFn().

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

please address existing comments

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 30, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 31, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, wjhuang2016

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

The pull request process is described here

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 and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 31, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 31, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-10-30 07:29:07.487408576 +0000 UTC m=+2851745.074518721: ☑️ agreed by lance6716.
  • 2023-10-31 08:34:31.900646246 +0000 UTC m=+2942069.487756391: ☑️ agreed by wjhuang2016.

@wjhuang2016
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit 99a4f35 into pingcap:master Oct 31, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #48144.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 31, 2023
@D3Hunter D3Hunter deleted the opt-write-ingest branch November 1, 2023 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

external engine oom on loadIngestData
4 participants