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

Why LinkedHashMap? #44

Closed
shism2 opened this issue Nov 10, 2013 · 4 comments
Closed

Why LinkedHashMap? #44

shism2 opened this issue Nov 10, 2013 · 4 comments

Comments

@shism2
Copy link

shism2 commented Nov 10, 2013

Why not just use HashMap?

The reason I ask is because I looked at some benchmarks here:

http://www.artima.com/weblogs/viewpost.jsp?thread=122295

@sjudd
Copy link
Collaborator

sjudd commented Nov 10, 2013

Can you link the part of Glide you're talking about?

Assuming you mean for the lru memory cache, performance aside, we need the linked list to be able to tell which images we want to discard when our cache grows too large. Although it's certainly less performant than simpler maps, it's vastly more performant to use the linked list rather than try to use some other scheme to keep track of what to remove next.

It's also worth noting that in the grand scheme of things, even a 10x increase in the amount of time it takes to get or put from a map is likely to be insignificant relative to all of the other things that have to happen for an image to be loaded into memory and displayed.

@shism2
Copy link
Author

shism2 commented Nov 10, 2013

Understood

@shism2 shism2 closed this as completed Nov 10, 2013
@shism2 shism2 reopened this Nov 11, 2013
@shism2
Copy link
Author

shism2 commented Nov 11, 2013

What about CocurrentLinkedHashMap?

@sjudd
Copy link
Collaborator

sjudd commented Nov 12, 2013

Essentially because it's not in the standard libraries. There does appear to be an open source version, but the performance gain probably wouldn't be worth the additional dependency. If you're curious and want to try integrating it, please do feel free to do so and run some benchmarks. I'm not against the idea if there are significant performance gains.

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

3 participants