-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
content: draft zero-alloc-call-sched
- Loading branch information
Showing
10 changed files
with
72 additions
and
17 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package thread_test | ||
|
||
import ( | ||
"testing" | ||
"x/thread" | ||
) | ||
|
||
func BenchmarkThreadCall(b *testing.B) { | ||
th := thread.New() | ||
f := func() {} | ||
b.ReportAllocs() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
th.Call(f) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
// | ||
// The code below is produced by Changkun Ou <[email protected]>. | ||
|
||
// +build linux | ||
|
||
package thread_test | ||
|
||
import ( | ||
|
@@ -63,13 +65,3 @@ func TestThread(t *testing.T) { | |
t.Fatalf("failed to schedule function on the same thread.") | ||
} | ||
} | ||
|
||
func BenchmarkThreadCall(b *testing.B) { | ||
th := thread.New() | ||
f := func() {} | ||
b.ReportAllocs() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
th.Call(f) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
date: 2021-01-21T10:57:59+01:00 | ||
toc: true | ||
slug: /zero-alloc-call-sched | ||
tags: | ||
- Channel | ||
- EscapeAnalysis | ||
- GUI | ||
- MainThread | ||
- Thread | ||
title: Scheduling Calls with Zero Allocation | ||
draft: true | ||
--- | ||
|
||
Author(s): [Changkun Ou](https://changkun.de) | ||
|
||
GUI programming in Go is a little bit tricky. The infamous issue regarding interacting with the legacy GUI frameworks is that most of the graphics related APIs must be called from the main thread. This basically violates the concurrent nature of Go: A goroutine may be arbitrarily and randomly scheduled or rescheduled on different running threads, i.e., the same pice of code will be called from different threads over time, even without evolving the `go` keyword. | ||
|
||
<!--more--> | ||
|
||
|
||
## Background | ||
|
||
TODO: | ||
|
||
## The Main Thread | ||
|
||
TODO: | ||
|
||
## Cost Analysis and Optimization | ||
|
||
TODO: | ||
|
||
## Optimal Threading Control | ||
|
||
TODO: | ||
|
||
## Verification and Discussion | ||
|
||
TODO: | ||
|
||
## Conclusion | ||
|
||
TODO: | ||
|
||
## References | ||
|
||
TODO: |