• This repository has been archived on 28/Aug/2021
  • Stars
    star
    172
  • Rank 221,201 (Top 5 %)
  • Language
    Haskell
  • License
    Other
  • Created about 7 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Example code for how we swap compiled code within a running Haskell process.

GHC.Hotswap

Demonstrates how to build an application that can hot-swap parts of itself at runtime, using GHC. This is a standalone illustration of the technology used in production in the Sigma system at Facebook.

There are a handful of Haskell packages here:

ghc-hotswap

Shared object swapping goodness.

Demo

Quick Start

Build types

  1. cd ghc-hotswap-types
  2. cabal configure
  3. cabal install

Build hotswap

  1. cd ghc-hotswap
  2. cabal configure
  3. cabal install

Build so

  1. cd ghc-hotswap-so
  2. cabal configure --enable-library-for-ghci
  3. cabal build (Note the file path of dist/build/HSghc-hotswap-so(...).o)

Run demo

  1. cd ghc-hotswap-demo
  2. cabal configure
  3. cabal build
  4. cabal run <path of first .o file>

ghc-hotswap-types

Example library for common types between the main binary and shared object. The object code for this library will end up in the final binary, but the shared object needs to know what types to generate at the API boundary.

No special configuration for this library

  • cabal configure
  • cabal install

ghc-hotswap

General library for loading and consecutively updating shared objects in a concurrency-safe manner.

No special configuration for this library

  • cabal configure
  • cabal install

ghc-hotswap-so

Example shared object library. Constains:

  • Handles module defining a function that returns a StablePtr to our expected API object and exports a c-symbol for it.
  • MyCode module as an example of complex library code that can be updated quickly

The main purpose is to generate an object file that another binary will know how to dynamically open. The --enable-library-for-ghci cabal flag does this for us.

  • cabal configure --enable-library-for-ghci
  • cabal build

The file we care about gets placed in ghc-hotswap-so/dist/build/ with a filename prefix like HSghc-hotswap-so and extension .o. The path to this file is important (or copy it to a nicer location for yourself) as you'll need it later.

ghc-hotswap-demo

Demo executable for loading + unloading shared objects on the fly.

Note the configuration set in ghc-hotswap-demo.cabal. It does not depend on ghc-hotswap-so and adds -rdynamic and -fwhole-archive-hs-libs as GHC flags.

  • cabal configure
  • cabal run <path-of-first-.o>

The program loads in the first shared object and periodically prints some information. It's waiting for input on stdin for the path of the next shared object to use.

  • Go back to ghc-hotswap-so
  • Edit SO/Handles.hs or SO/MyCode.hs to do as you want
  • Rebuild the object file (cabal build)
  • Copy the desired .o file somewhere friendlier
  • Send the full path of the .o to stdin of the demo program
  • See the output of the program change live
  • ???
  • Profit!

More Repositories

1

f8app

Source code of the official F8 app of 2017, powered by React Native and other Facebook open source projects.
JavaScript
13,987
star
2

messenger-platform-samples

Messenger Platform samples for sending and receiving messages. Walk through the Get Started with this code. https://developers.facebook.com/docs/messenger-platform/quickstart
JavaScript
1,717
star
3

360-video-player-for-android

Sample code for creating a 360 video player on Android. Creates an OpenGL ES scene that renders a sphere textured with video frames from MediaPlayer playback. Does not use the NDK. This is a simple example of the core elements of 360 video rendering and is not intended to be production quality code. The code may be unstable. This is won't be maintained.
Java
616
star
4

messenger-bot-samples

Messenger Bot Samples
JavaScript
554
star
5

Canvas-Streaming-Example

This project contains example code showing how to go live on Facebook using a <canvas> element as a source.
JavaScript
340
star
6

audience-network

Open source projects to demonstrate SDK and sample code usages and integration, and to collaborate and support peers in this community.
319
star
7

oculus-networked-physics-sample

This is a networked physics sample for Rift built in Unity.
C#
310
star
8

WhatsApp-Business-API-Postman-Collection

A Postman collection that contains the full set of sample WhatsApp Business API calls.
294
star
9

fbinstant-samples

Sample projects for the Facebook Instant Games platform
JavaScript
256
star
10

graph-api-webhooks-samples

These are sample clients for Facebook's Graph API Webhooks and Instagram's Real-time Photo Updates API.
CoffeeScript
236
star
11

whatsapp-api-examples

Examples of how to use WhatsApp Cloud API on the WhatsApp Business Platform
JavaScript
203
star
12

original-coast-clothing

Sample Messenger App - Original Coast Clothing
JavaScript
202
star
13

fbctf-2019-challenges

The challenge source code and solutions for FBCTF 2019
Python
200
star
14

threads_api

This repository contains a sample app for developers who are interested in integrating with the Threads API.
JavaScript
187
star
15

workplace-platform-samples

Sample code to enable Workplace customers to make the most of the features of the Workplace Custom Integrations platform.
PowerShell
183
star
16

kotlin_ast_tools

Utilities and examples used in Meta to simplify migration from Java to Kotlin and maintenance of Kotlin code.
Kotlin
149
star
17

fblogin-sample

Sample implementations for developers to take as reference when building into fb login products.https//developers.facebook.com/docs/facebook-login/messenger-integration
JavaScript
120
star
18

sculpting-and-simulations-sample

Sample code that supplements the Sculpting And Simulations talk.
C++
96
star
19

live-comments-teleprompter

Example code shows how to retrieve comments and reactions for a Facebook Live video.
JavaScript
89
star
20

bucksamples

Samples for the Buck build tool.
Objective-C
72
star
21

original-coast-clothing-ig

Sample Instagram App - Original Coast Clothing
JavaScript
51
star
22

glTF-Renderer

Sample glTF Renderer for Android
Java
50
star
23

marketing-api-samples

Solution samples using the Facebook marketing API.
JavaScript
49
star
24

reels_publishing_apis

This repository contains sample apps for developers who are interested in integrating with Reels APIs.
JavaScript
41
star
25

OpenNetNorad

Sample system to manage Uping and Upong (UdpPinger) instances, used to measure / graph network latency and loss on Linux
Python
38
star
26

VRDeepLinkSDK

VRDeepLinkSDK provides a quick way to integrate your app to display a 360 photo/video content from Facebook.
Java
37
star
27

android-native-library-merging-demo

Buck demo showing how to safely merge native libraries in Android apps.
C
36
star
28

sdstudio

sdstudio project for image generation and modification
Python
30
star
29

rusty-bunny

a tool that lets you write smart bookmarks
Rust
23
star
30

pytorch-quantization-workshop

Code for a workshop hosted at the MLOps World Summit '22
Jupyter Notebook
16
star
31

insights_dashboard

Insights Dashboard is a sample app that integrates with Meta's Insights APIs
JavaScript
14
star
32

lead-ads-webhook-sample

Sample code to accelerate client's adoption of Lead Ads and Conversion Leads products, by integrating with our advertising platform. Developers can also take this as reference when building integrations, without having to start from scratch.
C#
14
star
33

ListViewToRecyclerView

Library to help products migrate from ListView to RecyclerView.
Java
11
star
34

fbrell

An interactive environment to explore the Facebook JavaScript SDK.
Go
11
star
35

GetRecommendations

A complete, sample android application that uses the Audience Network SDK.
Java
10
star
36

share_to_reels_android

Android sample app with Share to Reels
Java
10
star
37

OptiMate

Sample codes that allows to fetch different Reach and Frequency curves from the Facebook Marketing API.
Python
10
star
38

discord-help-bot

This is the code used in a tutorial called "Build a Discord bot with Rust and Serenity"
Rust
9
star
39

share_to_reels_ios

iOS sample app with Share to Reels
Swift
7
star
40

f8-2014

For sample code used during sessions at the 2014 F8 conference.
Objective-C
7
star
41

cp_reference

We are building a 3rd party commerce platform partner reference implementation.
Python
7
star
42

typefast

An auto-deployable scripting environment that enables people to quickly leverage powerful automation tools.
JavaScript
6
star
43

python-typing-tutorial

A sample Python project to demonstrate basic type checking concepts and best practices.
Python
5
star
44

mit-dl-workshop

Jupyter Notebook
5
star
45

caldera-security-tests

This project was created to provide examples of a TTP Runner and Security Regression Pipeline using vulnerabilities discovered in MITRE CALDERA by Jayson Grace from Meta's Purple Team.
Go
5
star
46

video-template-builder

An intuitive tool for creating dynamic video templates. Seamlessly integrate and customize videos, images, and audio files to produce new media at scale.
Python
4
star
47

transparent-automated-ads-demo-app

A demo web app to simulate the marketplace integration for Transparent Automated Ads
JavaScript
3
star
48

NeurIPS2018

Notebooks from the NIPS 2018 booth screen rolling deck
Jupyter Notebook
3
star
49

Facebook-Reels-Publishing-API-Postman-Collection

A Postman Collection that contains requests to upload Reels to Facebook
3
star
50

marketing_messages_measurement

This project provides best practices on how to measure WhatsApp marketing messages effectively, understand how many incremental conversions businesses canget as well as how to compare the effectiveness of marketing messages against other external platforms such as email/SMS.
R
2
star
51

MediaSpatialAppTemplate

A sample media Android app works on Quest devices, in both Android 2D Panel Mode and Immersive Mode supported by Meta Spatial SDK.
Kotlin
2
star
52

wamquery

Collection of runtime primitives for implementing a SQL-like query language
C
2
star
53

portal-sdk-samples

Sample implementations demonstrating how to integrate various Portal SDK feature modules into an Android App for Portal
Java
1
star
54

cppcon24-async-demo

Demo application for C++con 2024 to showcase async stacks
Python
1
star