Skip to content

Instantly share code, notes, and snippets.

View tanghaodong25's full-sized avatar
:octocat:
Focusing

Haodong Tang tanghaodong25

:octocat:
Focusing
  • Antfin,Intel
  • shanghai china
View GitHub Profile
@tanghaodong25
tanghaodong25 / travis-local.md
Created November 27, 2019 00:20 — forked from fulldecent/travis-local.md
Run Travis build locally

travis-local.md

Preconditions:

  1. POSIX or Windows system
  2. Install Docker
  3. A GitHub repo that already builds on Travis

Postcondition:

@tanghaodong25
tanghaodong25 / ByteBufferOutputStream.java
Created April 29, 2019 02:38 — forked from ncruces/ByteBufferOutputStream.java
OutputStream that writes to a direct ByteBuffer
package io.github.ncruces.utils;
import java.io.OutputStream;
import java.nio.ByteBuffer;
public final class ByteBufferOutputStream extends OutputStream {
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
private ByteBuffer buf;
public ByteBufferOutputStream() { buf = ByteBuffer.allocate(32); }
@tanghaodong25
tanghaodong25 / spark-shuffle-log.diff
Created April 8, 2019 03:41
spark shuffle read block time log
diff --git a/core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala b/core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala
index 94def4d31c..4f45e2d454 100644
--- a/core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala
+++ b/core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala
@@ -100,7 +100,7 @@ final class ShuffleBlockFetcherIterator(
* A queue to hold our results. This turns the asynchronous model provided by
* [[org.apache.spark.network.BlockTransferService]] into a synchronous model (iterator).
*/
- private[this] val results = new LinkedBlockingQueue[FetchResult]
+ private[this] val results = new LinkedBlockingQueue[(FetchResult, Long, Long)]
@tanghaodong25
tanghaodong25 / FileLocking.java
Created March 27, 2019 02:17 — forked from syazawa/FileLocking.java
Example of inter-process and inter-thread file locking in Java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileLock;
// The class demonstrates how to get an exclusive file lock that prevents other threads and processes / JVMs from
// obtaining a lock on the same file. To do this, you need to synchronize a block on a file and acquire FileLock. See
// comments below for more details. Run this class in multiple JVMs and see each thread of each JVM acquires a lock in
// an orderly fasion.
public class FileLocking extends Thread
public class Client {
public static void main(String args[]) {
EqService eqService = new EqService(addr, "123456", 1, bufferNbr, false).init();
CqService cqService = new CqService(eqService, eqService.getNativeHandle()).init();
List<Connection> conList = new CopyOnWriteArrayList<Connection>();
ConnectedCallback connectedCallback = new ConnectedCallback(conList, false);
ReadCallback readCallback = new ReadCallback(false, eqService);
ShutdownCallback shutdownCallback = new ShutdownCallback();
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
package example;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.util.CharsetUtil;
@tanghaodong25
tanghaodong25 / Gdb-JNI.md
Created August 8, 2018 01:29 — forked from Zelldon/Gdb-JNI.md
How to debug JNI C code

Compile with debug flags

Compile with debug flags use -g on gcc

Run gdb

gdb --args java -Djava.library.path=src/main/resources/lib/ 
                -cp [path-to-jar] [MAINCLASS]

On GDB

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@tanghaodong25
tanghaodong25 / example.c
Created May 15, 2018 08:42 — forked from plebioda/example.c
libfabric example
#include <rdma/fabric.h>
#include <rdma/fabric.h>
#include <rdma/fi_endpoint.h>
#include <rdma/fi_cm.h>
#include <rdma/fi_errno.h>
#include <rdma/fi_rma.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>