Code Monkey home page Code Monkey logo

iouring-go's Introduction

What is io_uring

io_uring

io_uring-wahtsnew

LWN io_uring

Lord of the io_uring

【译】高性能异步 IO —— io_uring (Effecient IO with io_uring)

Go 与异步 IO - io_uring 的思考

Features

  • register a file set for io_uring instance
  • support file IO
  • support socket IO
  • support IO timeout
  • link request
  • set timer
  • add request extra info, could get it from the result
  • set logger
  • register buffers and IO with buffers
  • support SQPoll

OS Requirements

  • Linux Kernel >= 5.6

Installation

go get github.com/iceber/iouring-go

doc

Quickstart

package main

import (
        "fmt"
        "os"

        "github.com/iceber/iouring-go"
)

var str = "io with iouring"

func main() {
        iour, err := iouring.New(1)
        if err != nil {
                panic(fmt.Sprintf("new IOURing error: %v", err))
        }
        defer iour.Close()

        file, err := os.Create("./tmp.txt")
        if err != nil {
                panic(err)
        }

        ch := make(chan iouring.Result, 1)

        prepRequest := iouring.Write(int(file.Fd()), []byte(str))
        if _, err := iour.SubmitRequest(prepRequest, ch); err != nil {
                panic(err)
        }

        result := <-ch
        i, err := result.ReturnInt()
        if err != nil {
                fmt.Println("write error: ", err)
                return
        }

        fmt.Printf("write byte: %d\n", i)
}

Request With Extra Info

prepRequest := iouring.Write(int(file.Fd()), []byte(str)).WithInfo(file.Name())

request, err := iour.SubmitRequest(prepRequest, nil)
if err != nil {
    panic(err)
}

<- request.Done()
info, ok := request.GetRequestInfo().(string)

Cancel Request

prepR := iouring.Timeout(5 * time.Second)
request, err := iour.SubmitRequest(prepR, nil)
if err != nil {
    panic(err)
}

if _, err := request.Cancel(); err != nil{
    fmt.Printf("cancel request error: %v\n", err)
    return
}

<- request.Done()
if err := request.Err(); err != nil{
    if err == iouring.ErrRequestCanceled{
        fmt.Println("request is canceled"0
        return
    }
    fmt.Printf("request error: %v\n", err)
    return
}

Submit multitude request

var offset uint64
buf1 := make([]byte, 1024)
prep1:= iouring.Pread(fd, buf1, offset)

offset += 1024
buf2 := make([]byte, 1024)
prep2:= iouring.Pread(fd, buf1, offset)

requests, err := iour.SubmitRequests([]iouring.PrepRequest{prep1,prep2}, nil)
if err != nil{
    panic(err)
}
<- requests.Done()
fmt.Println("requests are completed")

requests is concurrent execution

Link request

var offset uint64
buf := make([]byte, 1024)
prep1 := iouring.Pread(fd, buf1, offset)
prep2 := iouring.Write(int(os.Stdout.Fd()), buf)

iour.SubmitLinkRequests([]iouring.PrepRequest{prep1, prep2}, nil)

Examples

cat

concurrent-cat

cp

request-with-timeout

link-request

link-with-timeout

timer

echo

echo-with-callback

TODO

  • add tests
  • arguments type (eg. int and int32)
  • set logger

iouring-go's People

Contributors

avagin avatar cafxx avatar iceber avatar ifplusor avatar paulcacheux avatar spikat avatar sungup avatar sylr 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  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  avatar  avatar  avatar

iouring-go's Issues

demo for performance advantage

I'm looking into using io_uring to improve the performance for some heavy workload. After tried the examples, they didn't show some performance advantage comparing to plain syscalls. For example, the cp example is not faster than builtin cp command, which uses read and write syscalls.

Should we have some examples to demo the performance of io_uring?

Confusion With multiple go routines

@Iceber

just wanted to know can I use and share a single instance with multiple go routines??? If I am doing it my app randomly gets stuck and it seems to have a deadlock scenario…

Slower reads using iouring than os for ReadFile type operations at all file sizes

Code discussed here can be found at:
https://github.com/johnsiilver/iouringfile

Expectations:
I expected faster Reads with io_uring, but found it to be slower in every benchmark. This could be due to multiple factors:

  • I don't know what I'm doing, which is easily possible
  • Single buffer reads, no matter what the size, have no speed advantage in io_uring vs epoll
  • Go's concurrency model and io_uring aren't good fits
  • There are bugs in this package

I could not get WithEQPoll() to work as I documented in another bug. Most benchmarks on io_uring show significant savings without it and multipliers if enabled. I found no examples in this repo that used it and using sourcegraph I could find no external repos that used it: https://sourcegraph.com/search?q=context%3Aglobal+WithSQPoll%28%29&patternType=standard&sm=1&groupBy=repo

Here are various benchmarks I ran on an Amazon VM running Ubnutu (I don't have any native linux boxes on bare metal).

Initially used runtime.LockOSThread() for my event loop, which yielded these results:

goos: linux
goarch: amd64
pkg: github.com/johnsiilver/iouringfile
BenchmarkReadFile/OS_1KiB-2 108146 11022 ns/op
BenchmarkReadFile/OS_16KiB-2 72103 16457 ns/op
BenchmarkReadFile/OS_32KiB-2 51840 23956 ns/op
BenchmarkReadFile/OS_64KiB-2 33656 36336 ns/op
BenchmarkReadFile/OS_128KiB-2 18320 66011 ns/op
BenchmarkReadFile/OS_512KiB-2 5438 239014 ns/op
BenchmarkReadFile/OS_1MiB-2 4478 277964 ns/op
BenchmarkReadFile/OS_10MiB-2 326 3560091 ns/op
BenchmarkReadFile/OS_100MiB-2 24 45336144 ns/op
BenchmarkReadFile/OS_1GiB-2 2 533741636 ns/op
BenchmarkReadFile/IOURING_1KiB_-2 20305 50978 ns/op <- Almost 5x slower
BenchmarkReadFile/IOURING_16KiB-2 19050 59990 ns/op
BenchmarkReadFile/IOURING_32KiB-2 18846 67469 ns/op
BenchmarkReadFile/IOURING_64KiB-2 14314 81480 ns/op
BenchmarkReadFile/IOURING_128KiB-2 10000 162159 ns/op
BenchmarkReadFile/IOURING_512KiB-2 2743 456180 ns/op
BenchmarkReadFile/IOURING_1MiB-2 1564 757464 ns/op
BenchmarkReadFile/IOURING_10MiB-2 278 4013378 ns/op
BenchmarkReadFile/IOURING_100MiB-2 25 42532022 ns/op
BenchmarkReadFile/IOURING_1GiB-2 2 627497596 ns/op <- Still slower, but at least not 5x

Improved with removal of the the lock, and got:

goos: linux
goarch: amd64
pkg: github.com/johnsiilver/iouringfile
cpu: Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
BenchmarkReadFile/OS_1KiB-2 104364 11190 ns/op
BenchmarkReadFile/OS_16KiB-2 70800 16552 ns/op
BenchmarkReadFile/OS_32KiB-2 48690 24940 ns/op
BenchmarkReadFile/OS_64KiB-2 29878 37414 ns/op
BenchmarkReadFile/OS_128KiB-2 17282 72963 ns/op
BenchmarkReadFile/OS_512KiB-2 4719 227736 ns/op
BenchmarkReadFile/OS_1MiB-2 3877 285898 ns/op
BenchmarkReadFile/OS_10MiB-2 326 3557621 ns/op
BenchmarkReadFile/OS_100MiB-2 24 44912433 ns/op
BenchmarkReadFile/OS_1GiB-2 2 552437373 ns/op
BenchmarkReadFile/IOURING_1KiB_-2 56310 21982 ns/op <- Almost 2x slower
BenchmarkReadFile/IOURING_16KiB-2 43414 28685 ns/op
BenchmarkReadFile/IOURING_32KiB-2 34561 34932 ns/op
BenchmarkReadFile/IOURING_64KiB-2 24840 45259 ns/op
BenchmarkReadFile/IOURING_128KiB-2 17257 84012 ns/op
BenchmarkReadFile/IOURING_512KiB-2 2972 375026 ns/op
BenchmarkReadFile/IOURING_1MiB-2 --- FAIL: BenchmarkReadFile/IOURING_1MiB-2
benchmark_test.go:148: bad file descriptor
BenchmarkReadFile/IOURING_10MiB-2 273 4144841 ns/op
BenchmarkReadFile/IOURING_100MiB-2 25 42300929 ns/op
BenchmarkReadFile/IOURING_1GiB-2 2 632643157 ns/op

NOTE: For this one run I got a bad file descriptor error, which I suspect is a bug in iouring-go, but it hasn't happened again so I can't confirm it is. It is also just as likely I did something silly.

I removed the event loop and pre-allocation of return channels and just did the iouring calls inside ReadFile itself, which yielded worse results:

goos: linux
goarch: amd64
pkg: github.com/johnsiilver/iouringfile
cpu: Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
BenchmarkReadFile/OS_1KiB-2 105922 11093 ns/op
BenchmarkReadFile/OS_16KiB-2 73557 16656 ns/op
BenchmarkReadFile/OS_32KiB-2 53299 22797 ns/op
BenchmarkReadFile/OS_64KiB-2 36957 36118 ns/op
BenchmarkReadFile/OS_128KiB-2 19062 66646 ns/op
BenchmarkReadFile/OS_512KiB-2 5625 234702 ns/op
BenchmarkReadFile/OS_1MiB-2 3667 318104 ns/op
BenchmarkReadFile/OS_10MiB-2 325 3617478 ns/op
BenchmarkReadFile/OS_100MiB-2 25 43581482 ns/op
BenchmarkReadFile/OS_1GiB-2 2 552909954 ns/op
BenchmarkReadFile/IOURING_1KiB_-2 11348 97162 ns/op <- 9x slower, so by far my worse idea
BenchmarkReadFile/IOURING_16KiB-2 10000 111489 ns/op
BenchmarkReadFile/IOURING_32KiB-2 10104 109561 ns/op
BenchmarkReadFile/IOURING_64KiB-2 6470 186679 ns/op
BenchmarkReadFile/IOURING_128KiB-2 7903 220638 ns/op
BenchmarkReadFile/IOURING_512KiB-2 2329 614333 ns/op
BenchmarkReadFile/IOURING_1MiB-2 1212 896992 ns/op
BenchmarkReadFile/IOURING_10MiB-2 255 4715659 ns/op
BenchmarkReadFile/IOURING_100MiB-2 25 43412745 ns/op
BenchmarkReadFile/IOURING_1GiB-2 2 631509550 ns/op
PASS
ok github.com/johnsiilver/iouringfile 47.412s

So I went back to the previous and measured the allocs:

goos: linux
goarch: amd64
pkg: github.com/johnsiilver/iouringfile
cpu: Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
BenchmarkReadFile/OS_1KiB-2 106183 11050 ns/op 1560 B/op 6 allocs/op
BenchmarkReadFile/OS_16KiB-2 76435 15818 ns/op 18840 B/op 6 allocs/op
BenchmarkReadFile/OS_32KiB-2 54651 23067 ns/op 41368 B/op 6 allocs/op
BenchmarkReadFile/OS_64KiB-2 37386 32897 ns/op 74136 B/op 6 allocs/op
BenchmarkReadFile/OS_128KiB-2 20600 67160 ns/op 139672 B/op 6 allocs/op
BenchmarkReadFile/OS_512KiB-2 5833 213830 ns/op 532888 B/op 6 allocs/op
BenchmarkReadFile/OS_1MiB-2 3462 339948 ns/op 1057176 B/op 6 allocs/op
BenchmarkReadFile/OS_10MiB-2 332 3739868 ns/op 10494360 B/op 6 allocs/op
BenchmarkReadFile/OS_100MiB-2 24 44693581 ns/op 104866200 B/op 6 allocs/op
BenchmarkReadFile/OS_1GiB-2 2 556463702 ns/op 1073750424 B/op 6 allocs/op
BenchmarkReadFile/IOURING_1KiB_-2 54560 21808 ns/op 1904 B/op 12 allocs/op
BenchmarkReadFile/IOURING_16KiB-2 39284 30109 ns/op 17264 B/op 12 allocs/op
BenchmarkReadFile/IOURING_32KiB-2 32830 34880 ns/op 33648 B/op 12 allocs/op
BenchmarkReadFile/IOURING_64KiB-2 24984 45831 ns/op 66416 B/op 12 allocs/op
BenchmarkReadFile/IOURING_128KiB-2 15892 70437 ns/op 131952 B/op 12 allocs/op
BenchmarkReadFile/IOURING_512KiB-2 5031 278818 ns/op 525169 B/op 12 allocs/op
BenchmarkReadFile/IOURING_1MiB-2 1681 725118 ns/op 1049459 B/op 12 allocs/op
BenchmarkReadFile/IOURING_10MiB-2 313 3600860 ns/op 10486647 B/op 12 allocs/op
BenchmarkReadFile/IOURING_100MiB-2 25 43821402 ns/op 104858486 B/op 12 allocs/op
BenchmarkReadFile/IOURING_1GiB-2 2 629058212 ns/op 1073742704 B/op 12 allocs/op

There is some lower byte allocations, but nothing to call home about, once you get over 1KiB.

I noticed that another open issue states that the examples directory doesn't have any examples that run faster than the system tools. Since the system tools are C related and have been optimized for years, io_uring may not be the contributing factor.

But in this case it is Go (epoll) and Go (io_uring).

If you see something here that is an obvious mistake on my part or a knowledge gap on my part, that would be great. And I completely understand if you are either no longer interested in this or don't have time to work on it. If so, I'll be glad to go away :)

Cheers and thanks for making your implementation available and open source!

无法支持SQPOLL的原因是什么呢?

但是在 Go 简单的设置 io_uring_params 并不能正常的工作,可能是由于 Go 的 GMP 模型导致的一些问题。暂时还在思考解决方案

这里我有些疑惑,我在5.18.10-1.el7.elrepo.x86_64 + INTEL SSDPE2KX040T8 的环境下,SQPOLL+IOPOLL同时开启时能正常work,并没有遇到所谓的因为CMP模型导致的一些问题。
查看iouring.c的实现,开启SQPOLL后也只是简单的创建和开启后台worker线程而已,这里似乎跟go的并发模型没有什么关系

Failed To Init IOURing: iouring_setup: cannot allocate memory

OS: Linux (Ubuntu 22.04 LTS)
Kernel Version: 6.5.0-26-generic #26~22.04.1-Ubuntu
Go Version: 1.21

code segment:
IOURing, err = iouring.New(10000)

if IOURing == nil {

	return false, err
}

while executing the above statement, many a times I encounter the IOURing object as nil and the err as: iouring_setup: cannot allocate memory. Can you help me find the RCA for this error.

Propose IORING_SETUP_SQE128 and IORING_SETUP_CQE32

Hello,

I'm trying to iouring-go for the NVMe command passthru, but current version cannot support that because of SQE and CQE entry size.
To send the NVMe command through io_uring, SQE and CQE size should be extended with flag IORING_SETUP_SQE128 (128byte SQE entry) and IORING_SETUP_CQE32 (32Byte CQE entry). The other case, NVMe driver reject all command through io_uring.
kernel nvme driver:
https://elixir.bootlin.com/linux/latest/source/drivers/nvme/host/ioctl.c#L734

So, I propose the SQE128/CQE32 features for the passthru command.

Go 1.15 compatible:
https://github.com/sungup/iouring-go/tree/support_SQE128_CQE32

Go > 1.18 implementation using Generic type:
https://github.com/sungup/iouring-go/tree/support_SQE128_CQE32_generic
(This version is modified from Go 1.15 compatible codes to reduce the duplicated logics managing SQE ring buffer.)

For the SQE128/CQE32, I have abstract the SubmissionQueueEnrty and CompletionQueueEntry, so too many lines has been changed related with SQEntry and CQEntry type.

The go race detector reports a few errors

$ bazel test //:iouring-go_test --test_output=streamed  --test_arg=-test.v --@io_bazel_rules_go//go/config:race
WARNING: Streamed test output requested. All tests will be run locally, without sharding, one at a time
INFO: Build option --@io_bazel_rules_go//go/config:race has changed, discarding analysis cache.
INFO: Analyzed target //:iouring-go_test (0 packages loaded, 8423 targets configured).
INFO: Found 1 test target...
=== RUN   TestSubmitRequests
=== RUN   TestSubmitRequests/1
==================
WARNING: DATA RACE
Read at 0x00c0001480c8 by goroutine 10:
  github.com/iceber/iouring-go.(*request).complate()
      request.go:101 +0xc4
  github.com/iceber/iouring-go.(*IOURing).run()
      iouring.go:370 +0x17e
  github.com/iceber/iouring-go.New·dwrap·5()
      iouring.go:87 +0x39

Previous write at 0x00c0001480c8 by goroutine 8:
  github.com/iceber/iouring-go.newRequestSet()
      request.go:245 +0x244
  github.com/iceber/iouring-go.(*IOURing).SubmitRequests()
      iouring.go:251 +0x668
  github.com/iceber/iouring-go.testSubmitRequests()
      iouring_test.go:32 +0x39e
  github.com/iceber/iouring-go.TestSubmitRequests.func1()
      iouring_test.go:47 +0x3a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47

Goroutine 10 (running) created at:
  github.com/iceber/iouring-go.New()
      iouring.go:87 +0x5b8
  github.com/iceber/iouring-go.testSubmitRequests()
      iouring_test.go:15 +0x15b
  github.com/iceber/iouring-go.TestSubmitRequests.func1()
      iouring_test.go:47 +0x3a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47

Goroutine 8 (running) created at:
  testing.(*T).Run()
      GOROOT/src/testing/testing.go:1306 +0x726
  github.com/iceber/iouring-go.TestSubmitRequests()
      iouring_test.go:47 +0xde
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c00002c4f8 by goroutine 10:
  sync/atomic.AddInt32()
      src/runtime/race_amd64.s:305 +0xb
  sync/atomic.AddInt32()
      <autogenerated>:1 +0x1a
  github.com/iceber/iouring-go.(*IOURing).run()
      iouring.go:370 +0x17e
  github.com/iceber/iouring-go.New·dwrap·5()
      iouring.go:87 +0x39

Previous write at 0x00c00002c4f8 by goroutine 8:
  github.com/iceber/iouring-go.newRequestSet()
      request.go:238 +0x7b
  github.com/iceber/iouring-go.(*IOURing).SubmitRequests()
      iouring.go:251 +0x668
  github.com/iceber/iouring-go.testSubmitRequests()
      iouring_test.go:32 +0x39e
  github.com/iceber/iouring-go.TestSubmitRequests.func1()
      iouring_test.go:47 +0x3a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47

Goroutine 10 (running) created at:
  github.com/iceber/iouring-go.New()
      iouring.go:87 +0x5b8
  github.com/iceber/iouring-go.testSubmitRequests()
      iouring_test.go:15 +0x15b
  github.com/iceber/iouring-go.TestSubmitRequests.func1()
      iouring_test.go:47 +0x3a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47

Goroutine 8 (running) created at:
  testing.(*T).Run()
      GOROOT/src/testing/testing.go:1306 +0x726
  github.com/iceber/iouring-go.TestSubmitRequests()
      iouring_test.go:47 +0xde
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Read at 0x00c00002c4e0 by goroutine 10:
  github.com/iceber/iouring-go.(*requestSet).complateOne()
      request.go:251 +0x113
  github.com/iceber/iouring-go.(*request).complate()
      request.go:102 +0xd8
  github.com/iceber/iouring-go.(*IOURing).run()
      iouring.go:370 +0x17e
  github.com/iceber/iouring-go.New·dwrap·5()
      iouring.go:87 +0x39

Previous write at 0x00c00002c4e0 by goroutine 8:
  github.com/iceber/iouring-go.newRequestSet()
      request.go:238 +0x7b
  github.com/iceber/iouring-go.(*IOURing).SubmitRequests()
      iouring.go:251 +0x668
  github.com/iceber/iouring-go.testSubmitRequests()
      iouring_test.go:32 +0x39e
  github.com/iceber/iouring-go.TestSubmitRequests.func1()
      iouring_test.go:47 +0x3a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47

Goroutine 10 (running) created at:
  github.com/iceber/iouring-go.New()
      iouring.go:87 +0x5b8
  github.com/iceber/iouring-go.testSubmitRequests()
      iouring_test.go:15 +0x15b
  github.com/iceber/iouring-go.TestSubmitRequests.func1()
      iouring_test.go:47 +0x3a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47

Goroutine 8 (running) created at:
  testing.(*T).Run()
      GOROOT/src/testing/testing.go:1306 +0x726
  github.com/iceber/iouring-go.TestSubmitRequests()
      iouring_test.go:47 +0xde
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Read at 0x00c00002c500 by goroutine 10:
  github.com/iceber/iouring-go.(*requestSet).complateOne()
      request.go:252 +0x12d
  github.com/iceber/iouring-go.(*request).complate()
      request.go:102 +0xd8
  github.com/iceber/iouring-go.(*IOURing).run()
      iouring.go:370 +0x17e
  github.com/iceber/iouring-go.New·dwrap·5()
      iouring.go:87 +0x39

Previous write at 0x00c00002c500 by goroutine 8:
  github.com/iceber/iouring-go.newRequestSet()
      request.go:238 +0x7b
  github.com/iceber/iouring-go.(*IOURing).SubmitRequests()
      iouring.go:251 +0x668
  github.com/iceber/iouring-go.testSubmitRequests()
      iouring_test.go:32 +0x39e
  github.com/iceber/iouring-go.TestSubmitRequests.func1()
      iouring_test.go:47 +0x3a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47

Goroutine 10 (running) created at:
  github.com/iceber/iouring-go.New()
      iouring.go:87 +0x5b8
  github.com/iceber/iouring-go.testSubmitRequests()
      iouring_test.go:15 +0x15b
  github.com/iceber/iouring-go.TestSubmitRequests.func1()
      iouring_test.go:47 +0x3a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47

Goroutine 8 (running) created at:
  testing.(*T).Run()
      GOROOT/src/testing/testing.go:1306 +0x726
  github.com/iceber/iouring-go.TestSubmitRequests()
      iouring_test.go:47 +0xde
  testing.tRunner()
      GOROOT/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      GOROOT/src/testing/testing.go:1306 +0x47
==================
    testing.go:1152: race detected during execution of test
=== RUN   TestSubmitRequests/2
=== RUN   TestSubmitRequests/4
=== RUN   TestSubmitRequests/8
=== RUN   TestSubmitRequests/16
=== RUN   TestSubmitRequests/32
=== RUN   TestSubmitRequests/64
=== RUN   TestSubmitRequests/128
=== CONT  TestSubmitRequests
    testing.go:1152: race detected during execution of test
--- FAIL: TestSubmitRequests (0.23s)
    --- FAIL: TestSubmitRequests/1 (0.02s)
    --- PASS: TestSubmitRequests/2 (0.03s)
    --- PASS: TestSubmitRequests/4 (0.02s)
    --- PASS: TestSubmitRequests/8 (0.03s)
    --- PASS: TestSubmitRequests/16 (0.02s)
    --- PASS: TestSubmitRequests/32 (0.03s)
    --- PASS: TestSubmitRequests/64 (0.04s)
    --- PASS: TestSubmitRequests/128 (0.04s)
=== CONT  
    testing.go:1152: race detected during execution of test
FAIL

是否支持 ReadAt 操作?

我想以非常高的频率随机读取文件的特定部分,看了文档没有找到相关的函数,只有 Read/Readv 这两个,想问下是否支持 ReadAt 的方式:

func (f *File) ReadAt(b []byte, off int64) (n int, err error)

panic: iouring_setup: function not implemented

When I tested the cat in /example, it was panic on my machine(CentOS Stream9).
But, when I tested the cat in Ubuntu22.04, It can work normally.

env

uname -a
Linux 5.14.0-160.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 25 23:06:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
uname -a
Linux 5.15.0-33-generic #34-Ubuntu SMP Wed May 18 13:34:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Size of cq could be wrong (?)

Hello, I see that in this repo the size of the cq ring is using uint32Size instead of the CompletionQueueEntry's size. For reference, in liburing they use CompletionQueueEntry.

Your code

cq.size = params.CQOffset.Cqes + params.CQEntries*uint32Size

liburing:
https://github.com/axboe/liburing/blob/a71d56ef3259216739677473ddb17ad861c3a964/src/setup.c#L29

size = sizeof(struct io_uring_cqe);
...
cq->ring_sz = p->cq_off.cqes + p->cq_entries * size;

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.