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

bitswap/client: add option to disable duplicated block stats #195

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

hsanjuan
Copy link
Contributor

@hsanjuan hsanjuan commented Mar 6, 2023

Keeping a counter should not require query-ing the blockstore repeteadly for every single block received, so I have added an option to disable it.

Currently there is the assumption that doing Has() calls is cheap. That can be correct for most cases but also badly incorrect for others.

@hsanjuan hsanjuan requested a review from a team as a code owner March 6, 2023 12:54
@welcome
Copy link

welcome bot commented Mar 6, 2023

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Merging #195 (3c22aeb) into main (38b183c) will increase coverage by 0.00%.
The diff coverage is 55.55%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #195   +/-   ##
=======================================
  Coverage   65.65%   65.66%           
=======================================
  Files         207      207           
  Lines       25135    25141    +6     
=======================================
+ Hits        16503    16508    +5     
- Misses       7165     7169    +4     
+ Partials     1467     1464    -3     
Files Coverage Δ
bitswap/client/client.go 90.42% <55.55%> (+1.00%) ⬆️

... and 13 files with indirect coverage changes

@Jorropo
Copy link
Contributor

Jorropo commented Mar 6, 2023

I don't think anyone is using this to compare against the actual blockstore, I think it's more meant when you download the same block from multiple nodes.
There an in memory LRU or refactoring this to compare against our wantlist (if we get a block that isn't in our wantlist anymore we can assume it may be a duplicate). Would solve the same thing.

@hsanjuan
Copy link
Contributor Author

hsanjuan commented Mar 6, 2023

I am not sure what this stat is being used for or why it is implemented like this, I just want the ability to disable it.

@aschmahmann
Copy link
Contributor

@Jorropo any objection to merging this?

@lidel lidel requested a review from Jorropo August 7, 2023 13:29
@hacdias
Copy link
Member

hacdias commented Aug 17, 2023

Ping @Jorropo

@hacdias hacdias force-pushed the bitswap/disable-dup-block-stats branch from 1518fcb to 9b8b3d7 Compare August 17, 2023 12:49
Copy link
Contributor

@Jorropo Jorropo left a comment

Choose a reason for hiding this comment

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

That fine, it solves the problem and allows to optin.

@Jorropo Jorropo enabled auto-merge (rebase) September 25, 2023 13:51
@Jorropo
Copy link
Contributor

Jorropo commented Sep 25, 2023

@hsanjuan sorry for the delay, this code is good and doesn't make anything worst even if it could be optimized.
Could you please add a changelog entry ?

Keeping a counter should not require query-ing the blockstore repeteadly for
every single block received, so I have added an option to disable it.

Currently there is the assumption that doing Has() calls is cheap. That can be
correct for most cases but also badly incorrect for others.
... when duplicated block stats are disabled.
@hsanjuan hsanjuan force-pushed the bitswap/disable-dup-block-stats branch from 9b8b3d7 to 4e7a9a3 Compare October 12, 2023 16:56
@hsanjuan
Copy link
Contributor Author

@Jorropo now without allocating an empty slice

Copy link
Contributor

@Jorropo Jorropo left a comment

Choose a reason for hiding this comment

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

LGTM

@Jorropo
Copy link
Contributor

Jorropo commented Oct 12, 2023

A test would be good to catch regressions but I think this is fine.

@hsanjuan
Copy link
Contributor Author

Merge and will do a follow up with a test some day. 👀

@hsanjuan hsanjuan merged commit ef6adea into main Oct 13, 2023
11 checks passed
@hacdias hacdias deleted the bitswap/disable-dup-block-stats branch February 20, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants