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

Fixing issues in Thread/Fiber merge #321

Merged
merged 5 commits into from Apr 16, 2023
Merged

Fixing issues in Thread/Fiber merge #321

merged 5 commits into from Apr 16, 2023

Conversation

asksurya
Copy link
Contributor

As discussed in #320 (comment), the new solution has been implemented in these changes

@@ -91,7 +91,7 @@ def test_add_child_gc
GC.stress = false
end
end

=begin
Copy link
Member

Choose a reason for hiding this comment

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

What is this for?

Copy link
Contributor

Choose a reason for hiding this comment

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

I commented this test out because we no longer can just merge call trees we need to have the thread table present and that merge is tested in thread_merge tests so this is no longer relevant test

Copy link
Member

Choose a reason for hiding this comment

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

Ok, then just delete?

@@ -20,7 +20,7 @@ You cannot create an instance of RubyProf::Thread, instead you access it from a
#include "rp_profile.h"

VALUE cRpThread;

st_table* merge_method_table;
Copy link
Member

Choose a reason for hiding this comment

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

This looks like global state to me, won't this conflict with multiple threads?
If you need access to it, add a method to rp_thread.h:

st_table* thread_get_method_table(thread_data_t* thread);

Copy link
Contributor

Choose a reason for hiding this comment

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

I have modified the methods now to pass the information from thread side into the call tree side and store it as a struct in the call_tree.c. I cannot do the thread.h becasue the call_tree is not having thread info and the struct is needed to call the merge_children code in rb_st_foreach

@@ -362,8 +362,12 @@ static VALUE prof_thread_merge(VALUE self, VALUE other)
{
thread_data_t* self_ptr = prof_get_thread(self);
thread_data_t* other_ptr = prof_get_thread(other);
prof_method_table_merge(self_ptr->method_table,other_ptr->method_table);
merge_method_table= self_ptr->method_table;
Copy link
Member

@cfis cfis Mar 20, 2023

Choose a reason for hiding this comment

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

Update this based on the comment above.

@@ -6,7 +6,7 @@

#include "ruby_prof.h"
#include "rp_stack.h"

extern st_table* merge_method_table;
Copy link
Member

Choose a reason for hiding this comment

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

Remove this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed.

@cfis
Copy link
Member

cfis commented Mar 20, 2023

Overall this looks pretty good - nice work! I added some comments for you to review. Also sync with latest master. You'll see I moved the merge tests to a new test file, including your original example. That test will need to be updated.

@asksurya
Copy link
Contributor Author

sorry for the late response, there are some pointer issues causing seg faults in the code, i am debugging them. Will update this thread once i resolve them

@cfis
Copy link
Member

cfis commented Mar 24, 2023

No worries - thanks for working on this. You probably know this, but one thing I find helpful is:

GC.stress = true

You can put the into a setup method of a test or in the abstract test for all tests. It makes exceptions show up much more quickly instead of a few tests later which is really hard to debug.

@cfis
Copy link
Member

cfis commented Apr 7, 2023

Hi @asksurya just checking on this? Would be good to great to get this merged in!

@asksurya
Copy link
Contributor Author

asksurya commented Apr 8, 2023

Hi @cfis ,
I have fixed the segmentation faults for this. I’ll implement the code changes and provide you the update by next week.

thanks,
Ashwin

@asivasub14
Copy link
Contributor

Hi @cfis,

I have updated the code logic to have the data correctly merged, it's the same logic suggested by you, I made some mistakes the first time around which are corrected now. W.R.T to the test code i will update them and submit again

Thanks,
Ashwin

@cfis
Copy link
Member

cfis commented Apr 11, 2023

Great thanks!

@asksurya
Copy link
Contributor Author

Hi @cfis,

I have fixed the tests as discussed as well as the changes suggested, Please let me know if anything is required further.

@cfis
Copy link
Member

cfis commented Apr 15, 2023

Great, I will take a look.

@cfis cfis merged commit d0e1136 into ruby-prof:master Apr 16, 2023
4 of 13 checks passed
@cfis
Copy link
Member

cfis commented Apr 16, 2023

I rebased your branch on master, squished the commits together, then pushed to askuray branch - see https://github.com/ruby-prof/ruby-prof/commits/asksurya. Work will continue on that branch.

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

4 participants