Giter VIP home page Giter VIP logo

physfs_magicstream's Introduction

PhysFS fork with magic streams

This is an unofficial, non-supported, unmaintained fork of PhysFS with "magic streams", for those who might want that functionality.

It's based on stable-3.0 of physfs.

Magic streams can be used to improve load times of deterministic file i/o such as initial game loads or level loads.

It achieves this by storing all file i/o into a linear file, and then when loading using that file, all file i/o (file open, file close, file seek, file position tell) is more or less ignored, reading all of the input from a single file linearly.

The magic stream files can also be compressed for further reduction of disk i/o.

This approach made more sense back when games were played from spinning media, but current SSDs have reduced the need. However, clear benefits can be seen even on modern systems, because operating system file operations are actually rather slow. In a synthetic benchmark on a SSD system I could see a 4x speedup, but your mileage may vary.

The drawbacks of this approach are primarily a lot of hassle, adding a lot of fragility to updating the data files, and very likely more disk usage.

Usage:

  1. Make your application use physfs.
  2. Identify deterministic file i/o operations you want to speed up. Deterministic in this case means something that is always done the same way, in the same order.
  3. At the beginning of the file i/o operation block, open a file for writing and call the create magicstream call:
    PHYSFS_File *sf;
    sf = PHYSFS_openWrite("test.magicstream");
    PHYSFS_createMagicStream(sf);
  1. At the end of the file i/o operation block, call the close magicstream call:
    PHYSFS_closeMagicStream();
  1. Run your application, generating the magic stream file.
  2. Modify the application to open magic stream instead of creating it:
    PHYSFS_File *sf;
    sf = PHYSFS_openRead("test.magicstream");
    PHYSFS_openMagicStream(sf);
  1. The close call is the same as with the creation.

If you find this useful, plase do let me know. I am not, however, able to offer any support for this patch.

-- Jari Komppa, http://iki.fi/sol/

physfs_magicstream's People

Contributors

jarikomppa avatar

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.