MinGW 8.1.0 vs. VC++2017: performance benchmark

I don't know why, but after writing down that I'm going to VC++2017 yesterday I took a simple benchmark testing. No, it was not that much delicate: it reads a file via ifstream and in the memory it parses the data, and the performance was checked with GetTickCount(). The result was that MinGW was always 10~30% faster than VC++2017.

Hmmm...... Do I have to get back to MinGW?

MinGW 8.1.0 vs. VC++2017: 수행성능 비교

어제 VC++2017로 가겠다고 써놓고 무슨 바람이 불었는지 간단한 퍼포먼스 벤치마킹을 수행했습니다. 제가 능력이 출중해서 정교한 실험을 한 건 아니고, 그냥 ifstream으로 파일을 읽은 후 메모리에 올려서 약간의 parsing을 하는 작업을 GetTickCount()로 찍어서 체크해봤는데, 제 사용 사례의 경우에는 MinGW가 VC++2017보다 항상 10~30%정도 더 빠르더군요.

MinGW로 돌아가야 되나...... 싶습니다. -_-

Going Native

A lot of things happened behind the scenes. Due to some unflexible cash flow my company closed Korea branch, and I moved to a small company and got dual role of system engineer and developer. Well, the company first expected to do engineering and development works in 50:50 manner, but in practice I concentrate on development itself. I think it's a good start for a ex-hobbiest-programmer where the customer changed their feedback from negative to positive after my application is delivered to them.

And, during the time I thought of the techonlogy stacks I should bring with myself. Though Qt can cover everything from desktop to mobile, and is equipped with a lot of powerful features, after applying the tool to the work situation things dragged me of my legs. For example:

  1. It's BIG. HUGE. OK. It's good to have a lot of things, but the size of library grows bigger with any new addition of the features. For simple tasks, I can't avoid the feeling of using zweihander to grass cutting.
  2. SLOW. From Qt Model-View framework which is a failure and needs restructuring, to container classes like QList or QLinkedList saying "we're concentraing on convenience while STL stresses on raw speed," and the speed of database manipulation is not that good eighter. For databases, I found out it's far faster to use SOCI after converting things from QString to std::string. From my experience, for the same task Qt took about twice or more time to perform the same task against others(e.g. STL or wxWidgets).
  3. Developer is "locked" into the Qt ecosystem. Well, I admit its rich feature gives developers more development convenience, but after adopting to Qt I don't feel good with using it with other libraries or environments. Sometimes I feel I'm working on Java instead of C++, in terms of not only structue but also running performance of the system(meaning that it's slow, unlike C++). During coding, I'm not sure whether I'm using Java or c++. Ah, of course signal-slot mechanism and QString is such a technologicla advance in a decade.
  4. It has some holes here and there, for example, Qt Quick. I love the approach and structure of Qt Quick and I admit it's such an accomplishment, I see occasional "broken" frames on Windows/Intel environment, or I see too long time for the first run on Andorid(they existed until Qt 5.9. I heard that the bytecode compilation in Qt 5.11 resolved the slow first start a lot, but I had no chance to test it). Or, for me a MinGW user, in Qt 5.10 qdoc(and that Qt documentation) suddenly became unavailable because MinGW 5.3 couldn't compile libclang(......). And the new autompletion with libclang in Qt Creator is said to be toooooo slow....... And so on and on and on. 
  5. Sometimes there are things infeasible to programmers. Qt hides the implementation details in its private layer, which makes it too difficult to debug when some bad things happen, especially when it's related with some specific feature of Qt itself. What's more, due to the behavior of QURL to force percent-encoding(and which is malfunction in specific context), I had to give up QNetworkAccess and adopt libcurl(with additional coding where I had to implement about 3/4 of my network coding again......).


Well, anyway it's BIG enough to be tackled from anywhere, but you know, now I can say there's no one library/framework that fits too all. So I looked for any alternatives and asked for help from my close friends. And guess what? Now I'm dropping the dependency against Qt and bringing development staks close to native "recommended" environment.

  1. C++ / wxWidgets & more: whoever says what, C++ is my main development platform. And I concluded wxWdigets, thin wrapper of native widgets, can replace Qt Widgets. Thinking of my past experience, I had to save my time so that I had to use Qt Widgets anyway(and Qt Quick took relatively too much time to develop). wxWidgets consumes less memory and bootstrapping is faster, which fits to my philosophy of "relatively fast running."
  2. Ah. I changed my compiler from MinGW to VC++. I was using MinGW to expect consistency against platforms, namely Windows and Linux, but nowadays I had to use some Windows API which doesn't exist in MinGW(:P). And it looks like VC++ looks good from VC++ 2017. I think I should conquer the differences between compilers with some nuts.
  3. Javascript: Javascript is the language of web! As soon as I'm done with my current project, I'd like to start learning vue.js and node.js(especially Express.js) and apply them to the work.
  4. Kotlin: OK. Now the desktop is done, but still "mobile" remains. Kotlin is native in Android(and I strongly feel that Google pushes it harder than ever after it lost the case against Oracle), and when Kotlin/Native is copmlete iOS can be "natively" supported. It's a good choice for me, who won't touch Apple ecosystem for a few years but no idea after that.


Originally I added Python and Rust to the list, but I found out that I don't have to dig deep Python though it's used in the product I currently engineer, and I concluded that from Rust I can adopt the structure to C++ so I don't have to worry much. And I also considered Go but its structure was not of my taste......

So that's all. At present, I just want to close the current project and have some time to learn Javascript.

네이티브로 가자!

조용했던 그동안 많은 일이 있었습니다. 다니던 회사가 자금사정이 악화되어 한국지사가 폐쇄되었고, 여차저차해서 작은 회사의 모 제품 시스템 엔지니어 겸 개발자가 되었습니다. 그리고 원래대로라면 엔지니어링과 개발이 50:50이 되어야 하는데, 또 어쩌다보니 엔지니어링보다는 개발에 집중하고 있습니다. 뭐, 제 개발품으로 인해 그간 계속 부정적이기만 했던 고객사의 피드백이 최초로 긍정적으로 바뀌었다고 하니, 20년동안 취미로만 프로그래밍을 하던 사람의 실적치고는 꽤 괜찮은 출발인 것 같습니다.

그리고 그동안 제가 가져가야 할 개발환경에 대해 많이 생각했습니다. 비록 Qt가 데스크탑에서 모바일에 이르기까지 다양한 플랫폼을 지원하고 매우 강력한 기능들이 많다지만, 실제로 업무현장에 적용해보니 확실히 몇가지 문제들이 제 발목을 잡더군요. 몇가지를 예로 들자면......

  1. 덩치가 큽니다. 기능이 많은건 좋은데, 그 반대급부로 라이브러리의 크기가 계속 커져가고 있습니다. 닭 잡는데 소 잡는 칼을 쓰는 듯한 느낌을 지울 수 없습니다.
  2. 느립니다. 많은 사람들로부터 전면 개보수가 필요하다고 평가받는 Qt Model-View framework부터 시작해서, QList, QLinkedList 등 container class들은 아예 "STL이 속도라면 우린 편의성"이 모토고, 데이터베이스 처리도 썩 그렇게 좋은 성능을 보여주지 못하고 있습니다. DB는 Qt datbase framework보다는 QString을 std::string으로 변환한 뒤에 SOCI를 쓰는게 훨씬 빠르더군요.
  3. 개발자가 Qt의 개발환경에 '갇힙니다.' Qt가 다방면으로 매우 많은 기능을 지원하고, 그로 인해 개발 편의성이 올라가는 것은 누구나 인정하는 바입니다만, 한번 Qt의 개발환경을 사용하고 나게 되면 다른 라이브러리나 환경을 접목시키기가 쉽지 않다는 느낌을 받습니다. 가끔씩은 매우 Java같은 느낌의 C++ 프레임워크라는 느낌이 들더군요. 구조만 그러면 모르겠는데, 프로그램의 수행속도도 C++보다는 Java에 더 가깝다는 느낌을 많이 받습니다(즉, C++답지 않게 느리게 느껴집니다). 개발을 하고 있다보면 내가 C++을 쓰는지 Java를 쓰는지 살짝 헷갈리기도 합니다(......). 아, 물론 signal-slot 매커니즘과 QString은 인정합니다.
  4. 꼭 뭔가 하나씩 빵꾸가 납니다. 가장 대표적인게 Qt Quick입니다. 비록 Qt Quick은 기능과 접근방법 모두 훌륭하고, 대단한 기술적 성공이긴 합니다만, Windows/Intel 비디오카드 환경에서 화면 크기 변경시에 프레임이 깨져서 눈에 거슬린다던가, Android로 빌드할 경우 최초 실행시 boottime이 너무 길어진다던가 하는 등의 문제점이 있습니다(최소한 5.9까지 상존했던 문제입니다. 5.11에서는 bytecode compilation 덕에 많이 좋아졌다고는 들었습니다만, 테스트는 못해봤네요). 아니면 저의 경우 플랫폼간 컴파일러의 일관적 행태를 위해 MinGW를 쓰는데, Qt 5.11의 경우 현재 지원하는 MinGW 5.3에서 libclang이 빌드되지 않는다는 이유 하나만으로 qdoc을 빌드하지 않게 막았다던가(......) 하는 등의 자잘한 건들이 생깁니다. 아울러 Qt Creator의 autocompletion을 libclang 기반으로 바꾼다고 선언했는데, 너무 느리다고 말이 많기도 하고...... 
  5. 가끔 뜬구름 잡는 듯한 느낌이 있습니다. Qt가 개발을 편하게 하게 하기 위하 많은 기능을 지원하긴 하는데, 이게 프로그램 동작의 많은 부분을 숨겨놓은 터라 가끔 문제가 생기면 어디서 뭘 봐야 할지 감이 안 잡히는 상황들이 발생합니다. 특히 그게 Qt의 특정 기능과 직접적으로 연관된 경우는 더 그렇습니다. 심지어 최근에는 QURL에서 퍼센트 인코딩을 강제하는(문제는 이게 특정 상황에서는 적용되기가 어렵다는) 특징때문에 그 편한 QNetworkAcccessManager을 쓰지 못하고 libcurl을 써야 했던(그리고 네트웍 코드의 3/4을 갈아엎어야 했던......-_-) 상황도 있었습니다.

뭐, 프레임워크의 덩치가 워낙 크다보니 말이 많긴 하겠습니다만, 하여간 실무에 적용하다보니 이런저런 문제점들이 보이더군요. 그래서 여러가지 대안도 찾아보고, 주변 분들의 조언도 구한 끝에 Qt에 대한 의존성을 버리고, 네이티브에 가까운 개발환경을 가져가는게 좋겠다는 결론을 내렸습니다.

  1. C++ / wxWidgets & more: C++은 제 메인 개발환경이니 필히 가져가야 하고, GUI는 네이티브 위젯의 thin wrapper인 wxWidgets를 쓰면 되겠다는 결론을 내렸습니다. 시간이 없어 급하게 개발하다보면 Qt Quick은 항상 그림의 떡이고, 맨날 Qt Widgets만 쓰던 입장에서는 차라리 네이티브라 RAM도 덜 먹고 bootstraping도 빠른 wxWidgets가 답이겠더군요.
  2. 하는 김에 컴파일러도 MinGW에서 VC++로 변경했습니다. 그동안에는 Windows와 Linux 사이에서 컴파일러가 일관적으로 돌아가는걸 감안하느라 MinGW를 썼는데, 가끔 Windows API를 쓸 일이 생기면 꼭 MinGW에는 없는 헤더만 찾게 되더군요(-_-). VC++2017 자체도 많이 좋아진 듯 하고...... 컴파일러간 차이는 그냥 근성으로 극복해봐야 할 듯 합니다.
  3. Javascript: Web은 역시 Javascript가 native입죠(......). 일단 현재 프로젝트가 어느정도 정리되면 vue.js와 node.js(Express.js)를 중심으로 천천히 실무에 적용해볼 계획입니다.
  4. Kotlin: 맨날 desktop에서 놀다보니 모바일은 어떻게 가져가야 하는가 하는 문제가 남는데, Kotlin은 일단 Android에서는 native고(특히나 Google이 Oracle과의 소송에서 패한 뒤로는 더 화끈하게 밀어주고 있다는 느낌을 많이 받았습니다), Kotlin/Native가 완성되면 iOS도 네이티브로 개발이 가능해지는 만큼 꽤 괜찮겠다는 결론을 내렸습니다. 특히나 저처럼 앞으로 근 몇년간은 Apple쪽 생태계를 건드릴 일이 없지만 언제가 건드릴지도 모르는 경우에는 더 그렇고요.

원래는 여기에 Python과 Rust가 추가되어 있었습니다만, Python은 현재 엔지니어링을 진행중인 제품에서 쓰고 있긴 하지만 그렇게 깊게 들어갈 필요가 없고, Rust는 C++에서 약간만 조심하면 되는터라 당장 큰 문제는 되지 않겠다는 결론이 나서 일단은 버리기로 했습니다. 그 외에 Go도 후보선상에 살짝 올라와 있었지만 언어 구조가 영 제 취향이 아니라 포기했고......

오랜만에 잡생각을 정리할 겸 해서 올려봤습니다. 지금은 하던 일 잘 마무리하고 Javascript 공부에 할애할 시간을 확보했으면 좋겠네요.

PostgreSQL vs. SQLite: read & write in multithreaded environment

The start was humble. I needed to cache some data, and I thought just push them to database table and give index, and the rest will be datab...

Popular in Code{nested}