Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Slowdown with two indices (using tmpfs) #482

Closed
eddie-scio opened this issue May 21, 2020 · 4 comments
Closed

Slowdown with two indices (using tmpfs) #482

eddie-scio opened this issue May 21, 2020 · 4 comments

Comments

@eddie-scio
Copy link

I've been mounting a tmpfs in a Google App Engine Flex instance (after looking through a couple of issues in this repo that suggested this) to ensure everything is fully mmapped.

Recently, I made a change where my server is loading two Annoy indices -- I've tried both allocating two tmpfs and one larger tmpfs, the total volume of which is much larger than it needs to be to load both indices into memory.

However, simply keeping index 2 loaded has a ~2x slowdown at 50% on .retrieve() calls to index 1 (whether they're loaded from the same tmpfs or two separate ones). Is is possible there are some library-level locks or logic that prevent multiple indices from being fully mmapped on the same machine?

@eddie-scio eddie-scio changed the title Slowdown with two indicse (using tmpfs) Slowdown with two indices (using tmpfs) May 21, 2020
@erikbern
Copy link
Collaborator

It's possible the page cache in the kernel simply keeps things on disk until they are fully "warmed up". You can try to use the prefault flag, or as another option, hit the second index with a bunch of random queries when you load it to force the kernel to put it in RAM as opposed to disk

@eddie-scio
Copy link
Author

eddie-scio commented May 22, 2020

I'm using tmpfs for the whole purpose of keeping it in RAM (as opposed to doing the various warmup and prefault strategies described in other issues) -- taking this advice. Are you saying that it's possible simply loading the index from tmpfs might still not be enough to keep it fully loaded in RAM?

I'll also shoot @sonots an email, seems like he might have a better idea.

@erikbern
Copy link
Collaborator

I don't know how tmpfs works, but if your computer has swap enabled, then I think it's hard to know whether it will "truly" be in RAM.

There's definitely no locking going on inside Annoy!

@eddie-scio
Copy link
Author

There's definitely no locking going on inside Annoy!

That's useful to know, thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants