mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
auto capacity
This commit is contained in:
@@ -42,7 +42,7 @@ PLATFORMS="$PLATFORMS linux/amd64 linux/386"
|
|||||||
# PLATFORMS="$PLATFORMS linux/ppc64 linux/ppc64le"
|
# PLATFORMS="$PLATFORMS linux/ppc64 linux/ppc64le"
|
||||||
PLATFORMS="$PLATFORMS linux/mips linux/mipsle linux/mips64 linux/mips64le" # experimental in go1.6
|
PLATFORMS="$PLATFORMS linux/mips linux/mipsle linux/mips64 linux/mips64le" # experimental in go1.6
|
||||||
#PLATFORMS="$PLATFORMS linux/arm linux/arm64"
|
#PLATFORMS="$PLATFORMS linux/arm linux/arm64"
|
||||||
# PLATFORMS="$PLATFORMS freebsd/amd64"
|
PLATFORMS="$PLATFORMS freebsd/amd64"
|
||||||
# PLATFORMS="$PLATFORMS netbsd/amd64" # amd64 only as of go1.6
|
# PLATFORMS="$PLATFORMS netbsd/amd64" # amd64 only as of go1.6
|
||||||
# PLATFORMS="$PLATFORMS openbsd/amd64" # amd64 only as of go1.6
|
# PLATFORMS="$PLATFORMS openbsd/amd64" # amd64 only as of go1.6
|
||||||
# PLATFORMS="$PLATFORMS dragonfly/amd64" # amd64 only as of go1.5
|
# PLATFORMS="$PLATFORMS dragonfly/amd64" # amd64 only as of go1.5
|
||||||
@@ -85,7 +85,11 @@ for PLATFORM in $PLATFORMS; do
|
|||||||
GOARCH=${PLATFORM#*/}
|
GOARCH=${PLATFORM#*/}
|
||||||
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}"
|
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}"
|
||||||
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
|
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
|
||||||
|
if [[ "${GOOS}" == "linux" ]]; then
|
||||||
|
CMD="CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} main"
|
||||||
|
else
|
||||||
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} main"
|
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} main"
|
||||||
|
fi
|
||||||
echo "${CMD}"
|
echo "${CMD}"
|
||||||
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
|
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ func mkReleasesJS() {
|
|||||||
func test() {
|
func test() {
|
||||||
config := torrent.NewDefaultClientConfig()
|
config := torrent.NewDefaultClientConfig()
|
||||||
|
|
||||||
config.EstablishedConnsPerTorrent = 100
|
config.EstablishedConnsPerTorrent = 20
|
||||||
config.HalfOpenConnsPerTorrent = 65
|
config.HalfOpenConnsPerTorrent = 65
|
||||||
config.DisableIPv6 = true
|
config.DisableIPv6 = true
|
||||||
config.NoDHT = true
|
config.NoDHT = true
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"server/settings"
|
||||||
"server/torr/reader"
|
"server/torr/reader"
|
||||||
"server/torr/storage/state"
|
"server/torr/storage/state"
|
||||||
"server/utils"
|
"server/utils"
|
||||||
@@ -53,6 +54,10 @@ func NewCache(capacity int64, storage *Storage) *Cache {
|
|||||||
|
|
||||||
func (c *Cache) Init(info *metainfo.Info, hash metainfo.Hash) {
|
func (c *Cache) Init(info *metainfo.Info, hash metainfo.Hash) {
|
||||||
fmt.Println("Create cache for:", info.Name)
|
fmt.Println("Create cache for:", info.Name)
|
||||||
|
if c.capacity == 0 {
|
||||||
|
c.capacity = info.PieceLength * 6
|
||||||
|
}
|
||||||
|
|
||||||
//Min capacity of 2 pieces length
|
//Min capacity of 2 pieces length
|
||||||
cap := info.PieceLength * 2
|
cap := info.PieceLength * 2
|
||||||
if c.capacity < cap {
|
if c.capacity < cap {
|
||||||
@@ -92,7 +97,7 @@ func (c *Cache) Close() error {
|
|||||||
c.pieces = nil
|
c.pieces = nil
|
||||||
c.bufferPull = nil
|
c.bufferPull = nil
|
||||||
c.readers = nil
|
c.readers = nil
|
||||||
utils.FreeOSMemGC(0)
|
utils.FreeOSMemGC()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +139,7 @@ func (c *Cache) cleanPieces() {
|
|||||||
c.muRemove.Unlock()
|
c.muRemove.Unlock()
|
||||||
|
|
||||||
remPieces := c.getRemPieces()
|
remPieces := c.getRemPieces()
|
||||||
if len(remPieces) > 0 && (c.capacity < c.filled || c.bufferPull.Len() <= 1) {
|
if len(remPieces) > 0 && (c.filled > c.capacity || c.bufferPull.Len() <= 1) {
|
||||||
remCount := int((c.filled - c.capacity) / c.pieceLength)
|
remCount := int((c.filled - c.capacity) / c.pieceLength)
|
||||||
if remCount < 1 {
|
if remCount < 1 {
|
||||||
remCount = 1
|
remCount = 1
|
||||||
@@ -182,8 +187,8 @@ func (c *Cache) removePiece(piece *Piece) {
|
|||||||
defer c.muPiece.Unlock()
|
defer c.muPiece.Unlock()
|
||||||
piece.Release()
|
piece.Release()
|
||||||
|
|
||||||
if c.prcLoaded >= 95 {
|
if c.prcLoaded >= 75 {
|
||||||
utils.FreeOSMemGC(c.capacity)
|
utils.FreeOSMemGC()
|
||||||
} else {
|
} else {
|
||||||
utils.FreeOSMem()
|
utils.FreeOSMem()
|
||||||
}
|
}
|
||||||
@@ -213,8 +218,12 @@ func (c *Cache) ReadersLen() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache) AdjustRA(readahead int64) {
|
func (c *Cache) AdjustRA(readahead int64) {
|
||||||
|
c.muReader.Lock()
|
||||||
|
defer c.muReader.Unlock()
|
||||||
|
if settings.Get().CacheSize == 0 {
|
||||||
|
c.capacity = readahead * 3
|
||||||
|
}
|
||||||
for r, _ := range c.readers {
|
for r, _ := range c.readers {
|
||||||
r.SetReadahead(readahead)
|
r.SetReadahead(readahead)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
const Version = "1.1.76"
|
const Version = "1.1.76_9"
|
||||||
const VerInt = 76
|
const VerInt = 76
|
||||||
|
|||||||
Reference in New Issue
Block a user