Skip to content

Instantly share code, notes, and snippets.

View yifan-gu's full-sized avatar

Yifan Gu yifan-gu

  • Anchorage Digital
  • San Francisco
View GitHub Profile
yifan-gu /
Last active August 29, 2015 13:56
if reaching EOF, splice won't block
$ go build testsplice.go
$ echo "hello splice" | ./testsplice
$ splicing... buffer size: 4096
recv: hello splice
count: 13
package main
import (
yifan-gu / gist:9286214
Last active August 29, 2015 13:56
Discussion on the schedule policy
For this problem, I tested two policies.
The first one is "small tasks first". Using this policy can make the scheduler achieve very high throughput in the terms of "# of tasks it can schedule in a given time".
But it will be likely to cause starvation problem. In which case if the small tasks keep coming, they will preempt the scheduler and block the big tasks.
So in real environment, this kind of scheduler will incent users not to lie about their actual usage.
The second one is "small tasks first + starvation proof"
yifan-gu / gist:9606979
Created March 17, 2014 19:56
== in golang
package main
import (
type obj struct {
a int
yifan-gu / gist:9673297
Created March 20, 2014 20:37
slice vs list
package slice_vs_list
import (
func runSliceAppend() {
s := make([]int, 0)
for i := 0; i < 1024; i++ {
s = append(s, i)
yifan-gu / gist:9848440
Last active August 29, 2015 13:57
test for sequence point
yifan@yifan-laptop:~/c/playground$ cat testsequencepoint.c
#include <stdio.h>
int a[10];
int i;
int main(int argc, char *argv[])
for (i = 0; i < 5;) {
a[i] = a[i++] + 5;
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 85ca5c4..c197da9 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -35,6 +35,7 @@
#include <process/pid.hpp>
#include <process/subprocess.hpp>
+#include <stout/duration.hpp>
#include <stout/option.hpp>
Built-in gogoprotobuf over HTTP:
=== RUN TestGoGoProtobufHTTPMessenger
Generating 8192 messages
Sending 8192 messages from [0] to [0]
Done! time elasped: 440ms
Verifying 8192 messages
Messages look good!
Generating 8192 messages
Sending 8192 messages from [0] to [1]
Done! time elasped: 1935ms
yifan-gu / log.txt
Created June 24, 2014 20:53
bootstrap fail
3rdparty/ warning: source file '$(GTEST)/src/' is in a subdirectory,
3rdparty/ but option 'subdir-objects' is disabled
automake: warning: possible forward-incompatibility.
automake: At least a source file is in a subdirectory, but the 'subdir-objects'
automake: automake option hasn't been enabled. For now, the corresponding output
automake: object file(s) will be placed in the top-level directory. However,
automake: this behaviour will change in future Automake versions: they will
automake: unconditionally cause object files to be placed in the same subdirectory
automake: of the corresponding sources.
automake: You are advised to start using 'subdir-objects' option throughout your In function ‘void mesos::protobuf_AssignDesc_mesos_2eproto()’: error: ‘const class mesos::HealthCheck’ has no member named ‘consecutive_failures_’
^ error: ‘const class mesos::SlaveInfo’ has no member named ‘private_resources_’
^ error: ‘const class mesos::ResourceStatistics’ has no member named ‘net_rx_packets_’