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

lightning/external: port file.go and necessary codes #45795

Merged
merged 12 commits into from
Aug 7, 2023

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Aug 3, 2023

What problem does this PR solve?

Issue Number: ref #45719

Problem Summary:

What is changed and how it works?

Add KeyValueStore which can serialize the KV pair and maintain the range property collector

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

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 do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 3, 2023
@tiprow
Copy link

tiprow bot commented Aug 3, 2023

Hi @lance6716. 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 Aug 3, 2023

Codecov Report

Merging #45795 (d1f973b) into master (c8a8819) will increase coverage by 0.0266%.
Report is 1 commits behind head on master.
The diff coverage is 58.8652%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #45795        +/-   ##
================================================
+ Coverage   73.3504%   73.3771%   +0.0266%     
================================================
  Files          1272       1277         +5     
  Lines        393076     393894       +818     
================================================
+ Hits         288323     289028       +705     
- Misses        86373      86469        +96     
- Partials      18380      18397        +17     
Flag Coverage Δ
integration 78.1388% <ø> (?)
unit 73.3689% <58.8652%> (+0.0184%) ⬆️

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

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0467% <ø> (ø)
br 52.0894% <58.8652%> (+0.0533%) ⬆️

Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716 lance6716 changed the title [WIP]sharedisk: port file.go and necessary codes sharedisk: port file.go and necessary codes Aug 4, 2023
@ti-chi-bot ti-chi-bot bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-linked-issue labels Aug 4, 2023
@lance6716 lance6716 changed the title sharedisk: port file.go and necessary codes lightning/external: port file.go and necessary codes Aug 4, 2023
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
// NewKeyValueStore creates a new KeyValueStore. The data will be written to the
// given dataWriter and range properties will be maintained in the given
// rangePropertiesCollector.
func NewKeyValueStore(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we provide an function to clear all data stored in kv store?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure about the design from a higher perspective, seems NewKeyValueStore just wraps the writing functionality on external store, and clearing all data is still a functionality of external store itself.

encoded = rc.encode()
require.Greater(t, len(encoded), 0)

// when not accumulated enough data, no range property will be added.
Copy link
Contributor

Choose a reason for hiding this comment

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

How can we enforce collect the range property if not accumulated enough data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems we don't and the code runs fine.

"encoding/binary"
)

type rangeProperty struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add more comments about the meaning of the rangeProperty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added comments for some members. I'm not sure about the rest ones.

// size or key count exceeds the given distance, a new range property will be
// appended to the rangePropertiesCollector with current status.
// Caller should guarantee `writerID` and `seq` are not changed.
func (s *KeyValueStore) AddKeyValue(key, value []byte, writerID, seq int) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we have batch add function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The overhead of AddKeyValue is not much, that's a premature optimization.

Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
}

// FilePathHandle handles data file paths under a prefix path.
type FilePathHandle struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can abandon this structure and use []string instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will think again when port the usage of FilePathHandle

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2023
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2023
writerID int
seq int
offset uint64
u64Buffer []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe change this field to a local variable var b [8]byte is better.

Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 4, 2023
@ti-chi-bot ti-chi-bot bot added the lgtm label Aug 7, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 7, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tangenta, 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:
  • OWNERS [tangenta,wjhuang2016]

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 7, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 7, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-08-04 08:25:37.448997077 +0000 UTC m=+433021.391345624: ☑️ agreed by wjhuang2016.
  • 2023-08-07 04:26:32.884866274 +0000 UTC m=+677876.827214804: ☑️ agreed by tangenta.

@lance6716
Copy link
Contributor Author

/retest

@tiprow
Copy link

tiprow bot commented Aug 7, 2023

@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@hawkingrei
Copy link
Member

/retest

@tiprow
Copy link

tiprow bot commented Aug 7, 2023

@lance6716: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
tiprow_fast_test f3d7fc7 link true /test tiprow_fast_test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@lance6716
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit de30804 into pingcap:master Aug 7, 2023
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm 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.

5 participants