ALL
GoLang Interview Questions
Below lists some frequently asked GoLang interview questions and their corresponding answers based on the author's experience. The list is updated frequently with new understandings. Stay tuned.What is the GMP model of GoLang?GoLang uses goroutine to achieve concurrency and it is famous for high concurrency support as the language defines its own goroutine dispatching and processing system which is well known as GMP model.How it works is that M is normally defined as the OS thread being spawned( then each M thread should be associated with a Process queue and each Process queue can have multip...
3 meanings of Stack
We may frequently see stack when we read programming books. But many times we may be confused about the different meanings of it. This term actually has three common meanings. Here we explain the three different meanings of Stack in programming.1. Data structureThe first meaning of Stack defines a method for storing data. Its feature is LIFO9Last In First Out). In this data structure, data are accumulated level by level. The data last put in is added at the top of the stack. When using the data, the top one is first popped out from the stack.There are usually some methods related to this data ...
3,227 1 STACK MEMORY DATA STRUCTURE
Server monitoring shell scripts
There are many open source server monitoring software such as cacti and nagios. Besides these, can we write our own shell scripts to monitor them? The shell scripts written by ourselves can fulfill our special requirements better and have a more detailed coverage.Below are some commonly used shell scripts used by Evangelist, an Oracle DBA. 1. Check network gateway traffic#!/bin/bash#network#Mike.Xuwhile : ; do time='date +%m"-"%d" "%k":"%M' day='date +%m"-"%d' rx_before='ifconfig eth0|sed -n "8"p|awk '{print $2}'|cut -c7-' tx_before='ifconfig eth0|sed -n "8"p|awk '{print $6...
46,768 2 SERVER MONITOR CPU MEMORY SHELL
malloc/free and new/delete in C++
malloc and free are C++/C language standard library functions, while new/delete are operator of C++. They can be used to allocate dynamic memory and free memory in C++ programs malloc/free can not meet the requirements of dynamic objects creation. Object needs to call the constructor to initialize the object when creating, the object needs to call the destructor before it is destroyed Since malloc() and free() are library functions rather than operators, the compiler has no control permissions on them, so it can not impose the task of object construction and destruction on malloc() and f...
In-memory key-value store in C, Go and Python
Subtitle: Wow Go’s net library is fastOn paternity leave for my second child, I found myself writing an in-memory hashmap (a poor-man’s memcached), in Go, Python and C. I was wondering how hard it would be to replace memcached, if we wanted to do something unusual with our key-value store. I also wanted to compare the languages, and, well, I get bored easily!The code is on github as Key-Value-Polyglot.Each version implements enough of the get and set commands from the memcached protocol that we can test them with a memcached client.If you write a version in a different language (...
Buffcacher
What should a ‘cache’ be? It means a lot of things, but to my mind the default programming type should be:“keep around expensive-to-generate bits of read-only data in case we need them again, or until the computer really needs that RAM for something elseâ€I was writing a custom video editing program in Python (interesting choice of language for that problem) and I wanted to cache decoded frames; but I just wasn’t happy with the memory management of explicit caches. It means making a decision about how much RAM to ring-fence for something without having g...
2,626 0 BUFFER CACHE WEB BROWSER MEMORY RAM
PHP's Output Buffering
While profiling our application I came across a a rather strange memory usage by the ob_start() function. We do use ob_start() quite a bit to defer output of data, which is a common thing in many applications. What was unusual is that 16 calls to ob_start() up chewing through almost 700kb of memory, given that the data being buffered rarely exceeds 1-2kb, this was quite unusual.I started looking at the C code of the ob_start() function and found this interesting bit of code inside php_start_ob_buffer()initial_size = 40*1024;block_size = 10*1024;Which directs PHP to pre-allocate 40kb of data fo...
4,220 0 PHP MEMORY OB_START() SOURCE 40KB
printf("goodbye, Dennis");
Dennis Ritchie, a father of modern computing, died on October 8th, aged 70EVERY time you tap an iSomething, you are touching a little piece of Steve Jobs. His singular vision shaped the products Apple has conjured up, especially over the last 14 years, after Jobs returned to the helm of the company he had founded. Jobs's death in October resembled the passing of a major religious figure. But all of his technological miracles, along with a billion others sold by Apple's competitors, would be merely pretty receptacles were it not for Dennis Ritchie. It is to him that they owe their digital souls...
3,056 0 MEMORY C DENNIS RITCHIE FATHER OF C