go: bump to 1.26 (#15904)
This commit is contained in:
@@ -206,35 +206,6 @@ To run tests, use `go test`:
|
|||||||
go test ./...
|
go test ./...
|
||||||
```
|
```
|
||||||
|
|
||||||
> NOTE: In rare circumstances, you may need to change a package using the new
|
|
||||||
> "synctest" package in go1.24.
|
|
||||||
>
|
|
||||||
> If you do not have the "synctest" package enabled, you will not see build or
|
|
||||||
> test failures resulting from your change(s), if any, locally, but CI will
|
|
||||||
> break.
|
|
||||||
>
|
|
||||||
> If you see failures in CI, you can either keep pushing changes to see if the
|
|
||||||
> CI build passes, or you can enable the "synctest" package locally to see the
|
|
||||||
> failures before pushing.
|
|
||||||
>
|
|
||||||
> To enable the "synctest" package for testing, run the following command:
|
|
||||||
>
|
|
||||||
> ```shell
|
|
||||||
> GOEXPERIMENT=synctest go test ./...
|
|
||||||
> ```
|
|
||||||
>
|
|
||||||
> If you wish to enable synctest for all go commands, you can set the
|
|
||||||
> `GOEXPERIMENT` environment variable in your shell profile or by using:
|
|
||||||
>
|
|
||||||
> ```shell
|
|
||||||
> go env -w GOEXPERIMENT=synctest
|
|
||||||
> ```
|
|
||||||
>
|
|
||||||
> Which will enable the "synctest" package for all go commands without needing
|
|
||||||
> to set it for all shell sessions.
|
|
||||||
>
|
|
||||||
> The synctest package is not required for production builds.
|
|
||||||
|
|
||||||
## Library detection
|
## Library detection
|
||||||
|
|
||||||
Ollama looks for acceleration libraries in the following paths relative to the `ollama` executable:
|
Ollama looks for acceleration libraries in the following paths relative to the `ollama` executable:
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
|||||||
module github.com/ollama/ollama
|
module github.com/ollama/ollama
|
||||||
|
|
||||||
go 1.24.1
|
go 1.26.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf
|
github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//go:build goexperiment.synctest
|
|
||||||
|
|
||||||
package backoff
|
package backoff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -11,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestLoop(t *testing.T) {
|
func TestLoop(t *testing.T) {
|
||||||
synctest.Run(func() {
|
synctest.Test(t, func(t *testing.T) {
|
||||||
last := -1
|
last := -1
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(t.Context())
|
ctx, cancel := context.WithCancel(t.Context())
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
//go:build goexperiment.synctest
|
|
||||||
|
|
||||||
package backoff
|
package backoff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"testing/synctest"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLoopAllocs(t *testing.T) {
|
func TestLoopAllocs(t *testing.T) {
|
||||||
@@ -26,14 +22,3 @@ func TestLoopAllocs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkLoop(b *testing.B) {
|
|
||||||
ctx := b.Context()
|
|
||||||
synctest.Run(func() {
|
|
||||||
for n := range Loop(ctx, 100*time.Millisecond) {
|
|
||||||
if n == b.N {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//go:build goexperiment.synctest
|
|
||||||
|
|
||||||
package syncs
|
package syncs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -12,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func TestPipelineReadWriterTo(t *testing.T) {
|
func TestPipelineReadWriterTo(t *testing.T) {
|
||||||
for range 10 {
|
for range 10 {
|
||||||
synctest.Run(func() {
|
synctest.Test(t, func(t *testing.T) {
|
||||||
q := NewRelayReader()
|
q := NewRelayReader()
|
||||||
|
|
||||||
tickets := []struct {
|
tickets := []struct {
|
||||||
|
|||||||
@@ -798,81 +798,6 @@ func verifyBlob(t *testing.T, dir string, blob Blob, expected []byte) {
|
|||||||
|
|
||||||
// ==================== Parallelism Tests ====================
|
// ==================== Parallelism Tests ====================
|
||||||
|
|
||||||
func TestDownloadParallelism(t *testing.T) {
|
|
||||||
// Create many blobs to test parallelism
|
|
||||||
serverDir := t.TempDir()
|
|
||||||
numBlobs := 10
|
|
||||||
blobs := make([]Blob, numBlobs)
|
|
||||||
blobData := make([][]byte, numBlobs)
|
|
||||||
|
|
||||||
for i := range numBlobs {
|
|
||||||
blobs[i], blobData[i] = createTestBlob(t, serverDir, 1024+i*100)
|
|
||||||
}
|
|
||||||
|
|
||||||
var activeRequests atomic.Int32
|
|
||||||
var maxConcurrent atomic.Int32
|
|
||||||
|
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
current := activeRequests.Add(1)
|
|
||||||
defer activeRequests.Add(-1)
|
|
||||||
|
|
||||||
// Track max concurrent requests
|
|
||||||
for {
|
|
||||||
old := maxConcurrent.Load()
|
|
||||||
if current <= old || maxConcurrent.CompareAndSwap(old, current) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simulate network latency to ensure parallelism is visible
|
|
||||||
time.Sleep(50 * time.Millisecond)
|
|
||||||
|
|
||||||
digest := filepath.Base(r.URL.Path)
|
|
||||||
path := filepath.Join(serverDir, digestToPath(digest))
|
|
||||||
data, err := os.ReadFile(path)
|
|
||||||
if err != nil {
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
w.Write(data)
|
|
||||||
}))
|
|
||||||
defer server.Close()
|
|
||||||
|
|
||||||
clientDir := t.TempDir()
|
|
||||||
|
|
||||||
start := time.Now()
|
|
||||||
err := Download(context.Background(), DownloadOptions{
|
|
||||||
Blobs: blobs,
|
|
||||||
BaseURL: server.URL,
|
|
||||||
DestDir: clientDir,
|
|
||||||
Concurrency: 4,
|
|
||||||
})
|
|
||||||
elapsed := time.Since(start)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Download failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify all blobs downloaded
|
|
||||||
for i, blob := range blobs {
|
|
||||||
verifyBlob(t, clientDir, blob, blobData[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify parallelism was used
|
|
||||||
if maxConcurrent.Load() < 2 {
|
|
||||||
t.Errorf("Max concurrent requests was %d, expected at least 2 for parallelism", maxConcurrent.Load())
|
|
||||||
}
|
|
||||||
|
|
||||||
// With 10 blobs at 50ms each, sequential would take ~500ms
|
|
||||||
// Parallel with 4 workers should take ~150ms (relax to 1s for CI variance)
|
|
||||||
if elapsed > time.Second {
|
|
||||||
t.Errorf("Downloads took %v, expected faster with parallelism", elapsed)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Downloaded %d blobs in %v with max %d concurrent requests", numBlobs, elapsed, maxConcurrent.Load())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUploadParallelism(t *testing.T) {
|
func TestUploadParallelism(t *testing.T) {
|
||||||
clientDir := t.TempDir()
|
clientDir := t.TempDir()
|
||||||
numBlobs := 10
|
numBlobs := 10
|
||||||
@@ -1244,53 +1169,6 @@ func TestUploadEmptyBlobList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDownloadManyBlobs(t *testing.T) {
|
|
||||||
// Test with many blobs to verify high concurrency works
|
|
||||||
serverDir := t.TempDir()
|
|
||||||
numBlobs := 50
|
|
||||||
blobs := make([]Blob, numBlobs)
|
|
||||||
blobData := make([][]byte, numBlobs)
|
|
||||||
|
|
||||||
for i := range numBlobs {
|
|
||||||
blobs[i], blobData[i] = createTestBlob(t, serverDir, 512) // Small blobs
|
|
||||||
}
|
|
||||||
|
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
digest := filepath.Base(r.URL.Path)
|
|
||||||
path := filepath.Join(serverDir, digestToPath(digest))
|
|
||||||
data, err := os.ReadFile(path)
|
|
||||||
if err != nil {
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
w.Write(data)
|
|
||||||
}))
|
|
||||||
defer server.Close()
|
|
||||||
|
|
||||||
clientDir := t.TempDir()
|
|
||||||
|
|
||||||
start := time.Now()
|
|
||||||
err := Download(context.Background(), DownloadOptions{
|
|
||||||
Blobs: blobs,
|
|
||||||
BaseURL: server.URL,
|
|
||||||
DestDir: clientDir,
|
|
||||||
Concurrency: 16,
|
|
||||||
})
|
|
||||||
elapsed := time.Since(start)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Download failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify all blobs
|
|
||||||
for i, blob := range blobs {
|
|
||||||
verifyBlob(t, clientDir, blob, blobData[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Downloaded %d blobs in %v", numBlobs, elapsed)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUploadRetryOnFailure(t *testing.T) {
|
func TestUploadRetryOnFailure(t *testing.T) {
|
||||||
clientDir := t.TempDir()
|
clientDir := t.TempDir()
|
||||||
blob, _ := createTestBlob(t, clientDir, 1024)
|
blob, _ := createTestBlob(t, clientDir, 1024)
|
||||||
|
|||||||
Reference in New Issue
Block a user