8000 Speed limit issue · Issue #41 · cenkalti/rain · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Speed limit issue #41
Closed
Closed
@dd4e

Description

@dd4e

Hello.

I found an issue with the global download speed limit working.
I have same results for tests with and without a download speed limit.

Input data

  • golang 1.17
  • github.com/cenkalti/rain v1.8.1
  • used the same torrent file for both tests
  • ./torrent.db and data folder clean

Test code

func main() {
	var limit int64

	flag.Int64Var(&limit, "limit", 0, "download limit")
	flag.Parse()

	fmt.Printf("Global speed limi
611D
t is %d KBps\n", limit)

	cfg := torrent.DefaultConfig
	cfg.DataDir = "./data"
	cfg.Database = "./torrent.db"
	cfg.SpeedLimitDownload = limit

	c, _ := torrent.NewSession(cfg)
	defer c.Close()

	f, _ := os.Open("test.torrent")
	defer f.Close()

	t, _ := c.AddTorrent(f, nil)

	for {
		select {
		case <-t.NotifyComplete():
			fmt.Println("Done!")
			return
		case <-time.Tick(10 * time.Second):
			speedKbps := t.Stats().Speed.Download / 1024
			fmt.Printf("Speed is %d KBps\n", speedKbps)
		}
	}
}

Test without download limit

# time ./test_torrent
Global speed limit is 0 KBps
2021-11-02 12:54:52 INFO     [session] session_load.go:34 loaded 0 existing torrents
2021-11-02 12:54:52 INFO     [rpc server] session_rpc_server.go:48 RPC server is listening on 127.0.0.1:7246
2021-11-02 12:54:52 INFO     [torrent 7JTQVDvCEey413Tl-RSrzA] session_add.go:284 added torrent
2021-11-02 12:54:52 INFO     [torrent 7JTQVDvCEey413Tl-RSrzA] torrent_start.go:31 starting torrent
2021-11-02 12:54:52 INFO     [torrent 7JTQVDvCEey413Tl-RSrzA] torrent_start.go:118 Listening peers on tcp://0.0.0.0:50898
Speed is 6315 KBps
Speed is 6492 KBps
Speed is 6613 KBps
Speed is 6629 KBps
Speed is 6756 KBps
Done!
2021-11-02 12:55:43 INFO     [torrent 7JTQVDvCEey413Tl-RSrzA] torrent_write.go:82 download completed
2021-11-02 12:55:43 INFO     [torrent 7JTQVDvCEey413Tl-RSrzA] torrent_stop.go:46 stopping torrent

real    0m51,059s
user    0m8,361s
sys     0m11,401s

Test with download limit

# time ./test_torrent --limit=1024
Global speed limit is 1024 KBps
2021-11-02 12:56:24 INFO     [session] session_load.go:34 loaded 0 existing torrents
2021-11-02 12:56:24 INFO     [rpc server] session_rpc_server.go:48 RPC server is listening on 127.0.0.1:7246
2021-11-02 12:56:24 INFO     [torrent I2naazvDEeyA0nTl-RSrzA] session_add.go:284 added torrent
2021-11-02 12:56:24 INFO     [torrent I2naazvDEeyA0nTl-RSrzA] torrent_start.go:31 starting torrent
2021-11-02 12:56:24 INFO     [torrent I2naazvDEeyA0nTl-RSrzA] torrent_start.go:118 Listening peers on tcp://0.0.0.0:55204
Speed is 6883 KBps
Speed is 7022 KBps
Speed is 6936 KBps
Speed is 6922 KBps
Speed is 6930 KBps
Done!
2021-11-02 12:57:15 INFO     [torrent I2naazvDEeyA0nTl-RSrzA] torrent_write.go:82 download completed
2021-11-02 12:57:15 INFO     [torrent I2naazvDEeyA0nTl-RSrzA] torrent_stop.go:46 stopping torrent

real    0m51,494s
user    0m8,410s
sys     0m11,407s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0