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
yifan-gu / result.sh
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
finish
package main
import (
"fmt"
"net"
"os"
"syscall"
"time"
)
@yifan-gu
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
yifan-gu / gist:9606979
Created March 17, 2014 19:56
== in golang
package main
import (
"fmt"
)
type obj struct {
a int
}
@yifan-gu
yifan-gu / gist:9673297
Created March 20, 2014 20:37
slice vs list
package slice_vs_list
import (
"container/list"
)
func runSliceAppend() {
s := make([]int, 0)
for i := 0; i < 1024; i++ {
s = append(s, i)
@yifan-gu
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
yifan-gu / log.txt
Created June 24, 2014 20:53
bootstrap fail
3rdparty/Makefile.am:71: warning: source file '$(GTEST)/src/gtest-all.cc' is in a subdirectory,
3rdparty/Makefile.am:71: 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
mesos.pb.cc: In function ‘void mesos::protobuf_AssignDesc_mesos_2eproto()’:
mesos.pb.cc:293:97: error: ‘const class mesos::HealthCheck’ has no member named ‘consecutive_failures_’
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HealthCheck, consecutive_failures_),
^
mesos.pb.cc:425:95: error: ‘const class mesos::SlaveInfo’ has no member named ‘private_resources_’
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SlaveInfo, private_resources_),
^
mesos.pb.cc:591:104: error: ‘const class mesos::ResourceStatistics’ has no member named ‘net_rx_packets_’
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ResourceStatistics, net_rx_packets_),
^