Skip to content

Commit

Permalink
trigger build
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhoonbang committed Nov 5, 2024
1 parent 44c644b commit c2b3a41
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-publish-develop-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

- uses: actions/cache/restore@v4
with:
path: dist/linux_arm64
path: dist/linux_arm64_v8.0
key: chainlink-arm64-${{ github.sha }}
fail-on-cache-miss: true

Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:

- runner: ubuntu-24.04-4cores-16GB-ARM
goarch: arm64
dist_name: linux_arm64
dist_name: linux_arm64_v8.0
steps:
- name: Checkout repository
uses: actions/[email protected]
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ the given `_test` database.
Note: Other environment variables should not be set for all tests to pass

There helper script for initial setup to create an appropriate test user. It requires postgres to be running on localhost at port 5432. You will be prompted for
the `postgres` user password
the `postgres` user password

```bash
make setup-testdb
Expand All @@ -195,19 +195,20 @@ This script will save the `CL_DATABASE_URL` in `.dbenv`

Changes to database require migrations to be run. Similarly, `pull`'ing the repo may require migrations to run.
After the one-time setup above:

```
source .dbenv
make testdb
```

If you encounter the error `database accessed by other users (SQLSTATE 55006) exit status 1`
and you want force the database creation then use

```
source .dbenv
make testdb-force
```


7. Run tests:

```bash
Expand Down Expand Up @@ -260,9 +261,11 @@ flowchart RL
github.com/smartcontractkit/chainlink/core/scripts --> github.com/smartcontractkit/chainlink/v2
```

The `integration-tests` and `core/scripts` modules import the root module using a relative replace in their `go.mod` files,
so dependency changes in the root `go.mod` often require changes in those modules as well. After making a change, `go mod tidy`
can be run on all three modules using:

```
make gomodtidy
```
Expand All @@ -282,6 +285,7 @@ pnpm i
```bash
pnpm test
```

NOTE: Chainlink is currently in the process of migrating to Foundry and contains both Foundry and Hardhat tests in some versions. More information can be found here: [Chainlink Foundry Documentation](https://github.com/smartcontractkit/chainlink/blob/develop/contracts/foundry.md).
Any 't.sol' files associated with Foundry tests, contained within the src directories will be ignored by Hardhat.

Expand All @@ -291,7 +295,7 @@ Go generate is used to generate mocks in this project. Mocks are generated with

### Nix

A [shell.nix](https://nixos.wiki/wiki/Development_environment_with_nix-shell) is provided for use with the [Nix package manager](https://nixos.org/). By default,we utilize the shell through [Nix Flakes](https://nixos.wiki/wiki/Flakes).
A [shell.nix](https://nixos.wiki/wiki/Development_environment_with_nix-shell) is provided for use with the [Nix package manager](https://nixos.org/). By default,we utilize the shell through [Nix Flakes](https://nixos.wiki/wiki/Flakes).

Nix defines a declarative, reproducible development environment. Flakes version use deterministic, frozen (`flake.lock`) dependencies to
gain more consistency/reproducibility on the built artifacts.
Expand Down Expand Up @@ -329,8 +333,9 @@ We use [changesets](https://github.com/changesets/changesets) to manage versioni
Every PR that modifies any configuration or code, should most likely accompanied by a changeset file.

To install `changesets`:
1. Install `pnpm` if it is not already installed - [docs](https://pnpm.io/installation).
2. Run `pnpm install`.

1. Install `pnpm` if it is not already installed - [docs](https://pnpm.io/installation).
2. Run `pnpm install`.

Either after or before you create a commit, run the `pnpm changeset` command to create an accompanying changeset entry which will reflect on the CHANGELOG for the next release.

Expand All @@ -349,3 +354,5 @@ Contributions are welcome to Chainlink's source code.
Please check out our [contributing guidelines](./docs/CONTRIBUTING.md) for more details.

Thank you!

> test
19 changes: 17 additions & 2 deletions core/capabilities/compute/cache.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package compute

import (
"log"
"sync"
"time"

Expand Down Expand Up @@ -43,6 +44,9 @@ type moduleCache struct {
}

func newModuleCache(clock clockwork.Clock, tick, timeout time.Duration, evictAfterSize int) *moduleCache {
log.Println("evictAfterSize", evictAfterSize)
log.Println("timeout in seconds", timeout.Seconds())
log.Println("mc.tickInterval", tick)
return &moduleCache{
m: map[string]*module{},
tickInterval: tick,
Expand All @@ -67,15 +71,19 @@ func (mc *moduleCache) close() {
}

func (mc *moduleCache) reapLoop() {
log.Println("reapLoop started")
ticker := mc.clock.NewTicker(mc.tickInterval)
for {
select {
case <-ticker.Chan():
log.Println("before evictOlderThan")
mc.evictOlderThan(mc.timeout)
log.Println("after evictOlderThan")
if mc.onReaper != nil {
mc.onReaper <- struct{}{}
}
case <-mc.stopChan:
log.Println("stopChan")
return
}
}
Expand All @@ -85,8 +93,10 @@ func (mc *moduleCache) add(id string, mod *module) {
mc.mu.Lock()
defer mc.mu.Unlock()
mod.lastFetchedAt = time.Now()
mc.m[id] = mod
moduleCacheAddition.Inc()
if _, exists := mc.m[id]; !exists {
mc.m[id] = mod
moduleCacheAddition.Inc()
}
}

func (mc *moduleCache) get(id string) (*module, bool) {
Expand All @@ -109,12 +119,17 @@ func (mc *moduleCache) evictOlderThan(duration time.Duration) {

evicted := 0

log.Println("len(mc.m)", len(mc.m))
if len(mc.m) > mc.evictAfterSize {
for id, m := range mc.m {
log.Println("mc.clock", mc.clock.Now())
log.Println("m.lastFetchedAt", m.lastFetchedAt)
log.Println("duration", duration)
if mc.clock.Now().Sub(m.lastFetchedAt) > duration {
delete(mc.m, id)
m.module.Close()
evicted++
log.Println("evicted. id:", id)
}

if len(mc.m) <= mc.evictAfterSize {
Expand Down
3 changes: 3 additions & 0 deletions core/capabilities/compute/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -219,6 +220,8 @@ func (c *Compute) initModule(id string, cfg *host.ModuleConfig, binary []byte, w
func (c *Compute) executeWithModule(ctx context.Context, module *host.Module, config []byte, req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) {
executeStart := time.Now()
capReq := capabilitiespb.CapabilityRequestToProto(req)
log.Println("executeWithModule req", req)
log.Println("executeWithModule capReq", capReq)

wasmReq := &wasmpb.Request{
Id: uuid.New().String(),
Expand Down
43 changes: 43 additions & 0 deletions core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package core
import (
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"os"
"runtime"
"runtime/debug"
"time"

"github.com/Masterminds/semver/v3"

Expand All @@ -25,7 +30,45 @@ func init() {
}
}

// Helper function to convert bytes to megabytes
func bToMb(b uint64) uint64 {
return b / 1024 / 1024
}

func printGCStats() {
for {
// Create MemStats and GCStats structs to hold stats data
var memStats runtime.MemStats
var gcStats debug.GCStats

// Read memory statistics
runtime.ReadMemStats(&memStats)
debug.ReadGCStats(&gcStats)

// Print memory allocation and GC details
log.Printf("Alloc = %v MiB", bToMb(memStats.Alloc))
log.Printf("TotalAlloc = %v MiB", bToMb(memStats.TotalAlloc))
log.Printf("Sys = %v MiB", bToMb(memStats.Sys))
log.Printf("NumGC = %v", memStats.NumGC)
log.Printf("PauseTotalNs = %v", memStats.PauseTotalNs)
log.Printf("LastGC = %v", time.Unix(0, int64(memStats.LastGC)))

log.Printf("GC Last Run: %v", gcStats.LastGC)
log.Printf("GC NumGC: %v", gcStats.NumGC)
log.Printf("GC PauseTotal: %v", gcStats.PauseTotal)
log.Printf("GC Pause history (last few GCs): %v", gcStats.Pause)

// Sleep for the specified interval
time.Sleep(5 * time.Minute) // Adjust interval as needed
}
}

func Main() (code int) {
go printGCStats() // Run printGCStats in a separate goroutine
go func() {
log.Println("Starting pprof server on :6060")
log.Println(http.ListenAndServe(":6060", nil))
}()
recovery.ReportPanics(func() {
app := cmd.NewApp(newProductionClient())
if err := app.Run(os.Args); err != nil {
Expand Down

0 comments on commit c2b3a41

Please sign in to comment.