Skip to content

Instantly share code, notes, and snippets.

View SupinePandora43's full-sized avatar
©️
#

SupinePandora43 SupinePandora43

©️
#
View GitHub Profile
@teo-tsirpanis
teo-tsirpanis / ScratchBuffer.cs
Created December 13, 2021 21:57
GC-friendly scratch buffers of arbitrary size in C# made easy.
// Written by Theodore Tsirpanis.
// Licensed under the CC0 license.
// SPDX-License-Identifier: CC0-1.0
using System.Buffers;
#nullable enable
/// <summary>
/// Manages temporary buffers with low GC pressure.
@EgorBo
EgorBo / Dynamic PGO in .NET 6.0.md
Last active January 25, 2024 15:15
Dynamic PGO in .NET 6.0.md

Dynamic PGO in .NET 6.0

Dynamic PGO (Profile-guided optimization) is a JIT-compiler optimization technique that allows JIT to collect additional information about surroundings (aka profile) in tier0 codegen in order to rely on it later during promotion from tier0 to tier1 for hot methods to make them even more efficient.

What exactly PGO can optimize for us?

  1. Profile-driving inlining - inliner relies on PGO data and can be very aggressive for hot paths and care less about cold ones, see dotnet/runtime#52708 and dotnet/runtime#55478. A good example where it has visible effects is this StringBuilder benchmark:

  2. Guarded devirtualization - most monomorphic virtual/interface calls can be devirtualized using PGO data, e.g.:

void DisposeMe(IDisposable d)
// simplest file logger in c++
#include <fstream>
//#include <iostream>
static void LOG(char* message) {
//std::cout << message << std::endl;
std::fstream fs;
fs.open("log.txt", std::fstream::in | std::fstream::out | std::fstream::app);
fs << message;
fs << "\n";
fs.close();
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PhysicsMovement : MonoBehaviour
{
[SerializeField] private float _minGroundNormalY = .65f;
[SerializeField] private float _gravityModifier = 1f;
[SerializeField] private Vector2 _velocity;
@ForeverZer0
ForeverZer0 / ExtractTarGz.cs
Last active February 5, 2024 10:36
Use pure C# to extract .tar and .tar.gz files
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
namespace TarExample
{
public class Tar
{
@MatthewRalston
MatthewRalston / roflcopter.md
Created February 14, 2018 19:03
ROFLcopter ASCII text art

ROFLcopter ASCII

If you hear SOI SOI SOI, you better RUN RUN RUN ’cause the ROFLCOPTER ASCII army is coming for you!

THE ORIGINAL ROFLCOPTER

 ROFL:ROFL:ROFL:ROFL
         _^___
 L __/ [] \
@SaschaWillems
SaschaWillems / vk.cpp
Last active November 23, 2023 10:02
Multiple Vulkan buffer binding points
Shader
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec3 inPosB;
layout (location = 3) in vec3 inColorB;
...
Application
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 9, 2024 04:48
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@MariadeAnton
MariadeAnton / hi-satellite.md
Last active August 7, 2022 18:06
Travis CI Demo Examples - GitHub Satellite 2019
@wassname
wassname / to_filename.py
Last active November 30, 2022 14:19
python convert string to safe filename
"""
Url: https://gist.github.com/wassname/1393c4a57cfcbf03641dbc31886123b8
"""
import unicodedata
import string
valid_filename_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
char_limit = 255
def clean_filename(filename, whitelist=valid_filename_chars, replace=' '):