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

Excessive handler duplication when running in serial #28

Closed
rrnewton opened this issue Oct 8, 2013 · 3 comments
Closed

Excessive handler duplication when running in serial #28

rrnewton opened this issue Oct 8, 2013 · 3 comments

Comments

@rrnewton
Copy link
Member

rrnewton commented Oct 8, 2013

In the course of debugging some stuff in GHCI, I'm seeing consistent double-execution of EVERY handler on my SLSet:

*Main> mem01
makeMemo, about to insert result: ("10","11")
makeMemo, about to insert result: ("100","101")
makeMemo, about to insert result: ("10","11")
makeMemo, about to insert result: ("100","101")

My (incorrect?) understanding was that handler duplication should only happen on the addHandler / put data-race, and the sequential version should have NO data-races right?

This is not a correctness problem, because of idempotency, but it is weird and possibly inefficient.

Oh, one more thing, like #27, this seems to only be with SLSet, not with PureSet.

@aturon, what do you think?

@aturon
Copy link
Contributor

aturon commented Oct 8, 2013

You're right that duplication should only be the result of an addHandler/put race, but it's actually very difficult to write purely sequential LVish code, because every callback executes in its own logical thread (even if they are all running on the same OS-level thread).

I can try to help track this down if you can point me to the code you're running here.

rrnewton added a commit that referenced this issue Dec 3, 2013
@rrnewton
Copy link
Member Author

rrnewton commented Dec 3, 2013

If you take a peek at that simple reproducer it is not purely sequential, but it does register the handler before it ever does any puts, so there should be no races.

On my machine I see two copies of both of those handlers, resulting in this test failure:

ERROR: LVarSpecificExn "EXCEPTION in runPar(ThreadId 5): HUnitFailure \"Should be no duplication in this case\\nexpected: 2\\n but got: 4\""

I'm coming back to this now because I'm currently debugging the "ParFoldable" instance for SLMap, which is suffering from duplication related errors. (Probably unrelated though...)

Heh, this is a good testing methodology though to make sure things are really idempotent!

rrnewton added a commit that referenced this issue Dec 8, 2013
Interestingly, the excessive duplication is only on the SLMap
version (see issue #28).
@rrnewton
Copy link
Member Author

rrnewton commented Dec 8, 2013

If all the prereqs are installed, the simplest way to reproduce this failure (as of rev 1e2d1c3) is:

cd lvish/tests
make main
./Main_wfailing.exe -t handlr

You should see the failing test there.

rrnewton added a commit that referenced this issue Dec 10, 2013
global thresh function runs sequential on the same thread as addHandler.
In the next commit the interface of addHandler will change to reflect this.

Also, add a bunch of debugging related to the handler duplication test.
rrnewton referenced this issue Jan 25, 2014
and instead just be a Par action run on the same thread as addHandler.
All 57 enabled tests pass on one thread, but I'm seeing big problems on
multiple threads (~8/57 test failures).
rrnewton added a commit that referenced this issue Jan 25, 2014
introduced a nasty bug with two execs in a row.  This fixes that bug.

We are still seeing some deadlock failures on multiple threads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants