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

Initial Code to reduce parallel.Client caching #2340

Merged
merged 3 commits into from
Jan 18, 2013
Merged

Initial Code to reduce parallel.Client caching #2340

merged 3 commits into from
Jan 18, 2013

Conversation

jankatins
Copy link
Contributor

See #1131 for the discussion

Up to now it only adds a purge_client_cache() method and fixes two minor bugs.

This is probably not merge ready!

@travisbot
Copy link

This pull request passes (merged 41d3f075 into f4616c9).

@minrk
Copy link
Member

minrk commented Aug 29, 2012

Can you tweak it so that purge_hub_results and purge_local_results are called by local/remote switches in purge_results? That way there can be a single call for dropping everything, and a single docstring for people to look at for discarding unused data, whether it be on the Client or on the Hub.

@jankatins
Copy link
Contributor Author

I would argue against this: it would be confusing to have two different "interfaces" (hub "results" and client "cache") merged into in here and that replacing the original one:

What would purge_results(local=True, hub=False, jobs=[msg_ids...]) do? Or remove some kwargs, so that's only a switch between purge everything local and everything on the hub? Would this mean errors for users who update?

I would be more in favor to add a deprecation warning to the old purge_results method (I've actually looked if there are any deprecateddecorators used in IPython, but couldn't find anything).

Anyway: If you want to have a certain interface I have no problem implementing it. :-)

@minrk
Copy link
Member

minrk commented Aug 29, 2012

There are two reasons for this:

  1. users are already calling purge_results as it is now, expecting it to do the the functionality you are adding here, and being disappointed.
  2. purging the local cache should absolutely support purging subsets, just like the remote purge does. The local cache purge should support everything the remote one does (by ID, by engine ID, dump all).

So the choice is either

A) two methods with identical signatures for purging local and remote result caches
B) one method that does both / either based on args.

Honestly, I think both, where the existing purge_results() wraps the local/remote methods with default args that reproduces current behavior) makes the most sense. Further, the two names should reflect that they are simply remote/local versions of the same call (purge_results_on_hub and purge_client_caches do not accurately reflect this symmetry, perhaps purge_local_results and purge_hub_results).

The Hub is a cache of finished results, just like the local dict. It just happens to be remote.

Purging results is really just saying "I'm done with this data, and I don't want it taking up resources anymore". It's only a question of whose resources you want to stop taking up. The Client's, the Hub's, or both? I can think of no reason that dealing with the two should be different.

What would purge_results(local=True, hub=False, jobs=[msg_ids...]) do?

It should remove just those IDs from the local cache.

If you want to keep the current call (purge local cache, history and all) as something like client.forget_everything(), that's fine too. I imagine it is something people will want often enough to get its own call (I certainly want it when I do long running benchmarks).

@jankatins
Copy link
Contributor Author

Ok, will do.

After trying to understand the client-controller connections I would actually rename purge_hub_results() to purge_controller_results() so that the terminology "hub" (or scheduler) doesn't even show up: you use a cluster with a controller and engines and the client connects to the controller.

So my idea would be

  • client.purge_all_caches() # purges local and remote result caches and the history, no arguments
  • client.purge_local_results(...all or per ids...) # like the current purge_results interface
  • client.purge_controller_results(...all or per ids) # just a rename
  • client.purge_results(...all or per ids...) # convenience method for deleting both on local and on remote -> API Change as it deletes from local too.

Also change the docstrings to "purge the cached results" so that it is clear that it is a cache of already computed results.

@minrk
Copy link
Member

minrk commented Aug 29, 2012

On Wed, Aug 29, 2012 at 2:40 PM, JanSchulz notifications@github.com wrote:

Ok, will do.

After trying to understand the client-controller connections I would
actually rename purge_hub_results() to purge_controller_results() so that
the terminology "hub" (or scheduler) doesn't even show up: you use a
cluster with a controller and engines and the client connects to the
controller.

I don't agree on this one. The Controller is really a deprecated notion
from the old Twisted days. What we used to call a 'controller' is really a
collection of loosely associated processes - one Hub and several
Schedulers. The coupling of Hub/Scheduler lives entirely in the
ipcontroller startup script. Ultimately, it will be possible to add and
remove schedulers, which will be necessary for scaling to large numbers of
engines, and implementing better broadcast. I think the 'Controller' term
is actively detrimental to understanding the IPython cluster, and is what
should go away, not Hub.

So my idea would be

  • client.purge_all_caches() # purges local and remote result caches
    and the history, no arguments
  • client.purge_local_results(...all or per ids...) # like the current
    purge_results interface
  • client.purge_controller_results(...all or per ids) # just a rename
  • client.purge_results(...all or per ids...) # convenience method for
    deleting both on local and on remote -> API Change as it deletes from local
    too.

Also change the docstrings to "purge the cached results" so that it is
clear that it is a cache of already computed results.

Sounds good, with two minor adjustments:

  1. s/controller/hub
  2. rename purge_all_caches to something more generic/destructive like
    purge_everything. 'caches' is not accurate because it purges more than
    caches. It's actually removing the history and disabling a security
    feature, neither of which are accurately described as caches.


Reply to this email directly or view it on GitHubhttps://github.com//pull/2340#issuecomment-8142232.

The new methods clear the cached values and free some memory.

The whole thing is split into different methods to both clear the
client and the hub side.

Additionally fix some bugs in other parts of the code.
Signed-off-by: Jan Schulz <jasc@gmx.net>
@jankatins
Copy link
Contributor Author

All Tests which access the hub history fail with an error. I've no idea why :-(

======================================================================
ERROR: test_purge_hub_results (IPython.parallel.tests.test_client.TestClient)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\data\jschulz\workspace\ipython\IPython\parallel\tests\test_client.py", line 412, in test_purge_hub_results
    hist = self.client.hub_history()
  File "<string>", line 2, in hub_history
  File "C:\data\jschulz\workspace\ipython\IPython\parallel\client\client.py", line 70, in spin_first
    return f(self, *args, **kwargs)
  File "C:\data\jschulz\workspace\ipython\IPython\parallel\client\client.py", line 1776, in hub_history
    raise self._unwrap_exception(content)
RemoteError: TypeError(can't compare datetime.datetime to NoneType)

@jankatins jankatins closed this Sep 10, 2012
@jankatins jankatins reopened this Sep 10, 2012
If the inputs are empty, no msg_ids should be returned. So change the
test to not only check for None but also for empty lists.

Signed-off-by: Jan Schulz <jasc@gmx.net>
@Carreau
Copy link
Member

Carreau commented Sep 30, 2012

I think we haven't seen you posted a commit that fixed the test.
Pinging @minrk as he already reviewed the first part.

@jankatins
Copy link
Contributor Author

From my understanding the error comes from something in the hub history lookup code on the hub side, not from something in the client code: the exception is also in untouched codepaths (by this patches) and before any new code is called during this test case (side effect from other test cases due to "recycling" of the hub side?)

Unfortunately I have no idea how to debug this as I can't see where this error is raised. :-( Is there any way to get at the stacktrace of the exception on the hub side?

@Carreau
Copy link
Member

Carreau commented Jan 5, 2013

Trying to revive old PRs.

Should we do something in particular with this one ? assign someone ?

@minrk
Copy link
Member

minrk commented Jan 5, 2013

I'll pick up review in a week or so, just wrapping some things up right now. Assigning to myself.

@ghost ghost assigned minrk Jan 5, 2013
@minrk
Copy link
Member

minrk commented Jan 15, 2013

This looks good to me, thanks for your patience @JanSchulz!
Since I can't reproduce the RemoteError you mention,
and it is in a code path you didn't touch, I don't think we need to worry about it here.
I expect I know where it is (sorting / date comparisons in the Hub, or the Hub's DB object),
so I can have a look at that myself.

@JanSchulz if you don't have anything more to add here,
I will go ahead and merge.

@jankatins
Copy link
Contributor Author

I'm fine. Thanks for your help and comments with this PR!

minrk added a commit that referenced this pull request Jan 18, 2013
Initial Code to reduce parallel.Client caching

adds:

    client.purge_local_results
    client.purge_hub_results
    client.purge_results (does both above)
    client.purge_everything (includes history, etc.)
@minrk minrk merged commit 9d021a3 into ipython:master Jan 18, 2013
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Initial Code to reduce parallel.Client caching

adds:

    client.purge_local_results
    client.purge_hub_results
    client.purge_results (does both above)
    client.purge_everything (includes history, etc.)
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.

4 participants