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

Allow interim reset of profile data #74

Open
wan54 opened this issue Mar 15, 2017 · 7 comments
Open

Allow interim reset of profile data #74

wan54 opened this issue Mar 15, 2017 · 7 comments
Assignees

Comments

@wan54
Copy link

wan54 commented Mar 15, 2017

EDIT: This issue originally was false bug report, but ended as a request for ability to reset profile numbers


calling clear() on a memoized function doesn't seem to work.

example:

let fn = null;

export const exportedFn = (dataArg) => {
  fn = fn || memoize((object) => {
    // code that uses object and dataArg; fn will be called recursively
  }, {serializer: (args) => JSON.stringify(args[0])})

  return fn;
};

setInterval(() => {
  // fn.clear(); // does not clear
  fn = null; // an alternative to clear() however the next fn invocation increases the Initial hit size by double, more or less, reported by memoize/profile
}, 30000);

any ideas why clear() does not have any effect?

Thanks

@medikoo
Copy link
Owner

medikoo commented Mar 15, 2017

@wan54 your example seems incomplete. Can you provide a complete test case, that exposes eventual issue?
In what you've shown, many things can happen.. e.g. external module may call exportedFn few times, while setInterval will clear cache only to last one generated.

@wan54
Copy link
Author

wan54 commented Mar 15, 2017

You're right. It's because only the last one the issue. I'm clearing as soon as fn() finishes. Thanks.

Is it expected though that the next fn invocation increases the Initial hit size

1. fn() call

Init      Cache   %Cache
864    622       41.86

2. fn.clear()

3. fn() call

Init      Cache   %Cache
1641   1167   41.56

4. fn.clear()

5. fn() call

Init      Cache   %Cache
2418   1712   41.45

@medikoo
Copy link
Owner

medikoo commented Mar 16, 2017

With clear you clear the cache totally, and you go back to initial state, so it's normal that next invocations will produce similar profile output as first one. Unless I don't understand something (?)

@wan54
Copy link
Author

wan54 commented Mar 16, 2017 via email

@medikoo
Copy link
Owner

medikoo commented Mar 17, 2017

@wan54 you mean, why counter was not reset after clear?

The profile functionality is global, it covers all memoized functions registered in a process, and doesn't have any reset counter function. Would you like to see it? I think it makes sense to add it

@wan54
Copy link
Author

wan54 commented Mar 19, 2017 via email

@medikoo
Copy link
Owner

medikoo commented Mar 20, 2017

Yes that'd be great. Thanks.

Ok Iet's make this issue about that. I'll leave it open until it's addressed

@medikoo medikoo changed the title clear cache Allow interim reset of profile data Mar 20, 2017
@medikoo medikoo assigned medikoo and unassigned wan54 Mar 20, 2017
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

No branches or pull requests

2 participants