Giter Club home page Giter Club logo

direct-io's People

Contributors

jorangreef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

direct-io's Issues

Module won't build on Windows with Node <9.2.0

Thanks again for updating the Windows library. We are using Electron to build a Windows & OS X app, and since Electron ships with Node 7.9.0 built in the module won't compile (error shown below).

I realize O_DIRECT will only work on Node 9.2.0+, however it would be great to add least be able to install the library. Right now we have to use some crazy try / catch tricks to avoid errors when we require the library since we need it for OS X and even with that have some issues with newer versions of npm.

PS C:\Users\GoChip\gochip\GoChipPlayer-Electron\app> npm install
                                                                                                                        ChipPlayer-Electron\app\node_modules\.staging\@ronomon\queue-4d47975e\nod
> @ronomon/[email protected] install C:\Users\GoChip\gochip\GoChipPlayer-Electron\app\node_modules\@ronomon\direct-io
> node-gyp rebuild

C:\Users\GoChip\gochip\GoChipPlayer-Electron\app\node_modules\@ronomon\direct-io>if not defined npm_config_node_gyp (node "C:\Users\GoChip\scoop\apps\nodejs\7.10.1\node_modules\npm\bin\node-gyp-
bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Warning: Missing input files:
C:\Users\GoChip\gochip\GoChipPlayer-Electron\app\node_modules\@ronomon\direct-io\build\Release\binding.node
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  binding.cc
  win_delay_load_hook.cc
..\binding.cc(145): error C3861: 'uv_get_osfhandle': identifier not found [C:\Users\GoChip\gochip\GoChipPlayer-Electron\app\node_modules\@ronomon\direct-io\build\binding.vcxproj]
..\binding.cc(374): error C3861: 'uv_get_osfhandle': identifier not found [C:\Users\GoChip\gochip\GoChipPlayer-Electron\app\node_modules\@ronomon\direct-io\build\binding.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\GoChip\scoop\apps\nodejs\7.10.1\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:194:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Users\\GoChip\\scoop\\apps\\nodejs\\current\\node.exe" "C:\\Users\\GoChip\\scoop\\apps\\nodejs\\7.10.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuil
d"
gyp ERR! cwd C:\Users\GoChip\gochip\GoChipPlayer-Electron\app\node_modules\@ronomon\direct-io
gyp ERR! node -v v7.10.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Users\\GoChip\\scoop\\apps\\nodejs\\current\\node.exe" "C:\\Users\\GoChip\\scoop\\apps\\nodejs\\current\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! @ronomon/[email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1

Loop device, SG_GET_VERSION_NUM failed (Linux)

Trying to use getBlockDevice() on a loop device on Linux.

var blockdev = dio.getBlockDevice(fd, function(e) {
  console.error('Couldn\'t get block device: ' + JSON.stringify(e.message))
})

It gives me Couldn't get block device: "SG_GET_VERSION_NUM failed"

Is it expected?

OS X ignores F_NOCACHE if you do a cached read

Thanks for creating this library, it's perfect for what we need. I created a script to test doing direct IO on OS X. I'm reading a 240 MB file off an SD card, so the disk cache should be effectively non-existent.

Flag set to 1: 13.6s
Flag set to 1: 13.6s
Flag set to 0: 13.6s
Flag set to 0: 0.3s
Flag set to 1: 0.3s
Flag set to 1: 0.3s

It appears that as long as you do non-cached reads, you get direct IO, however the moment it's loaded in the cache, the F_NOCACHE flag gets ignored.

SD cards tend to be pretty unreliable, so we want to write files to the card and then immediately read them back to ensure the contents were written without any errors. I'm concerned that the file will still be in the filesystem cache even with the F_NOCACHE flag set since we just wrote it.

Also, it looks like you completed the work to support direct IO on Windows via libuv. Is that something that is ready to be implemented now? We'd love to turn this on for Windows as well.

const directIO = require('@ronomon/direct-io');

const path = '/path/to/file';
const cache = 1;
let fd, info;
info = fs.statSync(path);
const alignedSize = Math.ceil(info.size / 4096) * 4096;
const alignedBuffer = directIO.getAlignedBuffer(alignedSize, 4096);
console.log('Size', info.size, alignedSize);
fd = fs.openSync(path, 'r');
console.log('Set flag to', cache);
directIO.setF_NOCACHE(fd, cache, () => {
  fs.read(fd, alignedBuffer, 0, alignedSize, (err, bytesRead, buffer) => {
    console.log('Read', bytesRead);
    fs.closeSync(fd);
  });
});

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.