-
Notifications
You must be signed in to change notification settings - Fork 504
Conversation
src/store.c
Outdated
@@ -351,14 +352,18 @@ int pthreads_store_write(zval *object, zval *key, zval *write) { | |||
normal refcounting, we'll just never read the reference | |||
*/ | |||
rebuild_object_properties(&threaded->std); | |||
|
|||
pthreads_store_sync(object); |
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.
It's not immediately clear to me why this is needed - is it related to the memory leaks you're fixing? And do you have a test case for this?
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.
A test case might be difficult. I ran the script above for a certain time and watched the memory consumption. Any idea to trace this in a test script?
I've added pthreads_store_sync at this point to guarantee consistency with the behavior of reading properties. It is not necessary for the memory leak fix itself, just for the cleanup problems in #580.
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.
Testing the memory leak isn't really necessary, since it's quite unlikely a regression will be introduced here. I just wasn't sure how syncing the pthreads store linked to the memory leaks (it doesn't, but I see that you're using this PR to fix two different bugs).
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.
This has the potential to make unsynchronized writes extremely slow ... I don't like it ... would be good to find another way to do whatever you are trying to do ...
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.
Producer/Consumer: Producer Thread A writes properties and never reads them. Consumer Thread B reads/removes properties. Table std.properties in Thread A fills up, endlessly. I could limit pthreads_store_sync
to Volatile objects, that might be a solution you like?
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.
I have again tested the script, without the pthreads_store_sync call. I must admit the memory isn't growing. My fault, I must have done something wrong.
027a554
to
8fa211b
Compare
@sirsnyder I'm also having trouble replicating the issue you're receiving without the syncing of the pthreads store. Do you have a smaller reproducing script that explicitly shows a difference with and without the syncing of stores on property writes? The memory leak fixes look fine to me though. |
@tpunt that must have been an erroneous observation in htop. My fault. I've removed the pthreads_store_sync call. |
Merged in 1dfeea7. Thanks! |
Cleanup on synchronized or reading a property is inconsistent, therefore cleanup should also happen on writing a property. Moreover the cleanup behavior on synchronized is misleading.
This is a fix for #681 as well.