Skip to content

Instantly share code, notes, and snippets.

View mstange's full-sized avatar

Markus Stange mstange

View GitHub Profile
@mstange
mstange / percentage-improvement.md
Last active June 18, 2023 20:35
Gotchas when looking at percentage improvements in a profiler

Gotchas with percentage improvements in a profiler

(Something similar to this post was originally written by Boris Zbarsky on his blog, but I can't find the post now.)

If you have a function which takes up 50% of our time, and you optimize that function so that it takes 30% of your time, by what percentage did you reduce overall time and by what percentage did you reduce time in that function?

The tricky bit here is that the 100% reference value is different, because it was also reduced.

    |<------------------------------- 100ms ------------------------------->|
@mstange
mstange / xul-files.md
Last active July 1, 2022 21:18
Example files for libxul with/without inline information (XUL 4AFD7ADF2E6130A887190DC656D969B60)

Example files for libxul with/without inline information

Native files are from a macOS arm64 build from this treeherder build job.

XUL/4AFD7ADF2E6130A887190DC656D969B60

Binary: XUL.gz (58.3MB, uncompresses to 170.6MB)

Debug file: XUL.dSYM.tar.bz2 (521.2MB, uncompresses to 1.76GB)

@mstange
mstange / dsc_extractor.c
Last active May 25, 2022 17:53
Save and then compile with `clang dsc_extractor.c -o dsc_extractor` and run with `./dsc_extractor /System/Library/dyld/dyld_shared_cache_arm64e ~/extracted-libs/`
// from https://github.com/apple-opensource/dyld/blob/master/dyld3/shared-cache/dsc_extractor.cpp#L817-L849
#include <stdio.h>
#include <stddef.h>
#include <dlfcn.h>
typedef int (*extractor_proc)(const char* shared_cache_file_path, const char* extraction_root_path,
void (^progress)(unsigned current, unsigned total));
@mstange
mstange / worker.js
Created December 6, 2021 19:53
Cloudflare worker which serves raw source code from googlesource.com
/**
* This worker makes sourcecode from googlesource.com accessible as
* plain text, with permissive CORS headers.
* This is a workaround for https://github.com/google/gitiles/issues/7 :
* googlesource.com currently only serves base64-encoded sources, and is
* not accessible by cross-site requests.
*
* Request URL format: /<subdomain>/<path>
* This gets the code from https://<subdomain>.googlesource.com/<path>?format=TEXT
* and base64-decodes it.
@mstange
mstange / debug-try-build-macos.md
Created August 31, 2021 18:43
How to debug a try build on macOS with lldb with full debug information and source

I tried this with an x86_64 try build running on an M1 machine, and it worked. It was this build (from Aug 26, 2021) and I'll use it as an example.

TL;DR

You need the XUL.dSYM and a local source checkout of the same revision, and then tell lldb about them like this:

% lldb /Volumes/Firefox\ Nightly/Firefox Nightly.app/Contents/MacOS/firefox
(lldb) target modules add "/Volumes/Firefox Nightly/Firefox Nightly.app/Contents/MacOS/XUL" --symfile ~/Downloads/target.crashreporter-symbols-full/XUL/E13E188188F0368CB252DC67549D134B0/XUL.dSYM/Contents/Resources/DWARF/XUL
// source: simplerperf_report.proto
/**
* @fileoverview
* @enhanceable
* @suppress {messageConventions} JS Compiler reports an error if a variable or
* field starts with 'MSG_' and isn't a translatable message.
* @public
*/
// GENERATED CODE -- DO NOT EDIT!
@mstange
mstange / fenix-sampling-profiler-intent.diff
Created March 11, 2020 19:02
When opening Fenix with an app link intent, this starts the Android sampling profiler. When opening the settings panel, the profiler is stopped and the result is dumped to /sdcard/Android/data/org.mozilla.fenix.performancetest/files/fenix.trace. The trace files can be opened with the profiler in Android Studio.
diff --git a/app/build.gradle b/app/build.gradle
index 1f1926a2..5ed912b2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -64,17 +64,18 @@ android {
applicationIdSuffix ".fenix.debug"
manifestPlaceholders.isRaptorEnabled = "true"
resValue "bool", "IS_DEBUG", "true"
pseudoLocalesEnabled true
}
@mstange
mstange / main.mm
Created June 5, 2019 17:48
Example program that renders feTurbulence using OpenGL shaders
// Produces rendering that looks like http://tests.themasta.com/turbulence.svg
//
// Save to main.mm, and then compile and run using:
// $ clang++ main.mm -Wall -O3 -framework Cocoa -framework OpenGL -o test && ./test
//
// Equivalent SVG code:
//
// <svg xmlns="http://www.w3.org/2000/svg">
// <defs>
// <filter id="turb" color-interpolation-filters="sRGB">
diff --git a/gfx/wr/webrender/src/device/gl.rs b/gfx/wr/webrender/src/device/gl.rs
--- a/gfx/wr/webrender/src/device/gl.rs
+++ b/gfx/wr/webrender/src/device/gl.rs
@@ -1281,30 +1281,30 @@ impl Device {
name: &str,
shader_type: gl::GLenum,
source: &String,
) -> Result<gl::GLuint, ShaderError> {
debug!("compile {}", name);
let id = gl.create_shader(shader_type);
# HG changeset patch
# User Markus Stange <mstange@themasta.com>
# Date 1548379388 18000
# Thu Jan 24 20:23:08 2019 -0500
# Node ID e442cd9c43e361fec584d473888cbf07b5910f1e
# Parent 19bfb22ffae28a0a6ec449064daff863213269a6
Bug 1514007 - Annotate <script> evaluation profiler labels with async/defer. r?smaug
This also moves the label from ScriptLoader::ProcessScriptElement to
ScriptLoader::EvaluateScript so that it also kicks in for scripts that are run