Rust的git2库支持将存储库克隆到内存中吗?

huangapple go评论92阅读模式
英文:

Does Rust git2 library support cloning repositories into memory?

问题

我想将GitHub存储库克隆到我的内存中
但似乎找不到支持克隆到内存的任何函数
使用mempack或odb是否可行

我尝试使用odb或mempack来实现克隆到内存
我问了ChatGPT,但代码无效
也无法将存储库克隆到虚拟文件系统中

英文:

I want to clone the github repository into my memory
But I don't seem to find any function that supports cloning to memory
Is this possible with mempack or odb

I tried to use odb or mempack to implement cloning to memory
I asked ChatGPT, but the code was invalid
It is also not possible to clone the repository to the virtual filesystem

答案1

得分: 1

我不认为这是开箱即用的。libgit2访问文件系统上的文件,虽然你当然可以实现一个内存后端存储作为ODB,但我认为这不是默认实现的。

一般来说,Git存储库的内存存储不如你想象的有用,因为许多存储库都很大,会占用大量内存。即使是普通的命令行Git进程(或libgit2)也可以映射大量内存来读取包并处理对象,所以你的内存剩余量非常有限,无法完全存储数据在RAM中。

如果你的目标只是提高性能,你可以在系统上挂载一个ramdisk,并将存储库克隆到其中。如何做这取决于你的操作系统;在Linux上,文件系统类型是tmpfs

英文:

I don't believe this is possible out of the box. libgit2 accesses files on the file system, and while you certainly could implement a memory-backed storage as an ODB, I don't think this is implemented by default.

In general, memory-based storage for Git repositories is a lot less useful than you think, because many repositories are large and would consume very large amounts of memory. Even a normal command-line Git process (or libgit2) can map large amounts of memory to read packs and work with objects, so that leaves you with substantially less memory to store data entirely in RAM.

If your goal is to simply improve performance, you can mount a ramdisk on your system and clone a repository to that. How you do that is dependent on your operating system; on Linux, the file system type is tmpfs.

huangapple
  • 本文由 发表于 2023年8月5日 00:07:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76837575.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定