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

qvector replace unnecessary code #114

Merged
merged 1 commit into from
May 15, 2024
Merged

Conversation

Hojun-Cho
Copy link
Contributor

@Hojun-Cho Hojun-Cho commented May 13, 2024

I add commit about replaced unnecessary code.

@Hojun-Cho Hojun-Cho changed the title replace for-loop to memcpy qvector replace unnecessary code May 13, 2024
memcpy(tmp, data1, vector->objsize);
memcpy(data1, data2, vector->objsize);
memcpy(data2, tmp, vector->objsize);
for (int k = 0; k < vector->objsize; k++) {
Copy link
Owner

Choose a reason for hiding this comment

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

I think the behavior of the qvector_reverse() is to reverse the order of the elements, not the byte order inside the elements.

Copy link
Owner

Choose a reason for hiding this comment

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

My bad. Plz ignore the above comment. I misread.
But performance-wise, how will it compare?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't need call malloc

@wolkykim
Copy link
Owner

Hi Hojun,

Thanks for your PR.
I like the update of replace for-loop to memcpy.
But have a concern about the 2nd commit of malloc removal as you might be misunderstanding the behavior of the function.
Please take a look and let me know what you think.

@Hojun-Cho Hojun-Cho closed this May 14, 2024
@Hojun-Cho Hojun-Cho reopened this May 14, 2024
@Hojun-Cho
Copy link
Contributor Author

First, thank you for time. I agree with you.
But I was thinking that it would be better to avoid dynamic allocation. If we can predict that the objsize will not be realistically large, how about use stack?

@wolkykim
Copy link
Owner

wolkykim commented May 14, 2024

Hi Hojun,

Oh sorry, I misread your code. Yeah, your update doesn't change the behavior.
But still not comfortable with doing for-loop in the byte level.

@Hojun-Cho
Copy link
Contributor Author

Hojun-Cho commented May 14, 2024

I agree with you. How about discard for-loop commit?

@wolkykim
Copy link
Owner

I Agree with you. How about discard for-lopp commit?

I'm good with that. We're good to go with 20d7435
Looks like the existing qvector test cases cover the changes but can you double-check?

@wolkykim
Copy link
Owner

wolkykim commented May 14, 2024 via email

@Hojun-Cho
Copy link
Contributor Author

Hojun-Cho commented May 14, 2024

It feels that's too much for removing a
temporary malloc.

I didn't think of that. Thank you for your feedback.

Copy link
Owner

@wolkykim wolkykim left a comment

Choose a reason for hiding this comment

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

Thank you again for a great PR!!!

@wolkykim wolkykim merged commit 0ed15e9 into wolkykim:main May 15, 2024
10 checks passed
@Hojun-Cho Hojun-Cho deleted the rwonly/qvector branch May 15, 2024 02:40
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.

2 participants