chore: cleanup

This commit is contained in:
Igor Sirotin 2026-06-10 11:33:19 +03:00
parent 9f9d9f4648
commit 7d8c57b44c
No known key found for this signature in database
GPG Key ID: 0EABBCB40CB9AD4A
5 changed files with 63 additions and 94 deletions

View File

@ -1,6 +0,0 @@
# Examples
Runnable examples for the Go bindings.
A `messaging/` example (create a node, subscribe, send, print received events)
will be added alongside the Messaging API implementation.

View File

@ -1,9 +1,3 @@
// Package kernel is the low-level Go wrapper over the logos-delivery Kernel API
// (libwaku): relay, store, lightpush, filter, peer management, discovery.
//
// It mirrors go-waku's shape and predates the Messaging API. It is considered
// legacy: once logos-delivery#3851 consolidates libwaku and liblogosdelivery
// into a single tiered library, the kernel surface will be re-pointed at that
// library and exposed as accessors on the messaging Node rather than as a
// standalone package. New consumers should prefer the messaging package.
package kernel

View File

@ -2,9 +2,4 @@
// logos-delivery Messaging API (an opinionated layer over the kernel protocols
// that owns reliability, re-subscriptions, store-based catch-up and the
// Messaging event surface).
//
// It will expose a Node type (create/start/stop, send/subscribe/unsubscribe)
// and a unified Events channel, backed by cgo calls into liblogosdelivery via
// the internal/ffi package. Scaffolding only for now; the implementation lands
// in a follow-up.
package messaging

View File

@ -1,10 +1,15 @@
package main
import (
"encoding/csv"
"flag"
"fmt"
"io"
"os"
"runtime"
"strconv"
"strings"
"time"
"github.com/logos-messaging/logos-delivery-go-bindings/utils"
)
@ -36,3 +41,61 @@ func main() {
os.Exit(1)
}
}
func RecordMemoryMetricsCSV(testName string, iter int, phase string, heapKB, rssKB uint64) error {
mu.Lock()
defer mu.Unlock()
f, err := os.OpenFile("memory_metrics.csv", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer f.Close()
w := csv.NewWriter(f)
defer w.Flush()
stat, err := f.Stat()
if err != nil {
return err
}
if stat.Size() == 0 {
header := []string{"TestName", "Iteration", "Phase", "HeapAlloc(KB)", "RSS(KB)", "Timestamp"}
if err := w.Write(header); err != nil {
return err
}
}
row := []string{
testName,
strconv.Itoa(iter),
phase,
strconv.FormatUint(heapKB, 10),
strconv.FormatUint(rssKB, 10),
time.Now().Format(time.RFC3339),
}
return w.Write(row)
}
func GetRSSKB() (uint64, error) {
f, err := os.Open("/proc/self/statm")
if err != nil {
return 0, err
}
defer f.Close()
data, err := io.ReadAll(f)
if err != nil {
return 0, err
}
fields := strings.Fields(string(data))
if len(fields) < 2 {
return 0, fmt.Errorf("unexpected /proc/self/statm format")
}
rssPages, err := strconv.ParseUint(fields[1], 10, 64)
if err != nil {
return 0, err
}
pageSize := os.Getpagesize()
return (rssPages * uint64(pageSize)) / 1024, nil
}

View File

@ -1,77 +0,0 @@
package utils
import (
"encoding/csv"
"fmt"
"io"
"os"
"strconv"
"strings"
"sync"
"time"
)
var (
testName string
iteration int
phase string
mu sync.Mutex
)
func RecordMemoryMetricsCSV(testName string, iter int, phase string, heapKB, rssKB uint64) error {
mu.Lock()
defer mu.Unlock()
f, err := os.OpenFile("memory_metrics.csv", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer f.Close()
w := csv.NewWriter(f)
defer w.Flush()
stat, err := f.Stat()
if err != nil {
return err
}
if stat.Size() == 0 {
header := []string{"TestName", "Iteration", "Phase", "HeapAlloc(KB)", "RSS(KB)", "Timestamp"}
if err := w.Write(header); err != nil {
return err
}
}
row := []string{
testName,
strconv.Itoa(iter),
phase,
strconv.FormatUint(heapKB, 10),
strconv.FormatUint(rssKB, 10),
time.Now().Format(time.RFC3339),
}
return w.Write(row)
}
func GetRSSKB() (uint64, error) {
f, err := os.Open("/proc/self/statm")
if err != nil {
return 0, err
}
defer f.Close()
data, err := io.ReadAll(f)
if err != nil {
return 0, err
}
fields := strings.Fields(string(data))
if len(fields) < 2 {
return 0, fmt.Errorf("unexpected /proc/self/statm format")
}
rssPages, err := strconv.ParseUint(fields[1], 10, 64)
if err != nil {
return 0, err
}
pageSize := os.Getpagesize()
return (rssPages * uint64(pageSize)) / 1024, nil
}