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

Remove unused valDup #443

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

eliblight
Copy link

It turns out valDup is totally unused in the codebase

Copy link

codecov bot commented May 6, 2024

Codecov Report

Attention: Patch coverage is 76.20358% with 173 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (unstable@af1b0de). Click here to learn what that means.

❗ Current head a956b50 differs from pull request most recent head b839456. Consider uploading reports for the commit b839456 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##             unstable     #443   +/-   ##
===========================================
  Coverage            ?   68.45%           
===========================================
  Files               ?      109           
  Lines               ?    61680           
  Branches            ?        0           
===========================================
  Hits                ?    42221           
  Misses              ?    19459           
  Partials            ?        0           
Files Coverage Δ
deps/hiredis/sds.h 46.87% <ø> (ø)
src/ae.c 79.65% <ø> (ø)
src/asciilogo.h 100.00% <ø> (ø)
src/blocked.c 91.86% <100.00%> (ø)
src/cluster.c 83.77% <100.00%> (ø)
src/commands.def 100.00% <ø> (ø)
src/connection.h 93.58% <ø> (ø)
src/connhelpers.h 100.00% <ø> (ø)
src/crc64.c 100.00% <100.00%> (ø)
src/crccombine.c 100.00% <100.00%> (ø)
... and 82 more

@madolson
Copy link
Member

madolson commented May 8, 2024

As mentioned on slack, can you run the performance test again with more keys and post the updated performance here. As long as there is a meaningful difference, I think it would be worth pulling it.

@eliblight
Copy link
Author

For random key and small packets we will see some improvement. For larger packet the improvement is overshadowed by the overall load and is no longer measurable (though logic say it must be there however small).

@madolson
Copy link
Member

@eliblight Can you fix the DCO complaint?

Signed-off-by: Eran Liberty <eran.liberty@gmail.com>
@@ -62,18 +62,6 @@ static unsigned int callbackHash(const void *key) {
hi_sdslen((const hisds)key));
}

static void *callbackValDup(void *privdata, const void *src) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's not touch hiredis. We are looking to devendor it anyways, so I think they can make independent decisions about this.

Copy link
Author

Choose a reason for hiding this comment

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

I think we must.
i.e. I changed the type and then changed whatever did not compile.
will recheck if we must and remove if not

Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need to change hiredis. Hiredis is compiled independently as a static file and then linked against.

@@ -820,9 +820,9 @@ void dictSetKey(dict *d, dictEntry* de, void *key) {
de->key = key;
}

void dictSetVal(dict *d, dictEntry *de, void *val) {
void dictSetVal(dictEntry *de, void *val) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
void dictSetVal(dictEntry *de, void *val) {
void dictSetVal(dict *d, dictEntry *de, void *val) {
UNUSED(d);

Although a little silly, this makes the actual scope of the change much smaller. If we end up reverting it, we'll preserve a lot more history.

Copy link
Author

@eliblight eliblight May 22, 2024

Choose a reason for hiding this comment

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

Will need to inspect the assembly to say for sure but, this might force the compile to put "d" on the stack for nothing. It might force higher function that want to setVal to fetch the dict for nothing both in code lines and in assembly instruction (i.e. I am not sure the compiler will be able to optimize it out)

think about this and if you still prefer me to take your suggestion, say so and I will comply.

@madolson
Copy link
Member

Sorry for taking a bit to get back around to this, can you address the merge conflicts and update the PR? I'm happy with it otherwise.

@@ -820,9 +820,9 @@ void dictSetKey(dict *d, dictEntry* de, void *key) {
de->key = key;
}

void dictSetVal(dict *d, dictEntry *de, void *val) {
Copy link
Member

Choose a reason for hiding this comment

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

I like asserts during functional testing, but not so much in production. dictSetVal is now

void dictSetVal(dictEntry *de, void *val) {
    assert(entryHasValue(de));
    de->v.val = val;
}

Can we disable this assert except when testing? Can we take the next step and make this function in-line?

Copy link
Author

Choose a reason for hiding this comment

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

Trust in the compiler! or "respect and suspect" and actually examine the assembly. But from my experience the compiler is way smarter than mere humans and will inline this and a lot more where it make sense.

Copy link
Member

Choose a reason for hiding this comment

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

If cross-file optimization is turned on, then I would expect a good compiler to automatically inline this. We have a lot of inline directives in our code, I cannot tell you why.

I am more interested in changing assert to debugServerAssertWithInfo so that it is a no-op in production.

I have a zero-trust policy. I am willing to work with a "trust and verify" policy on the grounds that it really means "don't tell someone you don't trust them until after you have proof". I think that is almost equivalent to your "respect and suspect".

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

3 participants