Skip to content
Snippets Groups Projects
Commit d018f2a0 authored by roadscape's avatar roadscape
Browse files

bump up LRU post map to 2M entries

parent e1a504f3
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,7 @@ Precedence: CLI over ENV over hive.conf. Check `hive --help` for details. ...@@ -68,7 +68,7 @@ Precedence: CLI over ENV over hive.conf. Check `hive --help` for details.
### Hardware ### Hardware
- Focus on Postgres performance - Focus on Postgres performance
- 2GB of memory for hive itself (TODO: verify/limit max usage during initial sync) - 2.5GB of memory for `hive sync` process
- 200GB storage for database - 200GB storage for database
......
...@@ -18,6 +18,7 @@ class Posts: ...@@ -18,6 +18,7 @@ class Posts:
"""Handles critical/core post ops and data.""" """Handles critical/core post ops and data."""
# LRU cache for (author-permlink -> id) lookup # LRU cache for (author-permlink -> id) lookup
CACHE_SIZE = 2000000
_ids = collections.OrderedDict() _ids = collections.OrderedDict()
_hits = 0 _hits = 0
_miss = 0 _miss = 0
...@@ -56,7 +57,7 @@ class Posts: ...@@ -56,7 +57,7 @@ class Posts:
def _set_id(cls, url, pid): def _set_id(cls, url, pid):
"""Add an entry to the LRU, maintaining max size.""" """Add an entry to the LRU, maintaining max size."""
assert pid, "no pid provided for %s" % url assert pid, "no pid provided for %s" % url
if len(cls._ids) > 1000000: if len(cls._ids) > cls.CACHE_SIZE:
cls._ids.popitem(last=False) cls._ids.popitem(last=False)
cls._ids[url] = pid cls._ids[url] = pid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment