Giter Club home page Giter Club logo

p4vfs's Introduction

Introduction

Microsoft Virtual File System for Perforce (P4VFS)

The P4VFS is a Windows service that allows you to sync files from Perforce quickly using almost no disk space. The contents of a file will be download automatically on-demand when first needed. You can seamlessly mix any use of P4VFS virtual sync with regular Perforce sync's using P4V and p4.exe.

For example, you can use the P4VFS to perform a "virtual sync" to a Perforce filespec and it will complete relatively quickly, and the files will exist on machine as usual. However, the actual size of the files on disk will be zero, and the file contents will be downloaded on-demand during the first read operation.

Installation

You can install the latest signed release of P4VFS from here:

P4VFS.Setup

The entire history of release notes is included with the installer.

Release Notes

Supported operating systems

  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • Windows 8.1 (P4VFS 1.24.0.0 and earlier)

Technical Overview

P4VFS is a Windows service, driver, and console application that allows us to sync files from Perforce immediately, and then actually download the file contents on-demand. It introduces the concept of a "virtual" sync, where a file revision can be sync'ed from Perforce and will exist locally on disk with a correct size, but zero disk-size, until accessed. When first opened, the Windows NTFS file system will automatically download file's contents, and the file will be read as expected.

The P4VFS is intended to work perfectly seamless with regular p4 and p4v usage. There is no need for special perforce server configuration, special workspaces, or any other client settings. You can feel free to sync files immediately using p4.exe, or use p4vfs.exe to virtual sync zero sized "offline" files with contents downloaded on-demand.

Basic Usage

The main program that you'll use to do a virtual sync, and possibly other P4VFS operations, is p4vfs.exe.

C:\Program Files\P4VFS\p4vfs.exe

The tool has a very similar interface to p4.exe. If you ever need to terminate p4vfs.exe while in-progress, simply use Ctrl+C or Ctrl+Break from the terminal, or just terminate the process with the Windows Task Manager. A p4vfs sync will always terminate gracefully and always leave your client consistent with Perforce. Take a look at the command help:

p4vfs.exe help
p4vfs.exe help sync

Try syncing as usual:

p4vfs.exe sync //depot/tools/dev/...
p4vfs.exe sync //depot/tools/dev/...@600938
p4vfs.exe sync //depot/tools/dev/...#head  //depot/tools/release/...@599820

The tool respects P4CONFIG file usage, as well as supports typical configuration settings (just like p4.exe)

p4vfs.exe -c joe-pc-depot -u contonso\joe -p p4-contoso:1666 sync //depot/tools/dev/...

Build and Test

Build Requirments:

  1. Visual Studio 2022 version 17.5.0 or later
  2. Windows SDK version 10.0.22621.0 (22H2)
  3. Windows WDK version 10.0.22621.382 (22H2)

Details for installing Visual Studio 2022, the Windows Software Development Kit (SDK), and the Windows Driver Kit (WDK) can be found here:

Download the Windows Driver Kit

Instructions:

  1. Using Visual Studio 2022, open solution file P4VFS.sln
  2. Build solution configurations Release/Debug for regular user mode development including the current production signed driver binaries. Build solution configuration Release-Dev/Debug-Dev for local built, test signed, driver binaries.
  3. Run P4VFS.Setup project to install local build.

Testing:

  1. Full suite of unit tests can be run locally by first opening Visual Studio as Administrator, and building the P4VFS.sln solution

  2. In the P4VFS.Console project, set the debug command arguments to:

    p4vfs.exe test
    
  3. See the Development.md for details.

p4vfs's People

Contributors

jessk-msft avatar microsoftopensource avatar belkiss avatar dependabot[bot] avatar microsoft-github-operations[bot] avatar

Stargazers

Tim Leader avatar Derick Ostrenko avatar  avatar  avatar Seiya Ishibashi avatar  avatar Matthew Colecio avatar Roozbeh avatar jonn avatar Changlong.Zang avatar J.upter avatar 小强 avatar Manuel Köster | shadesoforange avatar Hal avatar Brett B avatar  avatar 朱辉 avatar ziaur avatar  avatar  avatar  avatar Paul Oliver avatar  avatar ShannonLiu avatar  avatar tzf-omkey avatar PassP avatar  avatar  avatar Thomas Schwalen avatar DogeBotZ avatar Mark Baker avatar Szymon Zak avatar Gary Innerarity avatar  avatar MIAIONE avatar Jason De Arte avatar MATYSIAK Hervé avatar Emilian Cioca avatar Piotr Mintus avatar  avatar Brandon Jones (Eduardo Valencia) avatar Media Explorer avatar Larson T. avatar RainsSoft avatar  avatar shyboy avatar atmgnd avatar Marwan Hilmi avatar Larry Weiner avatar  avatar  avatar  avatar QinMuYang avatar  avatar Fxtack avatar lvyhe avatar Fishverse avatar Key Zhang avatar  avatar Ali Salehi avatar Lee Seung Hu avatar Adrián Bíro avatar Kristján Valur Jónsson avatar Jesse Printz avatar  avatar Alex avatar キキジキ avatar Malte Dreschert avatar Dico avatar Claudia Doppioslash avatar Alexandre Jubert avatar  avatar  avatar AN avatar perfectplug avatar pedoc avatar  avatar  avatar John Schroedl avatar Sergey Makeev avatar Toke Jepsen avatar  avatar  avatar  avatar Kamil Dąbrowski avatar Sven Sackers avatar Konstantin Khomyakov avatar AICDG avatar  avatar Petr Matoušek avatar Liang Yi avatar Sun Pengju avatar Jim Knowler avatar  avatar Idan Beck avatar Fedya Zentsev avatar  avatar Paul Jarrett avatar Cristinel Patrascu avatar

Watchers

Malte Dreschert avatar James Cloos avatar Romain Toutain avatar Ryan DowlingSoka avatar .NET Foundation Contribution License Agreements avatar  avatar  avatar  avatar J.upter avatar  avatar Rafael Horbach avatar  avatar

p4vfs's Issues

Resident command doesn't support quiet logging

I have been doing some testing with P4VFS to investigate how we can utilize it as part of our user syncs. One of the key aspects for us is the ability to re-virtualize any part of a workspace on demand via p4vfs resident -v.

Unlike the sync command, it appears the resident command doesn't support quiet logging? Even after adding the "-q" parameter to the resident command, it presents that it is doing a force|quiet sync but still presents the sync log anyway. (See image below)

image

This is not ideal as if we are re-virtualizing an entire workspace, the time taken for this grows exponentially if we don't use quiet logging as the resident command will print every file that has been virtually synced to it's #have revision. This takes a while in a large depot.

p4vfs.service.exe,A few days later, the driver disconnected,I want to know what are the possible reasons

ServiceListener::SrvConnectToDriver Failed to SrvConnectToDriver [0x0] Retry [1]
ServiceListener::SrvConnectToDriver Failed to SrvConnectToDriver [0x0] Retry [2]
ServiceListener::SrvConnectToDriver Failed to SrvConnectToDriver [0x0] Retry [3]
ServiceListener::SrvConnectToDriver Failed to SrvConnectToDriver [0x0] Retry [4]
ServiceListener::SrvConnectToDriver Failed to SrvConnectToDriver [0x0] Retry [5]
ServiceListener::SrvConnectToDriver Failed to SrvConnectToDriver [0x0] Retry [6]
ServiceListener::SrvConnectToDriver Failed to SrvConnectToDriver [0x0] Retry [7]
ServiceListener::SrvConnectToDriver Failed to SrvConnectToDriver [0x0] Retry [8]

Compile P4VFS.Setup Then Setup Error Unless Add Setting.Xml

When I download the official installation package, it works fine. However, when I try to install the package generated from compiling the code, it says that some files cannot be found. After I put the Setting.xml file in the same directory, the installation succeeds. Is this reasonable? Has the official installation package already compiled the xml file into the program?

Query Size on disk

Hello,
first, thank you for sharing and maintaining p4vfs, it's very cool.

I'd like to ask if there's a way to programmatically query the Size on disk that I can see in the folder properties window. I'd like to know how much space a given p4vfs-managed directory takes on a disk.

I've tried various approaches, but without success. Mentioning some below:

  • CMD's dir command reports only the full size
  • Git BASH's du command reports the full size and hydrates files in the process
  • Sysinternals' du command reports both Size and Size on disk, but the latter is incorrect (there's a non-zero value)
  • Python's os.stat(file_path).st_size returns the full size

Best,
Juraj

Unicode Filename output does not display properly in the console window

Performing a perforce sync on files with unicode characters in their names/paths results in incorrect output during sync.

This issue may also affect other file operations.

Tested on both CMD, and PowerShell/Windows Terminal
image
image

Sync completes successfully & properly, but output leads users to believe something failed or was incorrect.

P4VFS Driver offline

When I used the P4V client to create a new workspace and pulled it using P4VFS, I found that the P4VFS driver was offline

Text file metadata for dehydrated files do not match the hydrated metadata

I noticed that the file size before and after hydration differs. This causes unexpected things to happen in some cases. For example:

 Volume in drive D is Data
 Volume Serial Number is F24C-78F7

 Directory of d:\FN2\Engine\Source

10/03/2023  09:30               421 UnrealClient.Target.cs
10/03/2023  09:30               448 UnrealEditor.Target.cs
10/03/2023  09:30               463 UnrealGame.Target.cs
10/03/2023  09:30             (455) UnrealServer.Target.cs
               4 File(s)          1,787 bytes

d:\FN2\Engine\Source>more UnrealServer.Target.cs
// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

[SupportedPlatforms(UnrealPlatformClass.Server)]
public class UnrealServerTarget : TargetRules
{
    public UnrealServerTarget(TargetInfo Target) : base(Target)
        {
                Type = TargetType.Server;
                IncludeOrderVersion = EngineIncludeOrderVersion.Latest;
                BuildEnvironment = TargetBuildEnvironment.Shared;
                ExtraModuleNames.Add("Unreal

d:\FN2\Engine\Source>more UnrealServer.Target.cs
// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

[SupportedPlatforms(UnrealPlatformClass.Server)]
public class UnrealServerTarget : TargetRules
{
    public UnrealServerTarget(TargetInfo Target) : base(Target)
        {
                Type = TargetType.Server;
                IncludeOrderVersion = EngineIncludeOrderVersion.Latest;
                BuildEnvironment = TargetBuildEnvironment.Shared;
                ExtraModuleNames.Add("UnrealGame");
        }
}

d:\FN2\Engine\Source>dir Unreal*
 Volume in drive D is Data
 Volume Serial Number is F24C-78F7

 Directory of d:\FN2\Engine\Source

10/03/2023  09:30               421 UnrealClient.Target.cs
10/03/2023  09:30               448 UnrealEditor.Target.cs
10/03/2023  09:30               463 UnrealGame.Target.cs
10/03/2023  09:30               471 UnrealServer.Target.cs
               4 File(s)          1,803 bytes
               0 Dir(s)  3,100,296,794,112 bytes free

As you can see, the unhydrated file size is reported as 455 and the hydrated file size is 471. The difference is presumably because p4 stores text files in a normalized form on the server and transcodes it according to client settings as part of the syncing process.

The end result is that in this case more will only do a partial read of the file the first time, but the second time it reads the entire file. Many other processes still function as expected, which I assume means they just keep reading until EOF instead of checking the file size up front.

Incomplete support for filename characters on non-unicode servers

Experienced an error syncing today on a file with an accent character [specifically é] in its name. Virtual syncs result in a file with a � character in its place. Opening the file results in errors (probably because p4vfs has trouble figuring out the actual file name to force sync).

As a workaround force syncing using the normal p4 method worked fine.

P4VFS and Windows System for Linux Compatibility

I have used P4VFS on Windows to sync to the latest version of my project (p4vfs sync ...#head). However, I'm using VSCode running under WSL2/Ubuntu-20.04 to edit files. When I try to access the files using VSCode or Ubuntu command line, then I only see zeros in the file:

If I use a native Windows program to read the file, then I can see the actual contents of the file in WSL...

$ od -tx1 SourceCode.cc
0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0213720 00 00 00 00 00 00 00 00 00 00 00
0213733

$ /mnt/c/windows/system32/cmd.exe <<< "type sourceCode.cc" &> /dev/null
$ od -tx1 SourceCode.cc
0000000  2f  2f  20  24  49  64  3a  20  ...
...
0213720  53  74  61  74  65  3b  0a  7d  0a 
0213733

Is it possible to make this run seamlessly under WSL? (i.e. without the need to use a windows native program to trigger P4VFS)?

Note: (I had previously opened this up under Discussion, but think it is more suited to an issue)

Command sync -r fails for file with filetype <unicode> on perforce

Hi, thanks for the awesome work on p4vfs!
I would like to report an issue I had when testing out p4vfs. I found out an solution, but wanted to check if there is a better fix, or if I missed something for my setup.

  • Background
    Perforce server is in Unicode mode, Client P4CHARSET is set to utf8.

  • Issue
    If a file unicode_test.txt is of unicode filetype on perforce, then following command would fail.
    p4vfs.exe sync -r -f //depot//unicode_test.txt
    And gives the error: - Translation of file content failed near line ...
    The same command in p4 would succeed:
    p4 sync -f //depot//unicode_test.txt
    The same p4vfs command in local mode would also succeed:
    p4vfs.exe sync -r -f -t //depot//unicode_test.txt
    Just in case I attached the file for my test there: UnicodeTest.txt

  • Investigation
    By outputing m_P4->m_ClientApi->GetCharset().Text() in FDepotClient::Connect(const DepotConfig& config), I found the issue.
    In p4vfs.exe, the FDepotClient is properly picking up P4CHARSET settings and is set to utf8. However in P4VFS.Service.exe, it does not pick up P4CHARSET, and charset is set to auto. I'm not sure why, but this is the reason we have translation problem using sync command in service mode, but not in local mode.

  • Fix
    Added the following in FDepotClient::Connect(const DepotConfig& config)

DepotString charset = GetEnvImpersonated(DepotConstants::P4CHARSET); 
if (charset.empty() == false) 
{ 
    m_P4->m_ClientApi->SetCharset(charset.c_str()); 
} 

Much appreciated if you can share any insight on this problem. Thank you.

How can i sync?

I opened the CMD with administrator. Then i set the $P4PORT, $P4CLIENT and $P4USER variable. I run the p4vfs.exe login command and then login to the perforce with password.
I want to sync my debot with p4vfs.exe sync //myprojects/projectname/username/folder/name/... command.
But the p4vfs always crash with sync action:

P4VFS version 1.24.2.0
Virtual Sync: ["//myprojects/projectname/username/folder/name/..."] Normal Atomic @999999
Started at [03/24/2023-17:24:52] version [1.24.2.0]
1 Modification messages to act on.
Unsupported sync action: None <--- ERROR
Virtual Sync Summary:
Total Files: 1 / 1
Total Time: 0 sec (0.656)
Virtual Mod Time: 0 sec
Resident Mod Time: 0 sec
Virtual File Size: 0 bytes
Disk File Size: 0 bytes

and here is my p4vfs.exe info output:
P4VFS version 1.24.2.0
P4 UserName: username
P4 ClientName: p4vfs
P4 ClientHost: DESKTOP999999
P4 ClientRoot: c:\Share
P4 ClientStream:
P4 ServerAddress: perforceip:1999
P4 ServerVersion: P4D/LINUX26X86_64/2021.1/2313999 (2022/07/15)
P4 CaseHandling: sensitive
P4VFS CurrentVersion: 1.24.2.0
P4VFS ServiceVersion: 1.24.2.0
P4VFS DriverVersion: 1.24.0.0
P4VFS DriverReady: True
P4VFS ServiceReady: True
P4VFS SystemReady: True

SocketModelClient exception

I tried using p4vfs to populate a large tree, and after a few minutes it terminated with an error:

P4VFS version 1.24.0.0
Virtual Sync: ["XyzGame/..."] Quiet Single @24588784
SocketModelClient.SendCommand exit with exception: One or more errors occurred.

The tree appears to be complete but the fact that the command errored out is a bit concerning. I have not yet looked at the code so don't know how easy it might be to either back out all changes to the file system or add retry/resume logic somehow.

The server log contains the following

-03/10/2023-09:23:18::<Error> - SocketModelLogDevice.WriteDevice exception: One or more errors occurred.
-03/10/2023-09:23:18::<Info> - //Xyz/Main/Engine/Content/Internationalization/EFIGSCJK/icudt64l/lang/en_LR.res#1 - installed as d:\FN2\Engine\Content\Internationalization\EFIGSCJK\icudt64l\lang\en_LR.res
-03/10/2023-09:23:18::<Info> - Aborting Sync from DepotClient fault
-03/10/2023-09:23:18::<Info> - Aborting Sync from DepotClient fault
-03/10/2023-09:23:18::<Info> - Aborting Sync from DepotClient fault
-03/10/2023-09:23:18::<Info> - Aborting Sync from DepotClient fault
-03/10/2023-09:23:18::<Info> - Aborting Sync from DepotClient fault
-03/10/2023-09:23:18::<Info> - Aborting Sync from DepotClient fault
-03/10/2023-09:23:18::<Info> - Aborting Sync from DepotClient fault
-03/10/2023-09:23:18::<Info> - Aborting Sync from DepotClient fault
-03/10/2023-09:23:18::<Error> - SocketModelServer.HandleClientConnection exiting with exception: One or more errors occurred.

What is the best way to add this to P4V?

In P4V I can add it as a Custom tool, but if I select Run tool in terminal window, I can see the error logs, but no way to know when it's finished. If I also check Close window upon completion, then I kinda get a clue when it's finished (the window disappears), but then I can't read any errors.

If I don't select Run tool in terminal window, then the output is not visible anywhere, so that's not great either.

Also when using this as a P4V Custom Tool, I couldn't find a way to select just some folders and run p4vfs sync on those. It only shows up in the context menu when I select the workspace root folder. If I add %f or %F to the command line args ( those the only two that are using workspace syntax), then it doesn't show up in the context menu of any folders.

I'd be interested to learn how others integrated this to their workflow.

P4VFS Download File Size Acquisition Abnormal

After I use P4VFS to download a file, the size obtained through the stat function or the size function of the filesystem is wrong,Only after the file is actually downloaded, the obtained size is correct

Sync using an arguments file fails frequently. [p4vfs -x {file} sync]

We very heavily rely on argument files when performing a syncing using p4.exe. It allows us to filter out unnecessary files. When we ported over to p4vfs.exe we continued to use an argument file. However I have recently noticed that they don't always succeed.

The more files to sync, the greater the chance of failure. I cannot tell if there is a safe minimum.

This seems to only occur when using an arguments file. I have not been able to reproduce the issue without an arguments file. sync and populate with an arguments file both have the same issue.

At around 25,000 files I see about a 1/6 success rate.

When it fails I have seen the following:

  • Exit code will always be 1
  • All files are missing. I have not encountered a partial sync.
  • The p4 have table may sometimes be updated
  • The error below may sometimes be printed out
  • It might fail immediately, or it may first print out all of the files in the arguments file and then after a while fail
SocketModelClient.SendCommand exit with exception: One or more errors occurred.

I have attached a powershell script that I have been using to verify this. To use this script, you will have to have your p4 environment set up so that executing p4vfs sync would just start a sync.

# Tests p4vfs populate using an argument file to perform the sync
# .\p4vfs-test.ps1 -max 10000 will limit the sync to 10000 files
# .\p4vfs-test.ps1 -nofile will not use an argument file
# .\p4vfs-test.ps1 -sync will use sync instead of populate

p4vfs-test.ps1.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.