Skip to content

Conversation

taooceros
Copy link
Member

The program plugin will generate same result for same query unless it has been reindex. Therefore, it would be possible to avoid duplicate calculation by creating a cache, since user mostly will use similar query.

@jjw24
Copy link
Member

jjw24 commented May 24, 2021

Great idea, will take a look later

@jjw24
Copy link
Member

jjw24 commented May 24, 2021

Have you by any chance compared performance with this change?

@taooceros
Copy link
Member Author

Have you by any chance compared performance with this change?

Well I believe the current program plugin is quite fast? In my computer, the average calculation time is under 20ms (shorter query can be shorter). When cached, the query time will be 0ms.

There will be some memory cost for the cache, but since Result is a quite simple class, the cost is under 50mb? That may require some extra testing.

@jjw24
Copy link
Member

jjw24 commented May 24, 2021

Well I believe the current program plugin is quite fast? In my computer, the average calculation time is under 20ms (shorter query can be shorter). When cached, the query time will be 0ms.

Yep very fast thanks to your changes 👍

There will be some memory cost for the cache, but since Result is a quite simple class, the cost is under 50mb? That may require some extra testing.

As in ram? If so this we might need to confirm how much larger because I have read some users are not too fond of the large memory footprint currently flow has.

@taooceros taooceros self-assigned this May 24, 2021
@taooceros
Copy link
Member Author

taooceros commented May 24, 2021

If memory is under higher consideration, we can use WeakReference to cache the result (which is almost zero cost because we need to create the List of Result even without the cache). Or we can use a more specific control over cache like what we have done in ImageCache.

@jjw24
Copy link
Member

jjw24 commented May 24, 2021

If memory is under higher consideration, we can use WeakReference to cache the result (which is almost zero cost because we need to create the List of Result even without the cache). Or we can use a more specific control over cache like what we have done in ImageCache.

Yeah the general feeling I get from user comments around this type of applications is that memory usage is quite high, so where possible we would want to minimise it. I was going to take a look at why exactly flow is taking up so much memory and whether it's justifiable as one of next project goals.

Do you think you can add to this change using WeakReference

@taooceros
Copy link
Member Author

If memory is under higher consideration, we can use WeakReference to cache the result (which is almost zero cost because we need to create the List of Result even without the cache). Or we can use a more specific control over cache like what we have done in ImageCache.

Yeah the general feeling I get from user comments around this type of applications is that memory usage is quite high, so where possible we would want to minimise it. I was going to take a look at why exactly flow is taking up so much memory and whether it's justifiable as one of next project goals.

Do you think you can add to this change using WeakReference

Yeah that's the easiest way.

@taooceros
Copy link
Member Author

It seems that the GC is really collecting eagerly, so only using a weakreference may not be a great option for caching. It will be collected after one or two GC quickly unless we keep typing the same keyword. Maybe it would be better to keep a stronger caching system.

@taooceros taooceros added the enhancement New feature or request label Jun 4, 2021
@taooceros taooceros added this to the 1.9.0 milestone Aug 9, 2021
Copy link
Member

@jjw24 jjw24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jjw24
Copy link
Member

jjw24 commented Aug 10, 2021

would this change bump up the memory usage slightly?

@taooceros
Copy link
Member Author

would this change bump up the memory usage slightly?

I think so, but probably not a lot.

@jjw24 jjw24 merged commit f3398c5 into dev Sep 23, 2021
@jjw24 jjw24 deleted the cacheProgramResult branch September 23, 2021 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants