Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

[インデックス 18995] ファイルの概要

このコミットは、Go言語の次期リリースで導入される予定のAPI変更を記録するapi/next.txtファイルを更新するものです。このファイルは、GoのAPI互換性ポリシーに則り、将来のリリースで公開されるAPIの追加や変更を事前に文書化するために使用されます。

コミット

commit cc562e40b49126504f99bf00d8b769142dfe5b38
Author: Shenghou Ma <minux.ma@gmail.com>
Date:   Tue Apr 1 13:14:45 2014 -0400

    api: update next.txt
    
    LGTM=bradfitz
    R=golang-codereviews, gobot, bradfitz
    CC=golang-codereviews
    https://golang.org/cl/81890044

GitHub上でのコミットページへのリンク

https://github.com/golang/go/commit/cc562e40b49126504f99bf00d8b769142dfe5b38

元コミット内容

このコミットの元々の内容は、api/next.txtファイルを更新し、Goの次期リリースで導入される新しいAPI要素を追記することです。具体的には、regexp/syntaxパッケージ、runtime/debugパッケージ、およびsyscallパッケージにいくつかの新しい関数、メソッド、型、変数が追加されています。

変更の背景

Go言語では、後方互換性を非常に重視しており、APIの変更は厳格なプロセスを経て行われます。api/next.txtファイルは、Go 1の互換性保証の一部として機能し、次のメジャーリリースで導入される予定のAPI変更を事前にリストアップするために存在します。これにより、開発者は将来のAPI変更を早期に把握し、自身のコードベースへの影響を評価する機会を得られます。

このコミットは、Goの正規表現エンジン、デバッグ機能、およびシステムコールインターフェースにおける内部的な改善や新機能の追加に伴い、それらの変更が外部に公開されるAPIとして反映されることを示しています。特に、正規表現の「ワンパス」最適化やヒープダンプ機能、そしてクロスプラットフォームでのSendmsgNシステムコールへの対応が背景にあります。

前提知識の解説

  • GoのAPI互換性ポリシー: Go言語は、Go 1以降、メジャーバージョン内での後方互換性を厳格に維持することを約束しています。これは、既存のGoプログラムが新しいバージョンのGoコンパイラでコンパイルしても、動作が変更されないことを意味します。APIの追加は許可されますが、既存のAPIの変更や削除は原則として行われません。api/next.txtはこのポリシーをサポートするためのメカニズムの一つです。
  • api/next.txt: このファイルは、Goの次期メジャーリリースで公開される予定のAPIのリストです。Goのツールチェーンは、このファイルと現在のAPI定義を比較し、互換性のない変更がないかをチェックします。このファイルに記載されたAPIは、次のリリースで正式に公開されることを意味します。
  • 正規表現エンジン (regexpパッケージ): Goの標準ライブラリには、正規表現を扱うためのregexpパッケージが含まれています。このパッケージは、内部的にregexp/syntaxパッケージを使用して正規表現の構文解析とコンパイルを行います。正規表現のマッチング性能は、アプリケーションのパフォーマンスに大きな影響を与えるため、その最適化は継続的に行われます。
  • システムコール (syscallパッケージ): syscallパッケージは、Goプログラムからオペレーティングシステムのシステムコールを直接呼び出すための低レベルなインターフェースを提供します。これにより、Goの標準ライブラリでは提供されていない、OS固有の機能や高度なネットワーク操作などを実行できます。
  • ヒープダンプ (runtime/debugパッケージ): Goのランタイムは、プログラムのメモリ使用状況を管理します。ヒープダンプは、プログラム実行時のヒープメモリの内容をスナップショットとして取得する機能です。これは、メモリリークのデバッグやメモリ使用量のプロファイリングに非常に役立ちます。

技術的詳細

このコミットでapi/next.txtに追加されたAPIは、以下の主要な領域における機能拡張と最適化を示唆しています。

  1. regexp/syntaxパッケージの「ワンパス」最適化:

    • (*Inst) MatchRunePos(int32) int
    • (*Inst) OnePassNext(int32) uint32
    • (*Prog) CompileOnePass() *Prog
    • (*Prog) OnePassPrefix() (string, bool, uint32)
    • (InstOp) String() string
    • Inst struct, Next []uint32
    • var NotOnePass *Prog これらのAPIは、Goの正規表現エンジンにおける「ワンパス」マッチングの最適化に関連しています。従来の正規表現エンジンは、バックトラッキングを伴う複雑なアルゴリズムを使用することが多く、最悪の場合には指数関数的な時間計算量となる可能性がありました。 「ワンパス」マッチングは、正規表現の一部または全体を、入力文字列を一度だけ走査することでマッチングできるような、より効率的なアルゴリズムで処理しようとするものです。これにより、特定の正規表現パターン(特に固定文字列のプレフィックスを持つものや、単純な構造を持つもの)において、マッチング性能が大幅に向上します。
    • CompileOnePass(): 正規表現プログラムをワンパスでコンパイルできるかどうかを試み、可能であれば最適化されたプログラムを返します。
    • OnePassPrefix(): ワンパスでマッチング可能な固定文字列のプレフィックスを抽出します。これにより、正規表現のマッチングを開始する前に、高速な文字列検索で候補を絞り込むことができます。
    • MatchRunePosOnePassNextは、ワンパス実行中の内部的な状態遷移や文字のマッチングを効率的に行うためのメソッドと考えられます。
    • Inst struct, Next []uint32InstOp) String()は、正規表現の内部表現(命令セット)に関する詳細を示しており、最適化された実行パスを構築するために利用されます。
  2. runtime/debugパッケージのヒープダンプ機能:

    • func WriteHeapDump(uintptr) この関数は、Goプログラムの現在のヒープメモリの状態をファイルにダンプする機能を提供します。uintptr引数は、ダンプ先のファイルディスクリプタ(またはそれに類するもの)を指すと考えられます。ヒープダンプは、メモリリークの診断や、プログラムが実行時にどのようにメモリを使用しているかを詳細に分析するために不可欠なツールです。これにより、Goアプリケーションのデバッグ能力が向上します。
  3. syscallパッケージのSendmsgN関数:

    • func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error) この関数は、Unix系システムコールであるsendmsgのGo言語ラッパーです。sendmsgは、ソケットを介してデータを送信するための汎用的なシステムコールであり、通常のデータだけでなく、ファイルディスクリプタなどの補助データ(ancillary data)も送信できる点が特徴です。 SendmsgNは、特に複数のバッファからデータを送信する(scatter/gather I/O)場合や、プロセス間でファイルディスクリプタを渡す(Unixドメインソケット経由)場合などに使用されます。このAPIが追加されたことで、Goプログラムはより低レベルで柔軟なネットワーク通信やプロセス間通信(IPC)を、様々なOS(darwin, freebsd, linux, netbsd, openbsd)およびアーキテクチャ(386, amd64, arm)で利用できるようになります。これは、特に高性能なネットワークアプリケーションや、OS固有の高度な機能を利用するアプリケーションの開発において重要です。

コアとなるコードの変更箇所

このコミット自体は、Goのソースコード(.goファイル)を直接変更するものではなく、GoのAPI定義を記述したapi/next.txtファイルのみを変更しています。

diff --git a/api/next.txt b/api/next.txt
index d846dd53e6..ec8d7b058e 100644
--- a/api/next.txt
+++ b/api/next.txt
@@ -266,7 +266,15 @@ pkg net/http, type Response struct, TLS *tls.ConnectionState
 pkg net/http, type Server struct, ConnState func(net.Conn, ConnState)
 pkg net/http, type Server struct, ErrorLog *log.Logger
 pkg net/http, type Transport struct, TLSHandshakeTimeout time.Duration
+pkg regexp/syntax, method (*Inst) MatchRunePos(int32) int
+pkg regexp/syntax, method (*Inst) OnePassNext(int32) uint32
+pkg regexp/syntax, method (*Prog) CompileOnePass() *Prog
+pkg regexp/syntax, method (*Prog) OnePassPrefix() (string, bool, uint32)
+pkg regexp/syntax, method (InstOp) String() string
+pkg regexp/syntax, type Inst struct, Next []uint32
+pkg regexp/syntax, var NotOnePass *Prog
 pkg runtime/debug, func SetPanicOnFault(bool) bool
+pkg runtime/debug, func WriteHeapDump(uintptr)
 pkg sync, method (*Pool) Get() interface{}
 pkg sync, method (*Pool) Put(interface{})
 pkg sync, type Pool struct
@@ -277,24 +285,28 @@ pkg syscall (darwin-386), func Mlockall(int) error
 pkg syscall (darwin-386), func Mprotect([]uint8, int) error
 pkg syscall (darwin-386), func Munlock([]uint8) error
 pkg syscall (darwin-386), func Munlockall() error
+pkg syscall (darwin-386), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (darwin-386-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
 pkg syscall (darwin-386-cgo), func Mlock([]uint8) error
 pkg syscall (darwin-386-cgo), func Mlockall(int) error
 pkg syscall (darwin-386-cgo), func Mprotect([]uint8, int) error
 pkg syscall (darwin-386-cgo), func Munlock([]uint8) error
 pkg syscall (darwin-386-cgo), func Munlockall() error
+pkg syscall (darwin-386-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (darwin-amd64), func FcntlFlock(uintptr, int, *Flock_t) error
 pkg syscall (darwin-amd64), func Mlock([]uint8) error
 pkg syscall (darwin-amd64), func Mlockall(int) error
 pkg syscall (darwin-amd64), func Mprotect([]uint8, int) error
 pkg syscall (darwin-amd64), func Munlock([]uint8) error
 pkg syscall (darwin-amd64), func Munlockall() error
+pkg syscall (darwin-amd64), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (darwin-amd64-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
 pkg syscall (darwin-amd64-cgo), func Mlock([]uint8) error
 pkg syscall (darwin-amd64-cgo), func Mlockall(int) error
 pkg syscall (darwin-amd64-cgo), func Mprotect([]uint8, int) error
 pkg syscall (darwin-amd64-cgo), func Munlock([]uint8) error
 pkg syscall (darwin-amd64-cgo), func Munlockall() error
+pkg syscall (darwin-amd64-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (freebsd-386), const AF_INET6_SDP = 42
 pkg syscall (freebsd-386), const AF_INET6_SDP ideal-int
 pkg syscall (freebsd-386), const AF_INET_SDP = 40
@@ -359,6 +371,7 @@ pkg syscall (freebsd-386), const WTRAPPED = 32
 pkg syscall (freebsd-386), const WTRAPPED ideal-int
 pkg syscall (freebsd-386), func Accept4(int, int) (int, Sockaddr, error)
 pkg syscall (freebsd-386), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (freebsd-386), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (freebsd-386), type Termios struct
 pkg syscall (freebsd-386), type Termios struct, Cc [20]uint8
 pkg syscall (freebsd-386), type Termios struct, Cflag uint32
@@ -431,6 +444,7 @@ pkg syscall (freebsd-386-cgo), const WTRAPPED = 32
 pkg syscall (freebsd-386-cgo), const WTRAPPED ideal-int
 pkg syscall (freebsd-386-cgo), func Accept4(int, int) (int, Sockaddr, error)
 pkg syscall (freebsd-386-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (freebsd-386-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (freebsd-386-cgo), type Termios struct
 pkg syscall (freebsd-386-cgo), type Termios struct, Cc [20]uint8
 pkg syscall (freebsd-386-cgo), type Termios struct, Cflag uint32
@@ -505,6 +519,7 @@ pkg syscall (freebsd-amd64), const WTRAPPED = 32
 pkg syscall (freebsd-amd64), const WTRAPPED ideal-int
 pkg syscall (freebsd-amd64), func Accept4(int, int) (int, Sockaddr, error)
 pkg syscall (freebsd-amd64), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (freebsd-amd64), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (freebsd-amd64), type Termios struct
 pkg syscall (freebsd-amd64), type Termios struct, Cc [20]uint8
 pkg syscall (freebsd-amd64), type Termios struct, Cflag uint32
@@ -579,6 +594,7 @@ pkg syscall (freebsd-amd64-cgo), const WTRAPPED = 32
 pkg syscall (freebsd-amd64-cgo), const WTRAPPED ideal-int
 pkg syscall (freebsd-amd64-cgo), func Accept4(int, int) (int, Sockaddr, error)
 pkg syscall (freebsd-amd64-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (freebsd-amd64-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (freebsd-amd64-cgo), type Termios struct
 pkg syscall (freebsd-amd64-cgo), type Termios struct, Cc [20]uint8
 pkg syscall (freebsd-amd64-cgo), type Termios struct, Cflag uint32
@@ -650,6 +666,7 @@ pkg syscall (freebsd-arm), const TIOCTIMESTAMP = 1074820185
 pkg syscall (freebsd-arm), func Accept4(int, int) (int, Sockaddr, error)
 pkg syscall (freebsd-arm), func Fchflags(int, int) error
 pkg syscall (freebsd-arm), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (freebsd-arm), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (freebsd-arm), type BpfHdr struct, Pad_cgo_0 [6]uint8
 pkg syscall (freebsd-arm), type Flock_t struct, Pad_cgo_0 [4]uint8
 pkg syscall (freebsd-arm), type IfData struct, Pad_cgo_0 [4]uint8
@@ -726,6 +743,7 @@ pkg syscall (freebsd-arm-cgo), const TIOCTIMESTAMP = 1074820185
 pkg syscall (freebsd-arm-cgo), func Accept4(int, int) (int, Sockaddr, error)
 pkg syscall (freebsd-arm-cgo), func Fchflags(int, int) error
 pkg syscall (freebsd-arm-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (freebsd-arm-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (freebsd-arm-cgo), type BpfHdr struct, Pad_cgo_0 [6]uint8
 pkg syscall (freebsd-arm-cgo), type Flock_t struct, Pad_cgo_0 [4]uint8
 pkg syscall (freebsd-arm-cgo), type IfData struct, Pad_cgo_0 [4]uint8
@@ -740,6 +758,7 @@ pkg syscall (freebsd-arm-cgo), type Termios struct, Ospeed uint32
 pkg syscall (freebsd-arm-cgo), type Timespec struct, Pad_cgo_0 [4]uint8
 pkg syscall (freebsd-arm-cgo), type Timeval struct, Pad_cgo_0 [4]uint8
 pkg syscall (linux-386), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (linux-386), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (linux-386), type Flock_t struct
 pkg syscall (linux-386), type Flock_t struct, Len int64
 pkg syscall (linux-386), type Flock_t struct, Pid int32
@@ -747,6 +766,7 @@ pkg syscall (linux-386), type Flock_t struct, Start int64
 pkg syscall (linux-386), type Flock_t struct, Type int16
 pkg syscall (linux-386), type Flock_t struct, Whence int16
 pkg syscall (linux-386-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (linux-386-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (linux-386-cgo), type Flock_t struct
 pkg syscall (linux-386-cgo), type Flock_t struct, Len int64
 pkg syscall (linux-386-cgo), type Flock_t struct, Pid int32
@@ -754,6 +774,7 @@ pkg syscall (linux-386-cgo), type Flock_t struct, Start int64
 pkg syscall (linux-386-cgo), type Flock_t struct, Type int16
 pkg syscall (linux-386-cgo), type Flock_t struct, Whence int16
 pkg syscall (linux-amd64), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (linux-amd64), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (linux-amd64), type Flock_t struct
 pkg syscall (linux-amd64), type Flock_t struct, Len int64
 pkg syscall (linux-amd64), type Flock_t struct, Pad_cgo_0 [4]uint8
@@ -763,6 +784,7 @@ pkg syscall (linux-amd64), type Flock_t struct, Start int64
 pkg syscall (linux-amd64), type Flock_t struct, Type int16
 pkg syscall (linux-amd64), type Flock_t struct, Whence int16
 pkg syscall (linux-amd64-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (linux-amd64-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (linux-amd64-cgo), type Flock_t struct
 pkg syscall (linux-amd64-cgo), type Flock_t struct, Len int64
 pkg syscall (linux-amd64-cgo), type Flock_t struct, Pad_cgo_0 [4]uint8
@@ -772,6 +794,7 @@ pkg syscall (linux-amd64-cgo), type Flock_t struct, Start int64
 pkg syscall (linux-amd64-cgo), type Flock_t struct, Type int16
 pkg syscall (linux-amd64-cgo), type Flock_t struct, Whence int16
 pkg syscall (linux-arm), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (linux-arm), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (linux-arm), type Flock_t struct
 pkg syscall (linux-arm), type Flock_t struct, Len int64
 pkg syscall (linux-arm), type Flock_t struct, Pad_cgo_0 [4]uint8
@@ -781,6 +804,7 @@ pkg syscall (linux-arm), type Flock_t struct, Start int64
 pkg syscall (linux-arm), type Flock_t struct, Type int16
 pkg syscall (linux-arm), type Flock_t struct, Whence int16
 pkg syscall (linux-arm-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (linux-arm-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (linux-arm-cgo), type Flock_t struct
 pkg syscall (linux-arm-cgo), type Flock_t struct, Len int64
 pkg syscall (linux-arm-cgo), type Flock_t struct, Pad_cgo_0 [4]uint8
@@ -888,6 +912,7 @@ pkg syscall (netbsd-386), const PROT_READ ideal-int
 pkg syscall (netbsd-386), const PROT_WRITE = 2
 pkg syscall (netbsd-386), const PROT_WRITE ideal-int
 pkg syscall (netbsd-386), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (netbsd-386), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (netbsd-386), type Termios struct
 pkg syscall (netbsd-386), type Termios struct, Cc [20]uint8
 pkg syscall (netbsd-386), type Termios struct, Cflag uint32
@@ -995,6 +1020,7 @@ pkg syscall (netbsd-386-cgo), const PROT_READ ideal-int
 pkg syscall (netbsd-386-cgo), const PROT_WRITE = 2
 pkg syscall (netbsd-386-cgo), const PROT_WRITE ideal-int
 pkg syscall (netbsd-386-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (netbsd-386-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (netbsd-386-cgo), type Termios struct
 pkg syscall (netbsd-386-cgo), type Termios struct, Cc [20]uint8
 pkg syscall (netbsd-386-cgo), type Termios struct, Cflag uint32
@@ -1102,6 +1128,7 @@ pkg syscall (netbsd-amd64), const PROT_READ ideal-int
 pkg syscall (netbsd-amd64), const PROT_WRITE = 2
 pkg syscall (netbsd-amd64), const PROT_WRITE ideal-int
 pkg syscall (netbsd-amd64), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (netbsd-amd64), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (netbsd-amd64), type Termios struct
 pkg syscall (netbsd-amd64), type Termios struct, Cc [20]uint8
 pkg syscall (netbsd-amd64), type Termios struct, Cflag uint32
@@ -1209,6 +1236,7 @@ pkg syscall (netbsd-amd64-cgo), const PROT_READ ideal-int
 pkg syscall (netbsd-amd64-cgo), const PROT_WRITE = 2
 pkg syscall (netbsd-amd64-cgo), const PROT_WRITE ideal-int
 pkg syscall (netbsd-amd64-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (netbsd-amd64-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (netbsd-amd64-cgo), type Termios struct
 pkg syscall (netbsd-amd64-cgo), type Termios struct, Cc [20]uint8
 pkg syscall (netbsd-amd64-cgo), type Termios struct, Cflag uint32
@@ -1292,6 +1320,7 @@ pkg syscall (netbsd-arm), const PROT_WRITE ideal-int
 pkg syscall (netbsd-arm), const SizeofIfData = 136
 pkg syscall (netbsd-arm), func Fchflags(int, int) error
 pkg syscall (netbsd-arm), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (netbsd-arm), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (netbsd-arm), type Kevent_t struct, Pad_cgo_0 [4]uint8
 pkg syscall (netbsd-arm), type Stat_t struct, Pad_cgo_0 [4]uint8
 pkg syscall (netbsd-arm), type Stat_t struct, Pad_cgo_1 [4]uint8
@@ -1381,6 +1410,7 @@ pkg syscall (netbsd-arm-cgo), const PROT_WRITE ideal-int
 pkg syscall (netbsd-arm-cgo), const SizeofIfData = 136
 pkg syscall (netbsd-arm-cgo), func Fchflags(int, int) error
 pkg syscall (netbsd-arm-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (netbsd-arm-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (netbsd-arm-cgo), type Kevent_t struct, Pad_cgo_0 [4]uint8
 pkg syscall (netbsd-arm-cgo), type Stat_t struct, Pad_cgo_0 [4]uint8
 pkg syscall (netbsd-arm-cgo), type Stat_t struct, Pad_cgo_1 [4]uint8
@@ -1535,6 +1565,7 @@ pkg syscall (openbsd-386), const TCP_NOPUSH = 16
 pkg syscall (openbsd-386), const TCP_NOPUSH ideal-int
 pkg syscall (openbsd-386), const TIOCGTSTAMP = 1074558043
 pkg syscall (openbsd-386), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (openbsd-386), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (openbsd-386), type Dirent struct, Fileno uint64
 pkg syscall (openbsd-386), type Dirent struct, Off int64
 pkg syscall (openbsd-386), type Dirent struct, X__d_padding [4]uint8
@@ -1697,6 +1728,7 @@ pkg syscall (openbsd-386-cgo), const TCP_NOPUSH = 16
 pkg syscall (openbsd-386-cgo), const TCP_NOPUSH ideal-int
 pkg syscall (openbsd-386-cgo), const TIOCGTSTAMP = 1074558043
 pkg syscall (openbsd-386-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (openbsd-386-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (openbsd-386-cgo), type Dirent struct, Fileno uint64
 pkg syscall (openbsd-386-cgo), type Dirent struct, Off int64
 pkg syscall (openbsd-386-cgo), type Dirent struct, X__d_padding [4]uint8
@@ -1855,6 +1887,7 @@ pkg syscall (openbsd-amd64), const TCP_NOPUSH ideal-int
 pkg syscall (openbsd-amd64), const TIOCGSID = 1074033763
 pkg syscall (openbsd-amd64), const TIOCGSID ideal-int
 pkg syscall (openbsd-amd64), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (openbsd-amd64), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (openbsd-amd64), type Dirent struct, Fileno uint64
 pkg syscall (openbsd-amd64), type Dirent struct, Off int64
 pkg syscall (openbsd-amd64), type Dirent struct, X__d_padding [4]uint8
@@ -2014,6 +2047,7 @@ pkg syscall (openbsd-amd64-cgo), const TCP_NOPUSH ideal-int
 pkg syscall (openbsd-amd64-cgo), const TIOCGSID = 1074033763
 pkg syscall (openbsd-amd64-cgo), const TIOCGSID ideal-int
 pkg syscall (openbsd-amd64-cgo), func FcntlFlock(uintptr, int, *Flock_t) error
+pkg syscall (openbsd-amd64-cgo), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error)
 pkg syscall (openbsd-amd64-cgo), type Dirent struct, Fileno uint64
 pkg syscall (openbsd-amd64-cgo), type Dirent struct, Off int64
 pkg syscall (openbsd-amd64-cgo), type Dirent struct, X__d_padding [4]uint8

コアとなるコードの解説

このコミットは、GoのAPI互換性チェックツールが使用するapi/next.txtファイルに、次期リリースで公開される新しいAPI要素の定義を追加しています。このファイルは、Goのビルドプロセスの一部として、APIの変更がGo 1の互換性保証に違反していないかを検証するために利用されます。

追加された各行は、pkg <パッケージ名>, <要素の種類> <要素名>の形式で、新しいAPI要素を記述しています。

  • pkg regexp/syntax, ...:

    • 正規表現の内部表現と最適化に関連する新しい型、メソッド、変数が追加されています。これらは、正規表現のマッチング性能を向上させるための「ワンパス」最適化の実装をサポートするものです。
    • (*Inst) MatchRunePos(int32) int: 正規表現の命令(Inst)が特定のルーン(Unicodeコードポイント)と位置でマッチするかどうかを判定するメソッド。
    • (*Inst) OnePassNext(int32) uint32: ワンパス実行中に次の命令への遷移を決定するメソッド。
    • (*Prog) CompileOnePass() *Prog: 正規表現プログラムをワンパスで実行可能な形式にコンパイルするメソッド。
    • (*Prog) OnePassPrefix() (string, bool, uint32): ワンパスでマッチング可能な固定文字列のプレフィックスを抽出するメソッド。
    • (InstOp) String() string: 正規表現命令の操作コードを文字列で表現するメソッド。
    • type Inst struct, Next []uint32: 正規表現の命令構造体に、次の命令へのポインタまたはインデックスを格納するフィールドが追加されたことを示唆しています。
    • var NotOnePass *Prog: ワンパスでコンパイルできない正規表現プログラムを示すための変数。
  • pkg runtime/debug, func WriteHeapDump(uintptr):

    • Goランタイムのデバッグ機能として、ヒープメモリの内容をダンプする関数が追加されています。これにより、Goアプリケーションのメモリ使用状況を詳細に分析し、メモリリークなどの問題を特定するのに役立ちます。uintptrは、ダンプ先のファイルディスクリプタを渡すための型です。
  • pkg syscall (darwin-386), func SendmsgN(int, []uint8, []uint8, Sockaddr, int) (int, error) など:

    • syscallパッケージに、SendmsgN関数が追加されています。これは、Unix系OSのsendmsgシステムコールに対応するGoのラッパー関数です。
    • この関数は、複数のバッファからのデータ送信(scatter/gather I/O)や、補助データ(例: ファイルディスクリプタ)の送信を可能にします。
    • darwin, freebsd, linux, netbsd, openbsdの各OSと、386, amd64, armなどの複数のアーキテクチャ、およびCGOを使用する/しないバージョンに対して、この関数が追加されていることが示されています。これは、Goがこれらのプラットフォームでsendmsgシステムコールをサポートし、より低レベルなネットワーク通信やプロセス間通信の機能を提供することを示しています。

これらのAPIの追加は、Go言語が正規表現の性能向上、デバッグ機能の強化、および低レベルなシステムコールインターフェースの拡充を通じて、より幅広いアプリケーション要件に対応しようとしていることを示しています。

関連リンク

参考にした情報源リンク

  • Go言語の公式ドキュメント
  • Goのソースコードリポジトリ(特にapi/next.txtの履歴と、関連するパッケージのコード)
  • sendmsgシステムコールに関するUnix/Linuxのマニュアルページ
  • 正規表現の「ワンパス」最適化に関する一般的な情報
  • Goのコードレビューシステム (Gerrit) の該当コミットページ: https://golang.org/cl/81890044