Profile

Cover photo
Elazar Leibovich
263 followers|197,664 views
AboutPostsPhotosVideos

Stream

Elazar Leibovich

Shared publicly  - 
 
New attempt to add support for perf kvm -g. This kernel module would sample 64-bit linux guest stack, according to ELF file/Kallsyms symbol.

I'll be happy to hear what do anyone think about the code (the module is tiny, ~300 LOC), or to hear better ideas how to do that.

https://github.com/elazarl/gueststack#readme

Unstable hack: parsing x86-64 assembly to get a non-exported variable from the kernel: https://github.com/elazarl/gueststack/blob/master/module.c#L118
1
Add a comment...

Elazar Leibovich

Compilers & Tools  - 
 
Is there a clang C/C++ sanitation options that does the following:

Every time a negative number is implicitly casted to unsigned, a fairy dies a runtime error is thrown? 99.9% you didn't really mean to do that, and in the 0.1% cases you did mean, you were probably wrong.
1
1
Nick Gully's profile photoBoyd Smith's profile photoPhillip Adkins's profile photoElazar Leibovich's profile photo
19 comments
 
+Julian Gold

True, but he also said in the post that the 0.1% of the time you do it on purpose you are probably wrong 
Add a comment...
 
+OSv Congrats on redis support. How did you support multiple threads in redis? IIRC, the architecture of redis requires multiple processes to utilize SMP[0]. Did you just run multiple redis instances, each in a different thread in different memory areas?

[0] http://redis.io/topics/benchmarks "Redis is a single-threaded server. It is not designed to benefit from multiple CPU cores. People are supposed to launch several Redis instances to scale out on several cores if needed."
How fast is Redis? Redis includes the redis-benchmark utility that simulates running commands done by N clients at the same time sending M total queries (it is similar to the Apache's ab utility). Below you'll find the full output of a benchmark executed against a Linux box.
1
Add a comment...
 
Some pitfalls in C++ delegating constructors:
 
So, C++11 added delegating constructor.  Sounds simple. What could possibly go wrong? You can't get into trouble with that one, can you?

"Any target constructor may itself delegate to yet another constructor. If there is an infinitely
recursive cycle (e.g., constructor C1 delegates to another constructor C2, and C2 also dele‐
gates to C1), the behavior is undefined. No diagnostic is required, because detecting the circu‐
larity can be burdensome to detect at compile time in the general case, when constructors are
defined in different translation units."

So this piece of code can compile without warnings, and have an undefined behavior:

    // header.h
    struct C {
        C(int, int);
        C(int);
    };
    // impl1.cc
    C::C(int x, int y) : C(x){}
    // impl2.cc
    C::C(int x) : C(x, x){}

Why on earth should it be undefined behavior? What optimizations exactly are you allowing by having that undefined?

Why can't it be defined to be an infinite recursion? Yes, when you'll run out of stack you'll get undefined behavior, but until then you can rely on some sort of expected behavior.

Another catch is, exceptions thrown after any constructor is done would invoke the destructor.

So changing this

    C::C(int) : f1(0), f2(0) {
        might_throw();
    }

to:

    C::C(): f1(0), f2(0){}
    C::C(int) : C() {
        might_throw();
    }

changes behaviour, also it looks really harmless change.

Both behaviors are not a big deal, but C++'s this is yet-another paper-cut.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986
38 comments on original post
1
Add a comment...
 
So, C++11 added delegating constructor.  Sounds simple. What could possibly go wrong? You can't get into trouble with that one, can you?

"Any target constructor may itself delegate to yet another constructor. If there is an infinitely
recursive cycle (e.g., constructor C1 delegates to another constructor C2, and C2 also dele‐
gates to C1), the behavior is undefined. No diagnostic is required, because detecting the circu‐
larity can be burdensome to detect at compile time in the general case, when constructors are
defined in different translation units."

So this piece of code can compile without warnings, and have an undefined behavior:

    // header.h
    struct C {
        C(int, int);
        C(int);
    };
    // impl1.cc
    C::C(int x, int y) : C(x){}
    // impl2.cc
    C::C(int x) : C(x, x){}

Why on earth should it be undefined behavior? What optimizations exactly are you allowing by having that undefined?

Why can't it be defined to be an infinite recursion? Yes, when you'll run out of stack you'll get undefined behavior, but until then you can rely on some sort of expected behavior.

Another catch is, exceptions thrown after any constructor is done would invoke the destructor.

So changing this

    C::C(int) : f1(0), f2(0) {
        might_throw();
    }

to:

    C::C(): f1(0), f2(0){}
    C::C(int) : C() {
        might_throw();
    }

changes behaviour, also it looks really harmless change.

Both behaviors are not a big deal, but C++'s this is yet-another paper-cut.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986
4
1
Mat Sutcliffe's profile photoNikolaos Apostolakos's profile photoElazar Leibovich's profile photo
38 comments
 
+Nikolaos Apostolakos Good point. Most of the time, signed integers don't overflow, and many times they keep the invariant that they're positive. It's useful therefor to have overflow undefined behavior, so that the compiler can assume they remain positive - which is a very common use case.

My main point remain, I see no such case for stack exhaustion or infinite loop. Doesn't seem useful there.
Add a comment...

Elazar Leibovich

Shared publicly  - 
 
+OSv is a very interesting project from many angles.  +OSv is first and foremost an operating system, but I also found out it's a great exposition for OS and x64 architecture.

It features high level code, that manages low level stuff, hence, it's a pleasure to read and understand.

Here's a short writeup describing page management at OSv. Note, that I'm far from expert at OS in general and OSv in particular, so there's a good chance the text contains mistakes or inaccuracies. It's in wiki form, so feel free to edit and correct my mistakes:

https://github.com/elazarl/elazarl.github.io/wiki/Managing-Memory-Pages

Also in Quora
http://elazar.quora.com/Memory-Management-at-OSv
2
1
Elazar Leibovich's profile photodor laor's profile photoBenoit Hudzia's profile photo
3 comments
 
Just asked the team to look into it. That's a perfect place for it. Thanks!
Add a comment...
 
I'm reading about the crates now.

Can anyone explain me why the ambigious lookup for crates? Can't there be a single rule how to search for crates (e.g., mod "./fish" for single file, and mod "fish" for directory)?

What happens if both fish.rs, and fish/mod.rs exist?

On the surface, it seems to me problematic, and I can't see a great benefit from that.

I'd love to understand the rationale.

Thanks,
1
Michael Budde's profile photoElazar Leibovich's profile photo
2 comments
 
Maybe "problematic" is a strong word.

It makes writing tools or reasoning about the code harder.

It's nicer to have a single place to look for modules, than two places. I'd
rather write :grep foo module/*.rs than [ -f module.rs ] && grep $TOSEARCH
module.rs || grep $TOSEARCH module/*.rs.
Add a comment...
Have him in circles
263 people
Rami Arowesty's profile photo
Fatih PENSE's profile photo
ritika kohli's profile photo
Igor Itkin's profile photo
Brian Marete's profile photo
Misha P's profile photo
Oded Perlstein's profile photo
Christoph Hack's profile photo
Matt Dragon's profile photo
 
The Go tools is a treasure trove:

Specifically, the digraph+callgraph package. It allows you to query the call graph of your Go package with pointer analysis.

So that, you can see all functions that dynamically calls foo, or all reachable functions from bar. It can detect all possible types to reach foo(x interface{}) in practice.

I was looking for such a tool for C++/Java. But making it would be a couple of man years just to parse the language.

What people often don't get, is the fact that Go is simpler language, less safe than other languages, with less features, and more error prone, makes it simpler to add superb tooling, which are much much more helpful than another language feature.

https://godoc.org/golang.org/x/tools/cmd
Path, Synopsis. benchcmp, The benchcmp command displays performance changes between benchmarks. callgraph, callgraph: a tool for reporting the call graph of a Go program. cover, Cover is a program for analyzing the coverage profiles generated by 'go test -coverprofile=cover.out'.
12
2
James Synge's profile photoElazar Leibovich's profile photoRyanne Dolan's profile photoMassimo Fidanza's profile photo
6 comments
 
+James Synge I'm trying hard not to use interfaces, but this makes my code worse. I need caches a lot - you don't have any without interface.

The problem with generics is not that you'd use generics. I never have, not in Go, not in Java and definitely not in C++. The problem is, there's no widely used, agreed upon, collections library, cache library, etc. I've used guava.Cache a lot, I used multimap and histogram a lot, not to mention the wonderful multithreading library Java has. People don't use it too much in Go, because writing and using those are not easy without generics. I really hope go generate could be a solution.

Here is a concrete example. In a lot of Go code, people are using a single lock to implement MT map. In Java they'd use sharded locks, because it's just as easy.
Add a comment...

Elazar Leibovich

Shared publicly  - 
 
If anyone wants to see me speaking at the Reversim conference - I'll appreciate your vote:

http://summit2015.reversim.com/proposal/Yd4L9eX8h75nof6Cg

(Avi Kivity's talk would be probably very interesting and very original work. I'm just rehearsing known advice. http://summit2015.reversim.com/proposal/m3ANMw3wZr6MipbTA )
Everyone is obsessed with performance, and there are so many tools and ways to measure it. For a single Java program, one would use JProfiler, or VisualVM, but one usually have more than one running service on a machine. How do profilers work? How can the OS measure its own performance? It can get tricky when interrupts are involved. Can you measure performance without affecting the performance? In this talk we would focus on full system profil...
2
Add a comment...

Elazar Leibovich

Shared publicly  - 
 
Brilliant. Fuzzing tool, that instruments assembly instructions, and generates input to change the branch the software takes, creates a legal JPEG out of "hello" seed.
This is an interesting demonstration of the capabilities of afl; I was actually pretty surprised that it worked! $ mkdir in_dir $ echo 'hello' >in_dir/hello $ ./afl-fuzz -i in_dir -o out_dir ./libjpeg-turbo-1.3.1/djpeg. In essence, I created a text file containing just "hello" and asked the ...
2 comments on original post
1
1
Petr Machata's profile photo
Add a comment...

Elazar Leibovich

Shared publicly  - 
 
Iron Dome interception above Lod, near the train station. 30% of Lod's populations are Muslims. Sigh.
1
Jan Mercl's profile photo
 
Take care. Wish you are safe.
Add a comment...

Elazar Leibovich

Shared publicly  - 
 
A great talk by +Gil Tene 

http://www.infoq.com/presentations/latency-pitfalls

Main takeaways:

1) Latency distribution is not normal, thus don't assume the 6-sigma rule applies here (99% at 3 stddev from the average). I wonder if there's some distribution it is similar to. When I took statistics class I often wondered what do you do if you don't know which distribution applies to your dataset.
2) There's a known measurement pitfall, nicknamed by Gil as "coordinated omission". For example, if you throw requests at the server, not at a constant rate, but one after another, where one request waits until the previous one finish. In that case, you're basically omitting the results when the system is slow. You'll have less samples when the system slows down, and you give your system time to recover.
Don't do that. Shoot request at periodic, or even random interval.

Excellent talk. Generally speaking, you should go and watch anything by Gil. Even watching him repeatedly saying "chicken" for an hour and half would give you wonderful insights on garbage collection.
4
2
Elazar Leibovich's profile photoMatt Dragon's profile photoPetr Machata's profile photo
 
+Ilya Grigorik you probably already know it, but might find it interesting.
Add a comment...
People
Have him in circles
263 people
Rami Arowesty's profile photo
Fatih PENSE's profile photo
ritika kohli's profile photo
Igor Itkin's profile photo
Brian Marete's profile photo
Misha P's profile photo
Oded Perlstein's profile photo
Christoph Hack's profile photo
Matt Dragon's profile photo
Links
Other profiles
Contributor to
Basic Information
Gender
Male