Profile

Cover photo
Elazar Leibovich
263 followers|209,046 views
AboutPostsPhotosVideos

Stream

 
Implementation of Java's nested exceptions in go, while I never missed that at start, when the code starts getting complex, having those is very valuable

(by +roger peppe )

http://rogpeppe.neocities.org/error-loving-talk/index.html#37
Why is this better? Errors are important! We spend lots of time looking at errors; A good error message can save days of work; Errors happen all the time. Robustness. Reasonable behaviour in small programs ... but not in large ones. Failure is common. Explicit makes readable ...
9
Elazar Leibovich's profile photoCasey Sybrandy's profile photo
3 comments
 
Yes, I saw that and it's a nice presentation. 
Add a comment...

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...

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 ...
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...
Have him in circles
263 people
Tomer Barkan's profile photo
Boris Chuyko's profile photo
Ariel Keselman's profile photo
chressie's profile photo
‫עומר זק‬‎'s profile photo
Jacob Amrany's profile photo
Ephraim Dan's profile photo
陳世能's profile photo
Yossi Rizgan's profile photo
 
Raymond Chen is jesting about, assuming 2 complement signed integer, and all operations are modulu INT_MAX+1:

    int x; -~x =
    -(INT_MAX-x) mod INT_MAX+1
    = x - INT_MAX mod INT_MAX+1
    = x - INT_MAX + INT_MAX+1 mod INT_MAX+1
    = x + 1 mod INT_MAX+1

He says Microsoft have added a tadpole operator to C++, where -~x is (x+1), and ~-x is (x-1).

People in the comments actually believe it, and complain of Microsoft, and of C++ complexity.

http://blogs.msdn.com/b/oldnewthing/archive/2015/05/25/10616865.aspx
11
1
Todd Knarr (Jrral)'s profile photoAlessandro Baroni's profile photoGunther Laure's profile photoAlexey Rusakov's profile photo
3 comments
 
Alessandro Baroni please google for "jesting"
Add a comment...
 
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  - 
 
+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...

Elazar Leibovich

Shared publicly  - 
 
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
1
Add a comment...

Elazar Leibovich

The Standard  - 
 
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...
People
Have him in circles
263 people
Tomer Barkan's profile photo
Boris Chuyko's profile photo
Ariel Keselman's profile photo
chressie's profile photo
‫עומר זק‬‎'s profile photo
Jacob Amrany's profile photo
Ephraim Dan's profile photo
陳世能's profile photo
Yossi Rizgan's profile photo
Links
Other profiles
Contributor to
Basic Information
Gender
Male