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

benchmark: fix pht insert test #184

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sim590
Copy link
Contributor

@sim590 sim590 commented Apr 3, 2017

Output from insertTest in benchmark has been wrong since the begining due to minor errors. This PR fixes those errors and also depends on #183 to build and run right. Keep that in mind before merging.

I have attached before.txt and after.txt files to compare outputs.

before.txt
after.txt

- Old log code updated;
- fix output of entries under final prefix locations;
@sim590
Copy link
Contributor Author

sim590 commented Apr 3, 2017

I also should mention that the test will fail to run properly due to the bug from #180. I have made sure the test works well on my end by reverting the SockAddr changes from the python layer.

string toString() const
string flagsToString() const
size_t size_
Copy link
Member

@aberaud aberaud Apr 3, 2017

Choose a reason for hiding this comment

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

IMHO fields should not be exposed here. Even in the C++ code, these fields are only public for convenience but should be made private, since it's dangerous to manipulate them directly (risk of inconsistence, like size_ larger than content_ size()*8 or flags_.size()*8).

edit: this refers to lines 194-196

Copy link
Collaborator

Choose a reason for hiding this comment

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

Totally agreed with that, since flags_ and content_ are internal variable, user shouldn't be able to edit them directly.
As @aberaud point out, there is a risk of inconsistence ( ou just mistake if you [try to] move around those bits )

PhtTest.prefix = prefix.decode()
DhtNetwork.log('Index name: <todo>')
DhtNetwork.log('Leaf prefix:', prefix)
PhtTest.prefix = str(prefix)
Copy link
Member

Choose a reason for hiding this comment

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

Since the goal of this patch is to "fix" the pht test, please also make it use non-static callbacks and fields so we can run multiple instances at the same time. Current design is awful.

@@ -471,6 +473,25 @@ cdef class DhtRunner(_WithID):
ref.Py_DECREF(<object>token._cb['cb'])
# fixme: not thread safe

cdef class Prefix(object):
cdef shared_ptr[cpp.Prefix] _prefix
Copy link
Member

@aberaud aberaud Apr 3, 2017

Choose a reason for hiding this comment

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

Why not just cpp.Prefix (like for InfoHash and others) ? __cinit__can be used for initialization. The API doesn't make use of shared_ptr<Prefix>

Copy link
Collaborator

@kaldoran kaldoran left a comment

Choose a reason for hiding this comment

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

As aberaud point out, there is some changes to do before accepting this PR. :)


@staticmethod
def lookupDoneCb(ok):
DhtNetwork.log('[LOOKUP]:', PhtTest.key, "--", "success!" if ok else "Fail...")
DhtNetwork.Log.log('[LOOKUP]:', PhtTest.key, "--", "success!" if ok else "Fail...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Log.log, looks like "a lot" of "Log"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaldoran: What do you mean precisely? Dhtnetwork.Log is a class which has methods log, warn and err.

Do you suggest changing Log.log method to Log.debug?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, in order to avoid future mistake. [Log.debug or some other form]

string toString() const
string flagsToString() const
size_t size_
Copy link
Collaborator

Choose a reason for hiding this comment

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

Totally agreed with that, since flags_ and content_ are internal variable, user shouldn't be able to edit them directly.
As @aberaud point out, there is a risk of inconsistence ( ou just mistake if you [try to] move around those bits )

@sim590
Copy link
Contributor Author

sim590 commented Sep 5, 2019

I realize that this PR has been opened for a very long time and I have not found time to work on this again yet. Since I cannot say as of now when I will find the time to work on this again, I think that the best is to close this for consistency of the list of ongoing PRs. Let anyone be free to take this work and produce a mergeable version of it.

@sim590 sim590 closed this Sep 5, 2019
@aberaud aberaud reopened this Sep 5, 2019
@aberaud
Copy link
Member

aberaud commented Sep 5, 2019

@sim590 Thanks I'll follow up on this PR

@aberaud aberaud force-pushed the master branch 14 times, most recently from 966e620 to fe6676f Compare April 4, 2022 00:23
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.

3 participants