Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9346057
D3002.id10664.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D3002.id10664.diff
View Options
diff --git a/swh/graph/cli.py b/swh/graph/cli.py
--- a/swh/graph/cli.py
+++ b/swh/graph/cli.py
@@ -6,6 +6,7 @@
import aiohttp
import click
import logging
+import shutil
import sys
from pathlib import Path
@@ -334,6 +335,37 @@
webgraph.compress(graph_name, in_dir, out_dir, steps, conf)
+@cli.command(name="memcache")
+@click.option(
+ "--graph", "-g", required=True, metavar="GRAPH", help="compressed graph basename"
+)
+@click.option(
+ "--cache",
+ "-c",
+ required=True,
+ metavar="CACHE",
+ type=PathlibPath(),
+ help="memory cache path",
+)
+@click.pass_context
+def memcache(ctx, graph, cache):
+ """
+ Cache the mmapped files of the compressed graph in a tmpfs.
+
+ This command creates a new directory at the path given by CACHE that has the
+ same structure as the compressed graph basename, except it copies the files
+ that require fast/mmap access (.graph, .obl, .offsets) but uses symlinks
+ from the source for all the other files (.map, .bin, ...).
+ """
+ cache.mkdir()
+ for src in Path(graph).parent.glob("*"):
+ dst = cache / src.name
+ if src.suffix in (".graph", ".obl", ".offsets"):
+ shutil.copy2(src, dst)
+ else:
+ dst.symlink_to(src.resolve())
+
+
def main():
return cli(auto_envvar_prefix="SWH_GRAPH")
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 3:42 PM (2 w, 12 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3232868
Attached To
D3002: cli: add a cachemount command
Event Timeline
Log In to Comment