Skip to content

Commit c8e5bd6

Browse files
committed
Merge branch 'add-median-filter-blur' of https://github.com//youssefelzedy/Graphite into add-median-filter-blur
git pull
2 parents 2e1e713 + d79af07 commit c8e5bd6

File tree

441 files changed

+14534
-9022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

441 files changed

+14534
-9022
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ rustflags = [
1010
"link-arg=--max-memory=4294967296",
1111
"--cfg=web_sys_unstable_apis",
1212
]
13+
14+
[env]
15+
CARGO_WORKSPACE_DIR = { value = "", relative = true }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build Nix Package
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: DeterminateSystems/nix-installer-action@main
14+
- uses: DeterminateSystems/magic-nix-cache-action@main
15+
16+
- name: Build Nix Package Dev
17+
run: nix build .nix#graphite-dev --print-build-logs

.github/workflows/comment-profiling-changes.yaml

Lines changed: 103 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: Profiling Changes
22

33
on:
4-
pull_request: {}
4+
pull_request:
5+
paths:
6+
- 'node-graph/**'
7+
- 'Cargo.toml'
8+
- 'Cargo.lock'
59

610
env:
711
CARGO_TERM_COLOR: always
@@ -50,14 +54,23 @@ jobs:
5054
id: master-sha
5155
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
5256

57+
- name: Get CPU info
58+
id: cpu-info
59+
run: |
60+
# Get CPU model and create a short hash for cache key
61+
CPU_MODEL=$(cat /proc/cpuinfo | grep "model name" | head -1 | cut -d: -f2 | xargs)
62+
CPU_HASH=$(echo "$CPU_MODEL" | sha256sum | cut -c1-8)
63+
echo "cpu-hash=$CPU_HASH" >> $GITHUB_OUTPUT
64+
echo "CPU: $CPU_MODEL (hash: $CPU_HASH)"
65+
5366
- name: Cache benchmark baselines
5467
id: cache-benchmark-baselines
5568
uses: actions/cache@v4
5669
with:
5770
path: target/iai
58-
key: ${{ runner.os }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }}
71+
key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }}
5972
restore-keys: |
60-
${{ runner.os }}-benchmark-baselines-master-
73+
${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master-
6174
6275
- name: Run baseline benchmarks
6376
if: steps.cache-benchmark-baselines.outputs.cache-hit != 'true'
@@ -85,6 +98,8 @@ jobs:
8598
cargo bench --bench run_cached_iai -- --baseline=master --output-format=json | jq -sc | sed 's/\\"//g' > /tmp/run_cached_output.json
8699
87100
- name: Make old comments collapsed by default
101+
# Only run if we have write permissions (not a fork)
102+
if: github.event.pull_request.head.repo.full_name == github.repository
88103
uses: actions/github-script@v7
89104
with:
90105
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -109,7 +124,67 @@ jobs:
109124
});
110125
}
111126
127+
- name: Analyze profiling changes
128+
id: analyze
129+
uses: actions/github-script@v7
130+
with:
131+
script: |
132+
const fs = require('fs');
133+
134+
function isSignificantChange(diffPct, absoluteChange, benchmarkType) {
135+
const meetsPercentageThreshold = Math.abs(diffPct) > 5;
136+
const meetsAbsoluteThreshold = absoluteChange > 200000;
137+
const isCachedExecution = benchmarkType === 'run_cached' ||
138+
benchmarkType.includes('Cached Execution');
139+
140+
return isCachedExecution
141+
? (meetsPercentageThreshold && meetsAbsoluteThreshold)
142+
: meetsPercentageThreshold;
143+
}
144+
145+
const allOutputs = [
146+
JSON.parse(fs.readFileSync('/tmp/compile_output.json', 'utf8')),
147+
JSON.parse(fs.readFileSync('/tmp/update_output.json', 'utf8')),
148+
JSON.parse(fs.readFileSync('/tmp/run_once_output.json', 'utf8')),
149+
JSON.parse(fs.readFileSync('/tmp/run_cached_output.json', 'utf8'))
150+
];
151+
const outputNames = ['compile', 'update', 'run_once', 'run_cached'];
152+
const sectionTitles = ['Compilation', 'Update', 'Run Once', 'Cached Execution'];
153+
154+
let hasSignificantChanges = false;
155+
let regressionDetails = [];
156+
157+
for (let i = 0; i < allOutputs.length; i++) {
158+
const benchmarkOutput = allOutputs[i];
159+
const outputName = outputNames[i];
160+
const sectionTitle = sectionTitles[i];
161+
162+
for (const benchmark of benchmarkOutput) {
163+
if (benchmark.profiles?.[0]?.summaries?.parts?.[0]?.metrics_summary?.Callgrind?.Ir?.diffs?.diff_pct) {
164+
const diffPct = parseFloat(benchmark.profiles[0].summaries.parts[0].metrics_summary.Callgrind.Ir.diffs.diff_pct);
165+
const oldValue = benchmark.profiles[0].summaries.parts[0].metrics_summary.Callgrind.Ir.metrics.Both[1].Int;
166+
const newValue = benchmark.profiles[0].summaries.parts[0].metrics_summary.Callgrind.Ir.metrics.Both[0].Int;
167+
const absoluteChange = Math.abs(newValue - oldValue);
168+
169+
if (isSignificantChange(diffPct, absoluteChange, outputName)) {
170+
hasSignificantChanges = true;
171+
regressionDetails.push({
172+
module_path: benchmark.module_path,
173+
id: benchmark.id,
174+
diffPct,
175+
absoluteChange,
176+
sectionTitle
177+
});
178+
}
179+
}
180+
}
181+
}
182+
183+
core.setOutput('has-significant-changes', hasSignificantChanges);
184+
core.setOutput('regression-details', JSON.stringify(regressionDetails));
185+
112186
- name: Comment PR
187+
if: github.event.pull_request.head.repo.full_name == github.repository
113188
uses: actions/github-script@v7
114189
with:
115190
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -121,7 +196,7 @@ jobs:
121196
const runOnceOutput = JSON.parse(fs.readFileSync('/tmp/run_once_output.json', 'utf8'));
122197
const runCachedOutput = JSON.parse(fs.readFileSync('/tmp/run_cached_output.json', 'utf8'));
123198
124-
let significantChanges = false;
199+
const hasSignificantChanges = '${{ steps.analyze.outputs.has-significant-changes }}' === 'true';
125200
let commentBody = "";
126201
127202
function formatNumber(num) {
@@ -145,6 +220,17 @@ jobs:
145220
let sectionBody = "";
146221
let hasResults = false;
147222
let hasSignificantChanges = false;
223+
224+
function isSignificantChange(diffPct, absoluteChange, benchmarkType) {
225+
const meetsPercentageThreshold = Math.abs(diffPct) > 5;
226+
const meetsAbsoluteThreshold = absoluteChange > 200000;
227+
const isCachedExecution = benchmarkType === 'run_cached' ||
228+
benchmarkType.includes('Cached Execution');
229+
230+
return isCachedExecution
231+
? (meetsPercentageThreshold && meetsAbsoluteThreshold)
232+
: meetsPercentageThreshold;
233+
}
148234
149235
for (const benchmark of benchmarkOutput) {
150236
if (benchmark.profiles && benchmark.profiles.length > 0) {
@@ -181,8 +267,8 @@ jobs:
181267
}
182268
183269
sectionBody += "```\n</details>\n\n";
184-
185-
if (Math.abs(irDiff.diff_pct) > 5) {
270+
271+
if (isSignificantChange(irDiff.diff_pct, Math.abs(irDiff.new - irDiff.old), sectionTitle)) {
186272
significantChanges = true;
187273
hasSignificantChanges = true;
188274
}
@@ -232,7 +318,7 @@ jobs:
232318
if (commentBody.length > 0) {
233319
const output = `<details open>\n<summary>Performance Benchmark Results</summary>\n\n${commentBody}\n</details>`;
234320
235-
if (significantChanges) {
321+
if (hasSignificantChanges) {
236322
github.rest.issues.createComment({
237323
issue_number: context.issue.number,
238324
owner: context.repo.owner,
@@ -246,3 +332,13 @@ jobs:
246332
} else {
247333
console.log("No benchmark results to display.");
248334
}
335+
336+
- name: Fail on significant regressions
337+
if: steps.analyze.outputs.has-significant-changes == 'true'
338+
uses: actions/github-script@v7
339+
with:
340+
script: |
341+
const regressionDetails = JSON.parse('${{ steps.analyze.outputs.regression-details }}');
342+
const firstRegression = regressionDetails[0];
343+
344+
core.setFailed(`Significant performance regression detected: ${firstRegression.module_path} ${firstRegression.id} increased by ${firstRegression.absoluteChange.toLocaleString()} instructions (${firstRegression.diffPct.toFixed(2)}%)`);

.github/workflows/website.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ jobs:
2626
- name: 📥 Clone and checkout repository
2727
uses: actions/checkout@v3
2828

29+
# We can remove this step once `ubuntu-latest` has Node.js 22 or newer for its native TypeScript support. See:
30+
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
31+
# https://nodejs.org/en/learn/typescript/run-natively
32+
- name: 📦 Install the latest Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: "latest"
36+
2937
- name: 🕸 Install Zola
3038
uses: taiki-e/install-action@v2
3139
with:
@@ -77,7 +85,8 @@ jobs:
7785
MODE: prod
7886
run: |
7987
cd website
80-
npm run install-fonts
88+
npm ci
89+
npm run lint
8190
zola --config config.toml build --minify
8291
8392
- name: 📤 Publish to Cloudflare Pages

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
target/
2+
result/
23
*.spv
34
*.exrc
45
perf.data*

.nix/deps/cef.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ pkgs, inputs, ... }:
2+
3+
let
4+
libcef = pkgs.libcef.overrideAttrs (
5+
_: _: {
6+
postInstall = ''
7+
strip $out/lib/*
8+
'';
9+
}
10+
);
11+
cefPath = pkgs.runCommand "cef-path" { } ''
12+
mkdir -p $out
13+
14+
ln -s ${libcef}/include $out/include
15+
find ${libcef}/lib -type f -name "*" -exec ln -s {} $out/ \;
16+
find ${libcef}/libexec -type f -name "*" -exec ln -s {} $out/ \;
17+
cp -r ${libcef}/share/cef/* $out/
18+
19+
echo '${
20+
builtins.toJSON {
21+
type = "minimal";
22+
name = builtins.baseNameOf libcef.src.url;
23+
sha1 = "";
24+
}
25+
}' > $out/archive.json
26+
'';
27+
in
28+
{
29+
env.CEF_PATH = cefPath;
30+
}

.nix/deps/crane.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ pkgs, inputs, ... }:
2+
3+
{
4+
lib = inputs.crane.mkLib pkgs;
5+
}

.nix/deps/rust-gpu.nix

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{ pkgs, inputs, ... }:
2+
3+
let
4+
extensions = [
5+
"rust-src"
6+
"rust-analyzer"
7+
"clippy"
8+
"cargo"
9+
"rustc-dev"
10+
"llvm-tools"
11+
];
12+
toolchain = pkgs.rust-bin.nightly."2025-06-23".default.override {
13+
inherit extensions;
14+
};
15+
cargo = pkgs.writeShellScriptBin "cargo" ''
16+
#!${pkgs.lib.getExe pkgs.bash}
17+
18+
filtered_args=()
19+
for arg in "$@"; do
20+
case "$arg" in
21+
+nightly|+nightly-*) ;;
22+
*) filtered_args+=("$arg") ;;
23+
esac
24+
done
25+
26+
exec ${toolchain}/bin/cargo ${"\${filtered_args[@]}"}
27+
'';
28+
rustc_codegen_spirv =
29+
(pkgs.makeRustPlatform {
30+
cargo = toolchain;
31+
rustc = toolchain;
32+
}).buildRustPackage
33+
(finalAttrs: {
34+
pname = "rustc_codegen_spirv";
35+
version = "0-unstable-2025-08-04";
36+
src = pkgs.fetchFromGitHub {
37+
owner = "Firestar99";
38+
repo = "rust-gpu-new";
39+
rev = "c12f216121820580731440ee79ebc7403d6ea04f";
40+
hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno=";
41+
};
42+
cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4=";
43+
cargoBuildFlags = [
44+
"-p"
45+
"rustc_codegen_spirv"
46+
"--features=use-compiled-tools"
47+
"--no-default-features"
48+
];
49+
doCheck = false;
50+
});
51+
in
52+
{
53+
toolchain = toolchain;
54+
env = {
55+
RUST_GPU_PATH_OVERRIDE = "${cargo}/bin:${toolchain}/bin";
56+
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
57+
};
58+
}

.nix/dev.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
pkgs,
3+
deps,
4+
libs,
5+
tools,
6+
...
7+
}:
8+
9+
pkgs.mkShell (
10+
{
11+
packages = tools.all ++ libs.all;
12+
13+
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath libs.all}:${deps.cef.env.CEF_PATH}";
14+
XDG_DATA_DIRS = "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS";
15+
16+
shellHook = ''
17+
alias cargo='mold --run cargo'
18+
'';
19+
}
20+
// deps.cef.env
21+
// deps.rustGPU.env
22+
)

0 commit comments

Comments
 (0)