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
Move parse frame array to the Map object #3560
Conversation
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure. |
1 similar comment
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure. |
Can one of the admins verify this patch? |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
ba09825
to
0a274cc
Compare
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure. |
1 similar comment
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure. |
Can one of the admins verify this patch? |
ok to test |
I see that some builds failed, but I can't see the details. Do I need to make sure that all of them are green before this can be applied? |
I believe it's just flaky. The tests result look good. @haberman could you take a look at the PR? |
Thanks very much for the fix! Can you help me understand what could cause concurrent decodes though? I know Ruby can have multiple threads, but I was under the impression that Ruby has a GVL that prevents Ruby code or C extensions from running concurrently (unless you use |
Ruby can switch threads when the GC is invoked. Array manipulations with
It sounds like you might be confusing concurrency and parallelism. The GVL prevents parallelism (two Ruby threads running at the same time), but it does not prevent concurrency (two Ruby threads running interleaved). The bug that we are hitting here is that we have two decodes running interleaved. Interleaving thread execution happened because the calls to I hope this helps. If there's anything I can do to better explain, please let me know! NOTE: It may not have been the |
@@ -293,16 +288,12 @@ static map_parse_frame_t* map_push_frame(VALUE map, | |||
native_slot_init(handlerdata->key_field_type, &frame->key_storage); | |||
native_slot_init(handlerdata->value_field_type, &frame->value_storage); | |||
|
|||
rb_ary_push(map_parse_frames, | |||
Map_push_frame(map, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are storing this in the map directly, I don't think it needs to be an array with push and pop. I think it could just be a single value. The array was for when we had a single global stack that needed to be able to handle parsing of nested maps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I changed this to store only one value.
Got it, thanks for the explanation. I hadn't realized that calls into Ruby APIs could release the GVL; I thought every call into a C extension routine was atomic unless you explicitly released the GVL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks great. Could you add your test case to our test suite to verify the fix and prevent regressions?
b05391b
to
f5328c6
Compare
Done. 😊 |
This makes the frame stack per-parser, and per-thread. Fixes protocolbuffers#3250
f5328c6
to
f55c6ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
This makes the frame stack per-parser, and per-thread. Fixes #3250