Giter Club home page Giter Club logo

during's People

Contributors

baruch avatar tchaloupka 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

Watchers

 avatar  avatar  avatar  avatar

during's Issues

prepCancel should allow to specify a user_data field

  1. There is no reason not to
  2. Having user_data == 0 (as it's now), will confuse my program, because 0 is a valid userData for normal requests (I am using ulong.max as magic value).
  3. Allows to handle cancels like other requests, e.g. return the result code etc.

Would you accept a PR?

how to implement flow-control

Hello @tchaloupka

Can you please help? Below you'll find simple code which demonstrate my problem. This code has two threads - main thread just submits NOP entries to SQ in a tight loop and Consumer thread consume these NOPs from CQ.
Expected result - program finish with next output:

Running ./test 
completions=10000000
submissions=10000000
overflow=   0

but instead I get some number of overflows and consumer loop never ends.
If I increase RING_SIZE to 4096 then I get expected result. So the question is - how can I avoid overflows and event loss.

Thanks!

$ uname -a
Linux igor-Zen 5.3.0-53-generic #47~18.04.1-Ubuntu SMP Thu May 7 13:10:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
import std.stdio;
import std.datetime;
import core.thread;
import during;

static long submissions, completions;
enum iterations = 10_000_000;
enum RING_SIZE = 32; 
void main()
{
    Uring io; 
    io.setup(RING_SIZE);

    void Consumer()
    {   
        // consume NOP events
        while(completions<iterations)
        {
            int r = io.wait(1);
            if(r==0)
            {
                io.popFront;
                completions++;
            }
        }
        writefln("completions=%d", completions);
    }   

    Thread consumer = new Thread(&Consumer).start;
    // produce NOP events
    foreach(i;0..iterations)
    {
        SubmissionEntry e;
        e.prepNop();
        e.user_data = i;
        while(io.full)
        {
            // short sleep while sq is full
            Thread.sleep(1.hnsecs);
        }
        io.put(e);
        io.submit();
        submissions++;
    }   
    writefln("submissions=%d", submissions);
    writefln("overflow=   %d", io.overflow);
    consumer.join();
}

Missing interface to set the SetupParameters

The only field that can be set is the flags one but if I want to control the sq_thread_cpu I can't.

I think it would make sense to have a second setup function that will take the whole struct as an argument and copy it over for the setup.

EFAULT when using prepWrite with heap allocated buffer

Thank you for writing such a nice interface to uring. I like the API a lot. However I cannot get it to work. Take this very simple example, adjusted from the readme. I should write "test" to a file opened with std.stdio : File:

#!/usr/bin/env dub
/+ dub.sdl:
	name "during-test"
    dependency "during" version="~>0.2.0"
+/
module examples.test_during;

import during;
import std.range : drop, iota;
import std.algorithm : copy, equal, map;
import std.stdio : File, writefln, writeln;
import std.string : representation;
import std.exception : enforce;
import std.array;

void main() 
{
    Uring io;
    auto res = io.setup();
    enforce(res >= 0, "Error initializing IO");
    
    File f = File("/tmp/test.txt", "wb");
    
    ubyte[] buffer = new ubyte[4];
    buffer[] = "test".representation[0 .. 4];
    writeln(buffer);
    SubmissionEntry entry;
    prepWrite(entry, f.fileno, buffer, 0);
    entry.user_data = 1;

    // chain operations
    res = io
        .put(entry) // whole entry as defined by io_uring
        .submit(1); // submit operations and wait for at least 1 completed

    enforce(res == 1); // 3 operations were submitted to the submission queue
    io.wait(1);
    enforce(!io.empty); // at least one operation has been completed
    
    foreach (ref CompletionEntry cqe; io) {
        writefln("user data=%s, result=%s", cqe.user_data, cqe.res);
    }
}

I get EFAULT (-14) as a result code for the operation. Do you have any pointers on what I am doing wrong?

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.