Download as pdf or txt
Download as pdf or txt
You are on page 1of 63

Asynchronous Programming in Rust

1st Edition Carl Fredrik Samson


Visit to download the full and correct content document:
https://textbookfull.com/product/asynchronous-programming-in-rust-1st-edition-carl-fr
edrik-samson/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Asynchronous Programming in Rust 1 / converted Edition


Carl Fredrik Samson

https://textbookfull.com/product/asynchronous-programming-in-
rust-1-converted-edition-carl-fredrik-samson/

Asynchronous Programming in Rust: Learn asynchronous


programming by building working examples of futures,
green threads, and runtimes 1st Edition Carl Fredrik
Samson
https://textbookfull.com/product/asynchronous-programming-in-
rust-learn-asynchronous-programming-by-building-working-examples-
of-futures-green-threads-and-runtimes-1st-edition-carl-fredrik-
samson/

Programming Rust 1st Edition Jim Blandy

https://textbookfull.com/product/programming-rust-1st-edition-
jim-blandy/

Asynchronous Android Programming Helder Vasconcelos

https://textbookfull.com/product/asynchronous-android-
programming-helder-vasconcelos/
The Rust Programming Language Covers Rust 2018 Steve
Klabnik

https://textbookfull.com/product/the-rust-programming-language-
covers-rust-2018-steve-klabnik/

Hands On Functional Programming in Rust 1st Edition


Andrew Johnson

https://textbookfull.com/product/hands-on-functional-programming-
in-rust-1st-edition-andrew-johnson/

The Rust Programming Language 1st Edition Steve Klabnik

https://textbookfull.com/product/the-rust-programming-
language-1st-edition-steve-klabnik/

Programming WebAssembly with Rust 1st Edition Kevin


Hoffman

https://textbookfull.com/product/programming-webassembly-with-
rust-1st-edition-kevin-hoffman/

Network Programming With Rust 1st Edition Abhishek


Chanda

https://textbookfull.com/product/network-programming-with-
rust-1st-edition-abhishek-chanda/
Asynchronous Programming
in Rust

Learn asynchronous programming by building working


examples of futures, green threads, and runtimes

Carl Fredrik Samson


Asynchronous Programming in Rust
Copyright © 2024 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case
of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express
or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable
for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and
products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.

Publishing Product Manager: Samriddhi Murarka


Group Product Manager: Kunal Sawant
Senior Editor: Kinnari Chohan
Technical Editor: Rajdeep Chakraborty
Copy Editor: Safis Editing
Project Coordinator: Manisha Singh
Indexer: Rekha Nair
Production Designer: Joshua Misquitta
Marketing DevRel Coordinator: Sonia Chauhan

First published: February 2024


Production reference: 1120124

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-80512-813-7
www.packtpub.com
To my family—my brother, my parents, and especially my beloved wife and fantastic children that
make every day an absolute joy.

– Carl Fredrik Samson


Contributors

About the author


Carl Fredrik Samson is a popular technology writer and has been active in the Rust community since
2018. He has an MSc in Business Administration where he specialized in strategy and finance. When
not writing, he’s a father of two children and a CEO of a company with 300 employees. He’s been
interested in different kinds of technologies his whole life and his programming experience ranges
from programming against old IBM mainframes to modern cloud computing, using everything from
assembly to Visual Basic for Applications. He has contributed to several open source projects including
the official documentation for asynchronous Rust.
I want to thank the Rust community for being so constructive, positive and welcoming. This book would
not have happened had it not been for all the positive and insightful interaction with the community.
A special thanks goes to the implementors of all the libraries that underpins the async ecosystem today
like mio, Tokio, and async-std.
I also want to thank my editor, Kinnari, who has been extraordinarily patient and helpful and during
the process of writing this book.
About the reviewer
Evgeni Pirianov is an experienced Senior Software Engineer with a deep expertise in Backend
Technologies, Web3 an Blockchain. Evgeni has graduated with a degree in Engineering from Imperial
College, London and has worked for a few years developing non-linear solvers in C++ . Ever since, he
has been at the forefront of architecturing, designing, and implementing decentralized applications
in the fields of Defi and Metaverse. Evgeni’s passion for Rust is unsurpassed and he is a true believer
of its bright future and wide range of applications.

Yage Hu is a software engineer specializing in systems programming and computer architecture. He


has cut code in companies such as Uber, Amazon, and Meta and is currently conducting systems
research with WebAssembly and Rust. Yage and his wife have just welcomed their first child, Maxine.
Table of Contents

Prefacexiii

Part 1: Asynchronous Programming


Fundamentals
1
Concurrency and Asynchronous Programming:
a Detailed Overview 3
Technical requirements 4 The role of the operating system 13
An evolutionary journey of Concurrency from the operating system’s
multitasking4 perspective13
Non-preemptive multitasking 4 Teaming up with the operating system 14
Preemptive multitasking 5 Communicating with the operating system 14
Hyper-threading5 The CPU and the operating system 15
Multicore processors 6 Down the rabbit hole 16
Do you really write synchronous code? 6 How does the CPU prevent us from accessing
Concurrency versus parallelism 7 memory we’re not supposed to access? 17
But can’t we just change the page table in
The mental model I use 8
the CPU? 18
Let’s draw some parallels to process
economics9 Interrupts, firmware, and I/O 19
Concurrency and its relation to I/O 11 A simplified overview 19
What about threads provided by the Interrupts22
operating system? 12 Firmware22
Choosing the right reference frame 12
Asynchronous versus concurrent 12 Summary23
viii Table of Contents

2
How Programming Languages Model Asynchronous Program
Flow25
Definitions26 Fibers and green threads 33
Threads27 Each stack has a fixed space 34
Context switching 35
Threads provided by the operating
Scheduling35
system29
FFI36
Creating new threads takes time 29
Each thread has its own stack 29 Callback based approaches 37
Context switching 30 Coroutines: promises and futures 38
Scheduling30 Coroutines and async/await 39
The advantage of decoupling asynchronous
operations from OS threads 31 Summary41
Example31

3
Understanding OS-Backed Event Queues, System Calls, and
Cross-Platform Abstractions 43
Technical requirements 44 epoll, kqueue, and IOCP 49
Running the Linux examples 45 Cross-platform event queues 50
Why use an OS-backed event queue? 45 System calls, FFI, and cross-platform
Blocking I/O 46 abstractions51
Non-blocking I/O 46 The lowest level of abstraction 51
Event queuing via epoll/kqueue and IOCP 47 The next level of abstraction 55
The highest level of abstraction 61
Readiness-based event queues 47
Completion-based event queues 48 Summary61
Table of Contents ix

Part 2: Event Queues and Green Threads


4
Create Your Own Event Queue 65
Technical requirements 65 Level-triggered versus edge-triggered
events78
Design and introduction to epoll 66
Is all I/O blocking? 72 The Poll module 81
The ffi module 73 The main program 84
Bitflags and bitmasks 76 Summary93

5
Creating Our Own Fibers 95
Technical requirements 96 Running our example 107
How to use the repository alongside The stack 109
the book 96 What does the stack look like? 109
Background information 97 Stack sizes 111
Instruction sets, hardware architectures, and
ABIs97
Implementing our own fibers 112
The System V ABI for x86-64 99 Implementing the runtime 115
A quick introduction to Assembly language 102 Guard, skip, and switch functions 121

An example we can build upon 103 Finishing thoughts 125


Setting up our project 103 Summary126
An introduction to Rust inline assembly
macro105

Part 3: Futures and async/await in Rust


6
Futures in Rust 129
What is a future? 130 Non-leaf futures 130
Leaf futures 130 A mental model of an async
runtime131
x Table of Contents

What the Rust language and standard I/O vs CPU-intensive tasks 134
library take care of 133 Summary135

7
Coroutines and async/await 137
Technical requirements 137 async/await154
Introduction to stackless coroutine/wait155
coroutines138 corofy—the coroutine preprocessor 155
An example of hand-written b-async-await—an example of a coroutine/
coroutines139 wait transformation 156

Futures module 141 c-async-await—concurrent


HTTP module 142 futures160
Do all futures have to be lazy? 146 Final thoughts 165
Creating coroutines 147
Summary166

8
Runtimes, Wakers, and the Reactor-Executor Pattern 167
Technical requirements 168 Changing the Future definition 191
Introduction to runtimes and Step 2 – Implementing a proper
why we need them 169 Executor192
Reactors and executors 170 Step 3 – Implementing a proper
Improving our base example 171 Reactor199
Design173 Experimenting with our new
Changing the current implementation 177 runtime208
An example using concurrency 208
Creating a proper runtime 184
Running multiple futures concurrently and in
Step 1 – Improving our runtime parallel209
design by adding a Reactor and a
Waker187 Summary211
Creating a Waker 188
Table of Contents xi

9
Coroutines, Self-Referential Structs, and Pinning 213
Technical requirements 214 Pinning in theory 234
Improving our example Definitions234
1 – variables 214 Pinning to the heap 235
Setting up the base example 215 Pinning to the stack 237
Improving our base example 217 Pin projections and structural
pinning240
Improving our example
2 – references 222 Improving our example
4 – pinning to the rescue 241
Improving our example 3 – this
future.rs242
is… not… good… 227
http.rs242
Discovering self-referential Main.rs244
structs229 executor.rs246
What is a move? 231
Summary248
Pinning in Rust 233

10
Creating Your Own Runtime 251
Technical requirements 251 Explicit versus implicit reactor
Setting up our example 253 instantiation265
main.rs253 Ergonomics versus efficiency and
flexibility266
future.rs254
Common traits that everyone agrees
http.rs254
about267
executor.rs256
Async drop 268
reactor.rs259
The future of asynchronous Rust 269
Experimenting with our runtime 261
Summary269
Challenges with asynchronous
Rust265 Epilogue272

Index275

Other Books You May Enjoy 282


Preface
The content in this book was initially written as a series of shorter books for programmers wanting
to learn asynchronous programming from the ground up using Rust. I found the existing material
I came upon at the time to be in equal parts frustrating, enlightening, and confusing, so I wanted to
do something about that.
Those shorter books became popular, so when I got the chance to write everything a second time,
improve the parts that I was happy with, and completely rewrite everything else and put it in a single,
coherent book, I just had to do it. The result is right in front of you.
People start programming for a variety of different reasons. Scientists start programming to model
problems and perform calculations. Business experts create programs that solve specific problems that
help their businesses. Some people start programming as a hobby or in their spare time. Common to
these programmers is that they learn programming from the top down.
Most of the time, this is perfectly fine, but on the topic of asynchronous programming in general, and
Rust in particular, there is a clear advantage to learning about the topic from first principles, and this
book aims to provide a means to do just that.
Asynchronous programming is a way to write programs where you divide your program into tasks
that can be stopped and resumed at specific points. This, in turn, allows a language runtime, or a
library, to drive and schedule these tasks so their progress interleaves.
Asynchronous programming will, by its very nature, affect the entire program flow, and it’s very
invasive. It rewrites, reorders, and schedules the program you write in a way that’s not always obvious
to you as a programmer.
Most programming languages try to make asynchronous programming so easy that you don’t really
have to understand how it works just to be productive in it.
You can get quite productive writing asynchronous Rust without really knowing how it works as
well, but Rust is more explicit and surfaces more complexity to the programmer than most other
languages. You will have a much easier time handling this complexity if you get a deep understanding
of asynchronous programming in general and what really happens when you write asynchronous Rust.
Another huge upside is that learning from first principles results in knowledge that is applicable
way beyond Rust, and it will, in turn, make it easier to pick up asynchronous programming in other
languages as well. I would even go so far as to say that most of this knowledge will be useful even in
your day-to-day programming. At least, that’s how it’s been for me.
xiv Preface

I want this book to feel like you’re joining me on a journey, where we build our knowledge topic by
topic and learn by creating examples and experiments along the way. I don’t want this book to feel
like a lecturer simply telling you how everything works.
This book is created for people who are curious by nature, the kind of programmers who want to
understand the systems they use, and who like creating small and big experiments as a way to explore
and learn.

Who this book is for


This book is for developers with some prior programming experience who want to learn
asynchronous programming from the ground up so they can be proficient in async Rust and
be able to participate in technical discussions on the subject. The book is perfect for those
who like writing working examples they can pick apart, expand, and experiment with.

There are two kinds of personas that I feel this book is especially relevant to:

• Developers coming from higher-level languages with a garbage collector, interpreter, or runtime,
such as C#, Java, JavaScript, Python, Ruby, Swift, or Go. Programmers who have extensive
experience with asynchronous programming in any of these languages but want to learn it
from the ground up and programmers with no experience with asynchronous programming
should both find this book equally useful.
• Developers with experience in languages such as C or C++ that have limited experience with
asynchronous programming.

What this book covers


Chapter 1, Concurrency and Asynchronous Programming: A Detailed Overview, provides a short history
leading up to the type of asynchronous programming we use today. We give several important definitions
and provide a mental model that explains what kind of problems asynchronous programming really
solves, and how concurrency differs from parallelism. We also cover the importance of choosing the
correct reference frame when discussing asynchronous program flow, and we go through several
important and fundamental concepts about CPUs, operating systems, hardware, interrupts, and I/O.
Chapter 2, How Programming Languages Model Asynchronous Program Flow, narrows the scope from
the previous chapter and focuses on the different ways programming languages deal with asynchronous
programming. It starts by giving several important definitions before explaining stackful and stackless
coroutines, OS threads, green threads, fibers, callbacks, promises, futures, and async/await.
Chapter 3, Understanding OS-Backed Event Queues, System Calls, and Cross-Platform Abstractions,
explains what epoll, kqueue, and IOCP are and how they differ. It prepares us for the next chapters
by giving an introduction to syscalls, FFI, and cross-platform abstractions.
Preface xv

Chapter 4, Create Your Own Event Queue, is the chapter where you create your own event queue that
mimics the API of mio (the popular Rust library that underpins much of the current async ecosystem).
The example will center around epoll and go into quite a bit of detail on how it works.
Chapter 5, Creating Our Own Fibers, walks through an example where we create our own kind of
stackful coroutines called fibers. They’re the same kind of green threads that Go uses and show one
of the most widespread and popular alternatives to the type of abstraction Rust uses with futures and
async/await today. Rust used this kind of abstraction in its early days before it reached 1.0, so it’s also
a part of Rust’s history. This chapter will also cover quite a few general programming concepts, such
as stacks, assembly, Application Binary Interfaces (ABIs), and instruction set architecture (ISAs),
that are useful beyond the context of asynchronous programming as well.
Chapter 6, Futures in Rust, gives a short introduction and overview of futures, runtimes, and
asynchronous programming in Rust.
Chapter 7, Coroutines and async/await, is a chapter where you write your own coroutines that are
simplified versions of the ones created by async/await in Rust today. We’ll write a few of them by
hand and introduce a new syntax that allows us to programmatically rewrite what look like regular
functions into the coroutines we wrote by hand.
Chapter 8, Runtimes, Wakers, and the Reactor-Executor Pattern, introduces runtimes and runtime
design. By iterating on the example we created in Chapter 7, we’ll create a runtime for our coroutines
that we’ll gradually improve. We’ll also do some experiments with our runtime once it’s done to better
understand how it works.
Chapter 9, Coroutines, Self-Referential Structs, and Pinning, is the chapter where we introduce self-
referential structs and pinning in Rust. By improving our coroutines further, we’ll experience first-hand
why we need something such as Pin, and how it helps us solve the problems we encounter.
Chapter 10, Create Your Own Runtime, is the chapter where we finally put all the pieces together. We’ll
improve the same example from the previous chapters further so we can run Rust futures, which will
allow us to use the full power of async/await and asynchronous Rust. We’ll also do a few experiments
that show some of the difficulties with asynchronous Rust and how we can best solve them.

To get the most out of this book


You should have some prior programming experience and, preferably, some knowledge about Rust.
Reading the free, and excellent, introductory book The Rust Programming Language (https://
doc.rust-lang.org/book/) should give you more than enough knowledge about Rust to
follow along since any advanced topics will be explained step by step.
xvi Preface

The ideal way to read this book is to have the book and a code editor open side by side. You should
also have the accompanying repository available so you can refer to that if you encounter any issues.

Software/hardware covered in the book Operating system requirements


Rust (version 1.51 or later) Windows, macOS, or Linux

You need Rust installed. If you haven’t already, follow the instructions here: https://www.rust-
lang.org/tools/install.
Some examples will require you to use Windows Subsystem for Linux (WSL) on Windows. If you’re
following along on a Windows machine, I recommend that you enable WSL (https://learn.
microsoft.com/en-us/windows/wsl/install) now and install Rust by following the
instructions for installing Rust on WSL here: https://www.rust-lang.org/tools/install.
If you are using the digital version of this book, we advise you to type the code yourself or access
the code from the book’s GitHub repository (a link is available in the next section). Doing so will
help you avoid any potential errors related to the copying and pasting of code.
The accompanying repository is organized in the following fashion:

• Code that belongs to a specific chapter is in that chapter’s folder (e.g., ch01).
• Each example is organized as a separate crate.
• The letters in front of the example names indicate in what order the different examples are
presented in the book. For example, the a-runtime example comes before the b-reactor-
executor example. This way, they will be ordered chronologically (at least by default on
most systems).
• Some examples have a version postfixed with -bonus. These versions will be mentioned in
the book text and often contain a specific variant of the example that might be interesting to
check out but is not important to the topic at hand.

Download the example code files


You can download the example code files for this book from GitHub at https://github.com/
PacktPublishing/Asynchronous-Programming-in-Rust. If there’s an update to the
code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://
github.com/PacktPublishing/. Check them out!
Preface xvii

Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file
extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “So, now
we have created our own async runtime that uses Rust’s Futures, Waker, Context, and async/
await.”
A block of code is set as follows:

pub trait Future {


    type Output;
    fn poll(&mut self) -> PollState<Self::Output>;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items
are set in bold:

struct Coroutine0 {
    stack: Stack0,
    state: State0,
}

Any command-line input or output is written as follows:

$ cargo run

Tips or important notes


Appear like this.

Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at customercare@
packtpub.com and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen.
If you have found a mistake in this book, we would be grateful if you would report this to us. Please
visit www.packtpub.com/support/errata and fill in the form.
xviii Preface

Piracy: If you come across any illegal copies of our works in any form on the internet, we would
be grateful if you would provide us with the location address or website name. Please contact us at
[email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you
are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share your thoughts


Once you’ve read Asynchronous Programming in Rust, we’d love to hear your thoughts! Please click
here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering
excellent quality content.
Preface xix

Download a free PDF copy of this book


Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere?
Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical
books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content
in your inbox daily
Follow these simple steps to get the benefits:

1. Scan the QR code or visit the link below

https://packt.link/free-ebook/9781805128137

2. Submit your proof of purchase


3. That’s it! We’ll send your free PDF and other benefits to your email directly
Part 1:
Asynchronous
Programming Fundamentals

In this part, you’ll receive a thorough introduction to concurrency and asynchronous programming.
We’ll also explore various techniques that programming languages employ to model asynchrony,
examining the most popular ones and covering some of the pros and cons associated with each. Finally,
we’ll explain the concept of OS-backed event queues, such as epoll, kqueue, and IOCP, detailing how
system calls are used to interact with the operating system and addressing the challenges encountered
in creating cross-platform abstractions like mio. This section comprises the following chapters:

• Chapter 1, Concurrency and Asynchronous Programming: A Detailed Overview


• Chapter 2, How Programming Languages Model Asynchronous Program Flow
• Chapter 3, Understanding OS-Backed Event Queues, System Calls and Cross Platform Abstractions
1
Concurrency and
Asynchronous Programming: a
Detailed Overview
Asynchronous programming is one of those topics many programmers find confusing. You come to
the point when you think you’ve got it, only to later realize that the rabbit hole is much deeper than
you thought. If you participate in discussions, listen to enough talks, and read about the topic on the
internet, you’ll probably also come across statements that seem to contradict each other. At least, this
describes how I felt when I first was introduced to the subject.
The cause of this confusion is often a lack of context, or authors assuming a specific context without
explicitly stating so, combined with terms surrounding concurrency and asynchronous programming
that are rather poorly defined.
In this chapter, we’ll be covering a lot of ground, and we’ll divide the content into the following
main topics:

• Async history
• Concurrency and parallelism
• The operating system and the CPU
• Interrupts, firmware, and I/O

This chapter is general in nature. It doesn’t specifically focus on Rust, or any specific programming
language for that matter, but it’s the kind of background information we need to go through so we
know that everyone is on the same page going forward. The upside is that this will be useful no matter
what programming language you use. In my eyes, that fact also makes this one of the most interesting
chapters in this book.
4 Concurrency and Asynchronous Programming: a Detailed Overview

There’s not a lot of code in this chapter, so we’re off to a soft start. It’s a good time to make a cup of
tea, relax, and get comfortable, as we’re about start this journey together.

Technical requirements
All examples will be written in Rust, and you have two alternatives for running the examples:

• Write and run the examples we’ll write on the Rust playground
• Install Rust on your machine and run the examples locally (recommended)

The ideal way to read this chapter is to clone the accompanying repository (https://github.
com/PacktPublishing/Asynchronous-Programming-in-Rust/tree/main/
ch01/a-assembly-dereference) and open the ch01 folder and keep it open while you read
the book. There, you’ll find all the examples we write in this chapter and even some extra information
that you might find interesting as well. You can of course also go back to the repository later if you
don’t have that accessible right now.

An evolutionary journey of multitasking


In the beginning, computers had one CPU that executed a set of instructions written by a programmer
one by one. No operating system (OS), no scheduling, no threads, no multitasking. This was how
computers worked for a long time. We’re talking back when a program was assembled in a deck of
punched cards, and you got in big trouble if you were so unfortunate that you dropped the deck onto
the floor.
There were operating systems being researched very early and when personal computing started to
grow in the 80s, operating systems such as DOS were the standard on most consumer PCs.
These operating systems usually yielded control of the entire CPU to the program currently executing,
and it was up to the programmer to make things work and implement any kind of multitasking for
their program. This worked fine, but as interactive UIs using a mouse and windowed operating systems
became the norm, this model simply couldn’t work anymore.

Non-preemptive multitasking
Non-preemptive multitasking was the first method used to be able to keep a UI interactive (and
running background processes).
This kind of multitasking put the responsibility of letting the OS run other tasks, such as responding
to input from the mouse or running a background task, in the hands of the programmer.
Typically, the programmer yielded control to the OS.
An evolutionary journey of multitasking 5

Besides offloading a huge responsibility to every programmer writing a program for your platform,
this method was naturally error-prone. A small mistake in a program’s code could halt or crash the
entire system.

Note
Another popular term for what we call non-preemptive multitasking is cooperative multitasking.
Windows 3.1 used cooperative multitasking and required programmers to yield control to
the OS by using specific system calls. One badly-behaving application could thereby halt the
entire system.

Preemptive multitasking
While non-preemptive multitasking sounded like a good idea, it turned out to create serious problems
as well. Letting every program and programmer out there be responsible for having a responsive UI
in an operating system can ultimately lead to a bad user experience, since every bug out there could
halt the entire system.
The solution was to place the responsibility of scheduling the CPU resources between the programs
that requested it (including the OS itself) in the hands of the OS. The OS can stop the execution of a
process, do something else, and switch back.
On such a system, if you write and run a program with a graphical user interface on a single-core
machine, the OS will stop your program to update the mouse position before it switches back to your
program to continue. This happens so frequently that we don’t usually observe any difference whether
the CPU has a lot of work or is idle.
The OS is responsible for scheduling tasks and does this by switching contexts on the CPU. This process
can happen many times each second, not only to keep the UI responsive but also to give some time
to other background tasks and IO events.
This is now the prevailing way to design an operating system.

Note
Later in this book, we’ll write our own green threads and cover a lot of basic knowledge about
context switching, threads, stacks, and scheduling that will give you more insight into this
topic, so stay tuned.

Hyper-threading
As CPUs evolved and added more functionality such as several arithmetic logic units (ALUs) and
additional logic units, the CPU manufacturers realized that the entire CPU wasn't fully utilized. For
6 Concurrency and Asynchronous Programming: a Detailed Overview

example, when an operation only required some parts of the CPU, an instruction could be run on the
ALU simultaneously. This became the start of hyper-threading.
Your computer today, for example, may have 6 cores and 12 logical cores.. This is exactly where hyper-
threading comes in. It “simulates” two cores on the same core by using unused parts of the CPU to
drive progress on thread 2 and simultaneously running the code on thread 1. It does this by using a
number of smart tricks (such as the one with the ALU).
Now, using hyper-threading, we could actually offload some work on one thread while keeping the
UI interactive by responding to events in the second thread even though we only had one CPU core,
thereby utilizing our hardware better.

You might wonder about the performance of hyper-threading


It turns out that hyper-threading has been continuously improved since the 90s. Since you’re
not actually running two CPUs, there will be some operations that need to wait for each other
to finish. The performance gain of hyper-threading compared to multitasking in a single core
seems to be somewhere close to 30% but it largely depends on the workload.

Multicore processors
As most know, the clock frequency of processors has been flat for a long time. Processors get faster by
improving caches, branch prediction, and speculative execution, and by working on the processing
pipelines of the processors, but the gains seem to be diminishing.
On the other hand, new processors are so small that they allow us to have many on the same chip. Now,
most CPUs have many cores and most often, each core will also have the ability to perform hyper-threading.

Do you really write synchronous code?


Like many things, this depends on your perspective. From the perspective of your process and the
code you write, everything will normally happen in the order you write it.
From the operating system’s perspective, it might or might not interrupt your code, pause it, and run
some other code in the meantime before resuming your process.
From the perspective of the CPU, it will mostly execute instructions one at a time.* It doesn’t care
who wrote the code, though, so when a hardware interrupt happens, it will immediately stop and
give control to an interrupt handler. This is how the CPU handles concurrency.
Concurrency versus parallelism 7

Note
*However, modern CPUs can also do a lot of things in parallel. Most CPUs are pipelined,
meaning that the next instruction is loaded while the current one is executing. It might have
a branch predictor that tries to figure out what instructions to load next.
The processor can also reorder instructions by using out-of-order execution if it believes it
makes things faster this way without ‘asking’ or ‘telling’ the programmer or the OS, so you
might not have any guarantee that A happens before B.
The CPU offloads some work to separate ‘coprocessors’ such as the FPU for floating-point
calculations, leaving the main CPU ready to do other tasks et cetera.
As a high-level overview, it’s OK to model the CPU as operating in a synchronous manner,
but for now, let’s just make a mental note that this is a model with some caveats that become
especially important when talking about parallelism, synchronization primitives (such as
mutexes and atomics), and the security of computers and operating systems.

Concurrency versus parallelism


Right off the bat, we’ll dive into this subject by defining what concurrency is. Since it is quite easy to
confuse concurrent with parallel, we will try to make a clear distinction between the two from the get-go.

Important
Concurrency is about dealing with a lot of things at the same time.
Parallelism is about doing a lot of things at the same time.

We call the concept of progressing multiple tasks at the same time multitasking. There are two ways to
multitask. One is by progressing tasks concurrently, but not at the same time. Another is to progress
tasks at the exact same time in parallel. Figure 1.1 depicts the difference between the two scenarios:
8 Concurrency and Asynchronous Programming: a Detailed Overview

Figure 1.1 – Multitasking two tasks

First, we need to agree on some definitions:

• Resource: This is something we need to be able to progress a task. Our resources are limited.
This could be CPU time or memory.
• Task: This is a set of operations that requires some kind of resource to progress. A task must
consist of several sub-operations.
• Parallel: This is something happening independently at the exact same time.
• Concurrent: These are tasks that are in progress at the same time, but not necessarily
progressing simultaneously.

This is an important distinction. If two tasks are running concurrently, but are not running in parallel,
they must be able to stop and resume their progress. We say that a task is interruptible if it allows for
this kind of concurrency.

The mental model I use


I firmly believe the main reason we find parallel and concurrent programming hard to differentiate
stems from how we model events in our everyday life. We tend to define these terms loosely, so our
intuition is often wrong.
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Through India and
Burmah with pen and brush
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Through India and Burmah with pen and brush

Author: A. Hugh Fisher

Release date: August 28, 2023 [eBook #71505]

Language: English

Original publication: London: T. Werner Laurie, 1911

Credits: Al Haines

*** START OF THE PROJECT GUTENBERG EBOOK THROUGH


INDIA AND BURMAH WITH PEN AND BRUSH ***
The Moat, Fort Dufferin, Mandalay.
THROUGH
INDIA AND BURMAH
WITH PEN AND BRUSH

BY

A. HUGH FISHER
"The beauty of the world is simple like a looking-glass."

LONDON
T. WERNER LAURIE
CLIFFORD'S INN

TO MY FRIENDS IN ENGLAND

PREFACE

The following series of "Travel Pictures" is an endeavour to embody


some of my impressions and experiences in India and Burmah.
For kind permission to reproduce among the illustrations eight of the
painted sketches I made for them, my thanks are due to the Visual
Instruction Committee of the Colonial Office who sent me out to the East as
their artist.

The two chapters "The Moharam Festival" and "Rakhykash" are


included in this book by the courtesy of the Editor of The Fortnightly
Review, in which publication they have already appeared.

A. HUGH FISHER.

CONTENTS

CHAP.

I. RANGOON
II. HIS HIGHNESS THE SAWBWA OF HSIPAW
III. UP THE IRRAWADDY TO BHAMO
IV. THE DEAD HEART OF A KINGDOM
V. MANDALAY
VI. SOUTHERN INDIA, THE LAND OF HINDOO TEMPLES
VII. CALCUTTA
VIII. MY FIRST SIGHT OF THE HIMALAYAS
IX. BENARES
X. LUCKNOW
XI. CAWNPORE
XII. THE HOUSE OF DREAM
XIII. DELHI
XIV. DEHRA DUN AND LANDOUR
XV. AN EVENING OF GOLD
XVI. "GUARD YOUR SHOES"
XVII. "A GATE OF EMPIRE"
XVIII. THE CAPITAL OF THE PUNJAB
XIX. AT THE COURT OF HIS HIGHNESS THE RAJAH OF NABHA
XX. IN SIGHT OF AFGHANISTAN
XXI. RAJPUTANA
XXII. SIR PRATAP SINGH
XXIII. THE MOHARAM FESTIVAL
XXIV. RAKHYKASH
XXV. POLITICAL
INDEX

ILLUSTRATIONS

THE MOAT, FORT DUFFERIN, MANDALAY ... Frontispiece


"THEY COULD NOT LIE DOWN WITHOUT OVERLAPPING"
MONGOLIAN TYPE OF MOHAMMEDAN
MUTAMA, A HINDOO BABY
HINDOO GIRL, SHOWING ELABORATE JEWELLERY
ALTAR TABLE AT A BUDDHIST SOCIETY'S CELEBRATION
BOY SHOWING TATOOING CUSTOMARY WITH ALL BURMESE
MALES
IN THE SHAN STATES: GUARD AND POLICEMAN
KATHA
AT A BURMESE PWE
BURMESE ACTORS AT BHAMO
A VILLAGE ON THE IRRAWADDY
BURMESE MURDERERS
PAGAN
BURMESE DWARF (3 ft. 5 in. high) SUFFERING FROM CATARACT
BURMESE PRIEST AND HIS BETEL Box
BURMESE MOTHER AND CHILD
THE SACRED TANK AND THE ROCK, TRICHINOPOLY
THE MAIN BAZAAR, TRICHINOPOLY
KARAPANASAMI, THE BLACK GOD
HINDOO MOTHER AND CHILD
BENGAL GOVERNMENT OFFICES, CALCUTTA
BENGALEE ACTRESS, MISS TIN CORRY DASS THE YOUNGER
"A CHARMING OLD GENTLEMAN FROM DELHI"
AVENUE OF OREODOXA PALMS, BOTANICAL GARDENS,
CALCUTTA
THE KUTAB MINAR AND THE IRON PILLAR, FATEHPUR SIKRI
THE FORT OF ALI MASJID, IN THE KHYBER PASS
HIS HIGHNESS THE RAJAH OF NABHA
THE PALACE OF THE MAHARAJAH OF UDAIPUR (DRYPOINT
ETCHING)
THE MOHARAM FESTIVAL AT AGRA

THROUGH INDIA AND BURMAH


CHAPTER I

RANGOON

Down came the rain, sudden, heavy and terrible, seeming to quell even
the sea's rage and whelming those defenceless hundreds of dark-skinned
voyagers in new and more dreadful misery.

Terrors were upon them, and in abject wretchedness and hopeless


struggle men, women and children spread every strip of their belongings
over their bodies and even used for shelter the very mats upon which they
had been lying.

What trouble a Hindoo will take to keep his body from the rain!
Extremely cleanly and fond of unlimited ablutions he yet detests nothing so
much as a wetting from the sky, and now, wholly at the mercy of the
elements, do what they would, no human ingenuity availed to keep these
wretched people dry.

It was the season of the rice harvest, when South India coolies swarm
over to Burmah much as the peasantry of Mayo and Connemara used to
crowd to England every summer.

If anybody is really anxious to remember that there are paddy fields in


Burmah he should cross the Bay of Bengal in December.

Somebody said that our ship was an unlucky one—that it ran down the
Mecca on her last trip and killed her third officer; but we got through safely
enough, though that crossing was one of the most disagreeable as well as the
most weird I ever made—disagreeable because of the bad weather, and
weird because of the passengers.

The deck and the lower deck were tanks of live humanity, and when it
began to get rough, as it did the morning after we left Madras, catching the
end of a strayed cyclone, it was worse than a Chinese puzzle to cross from
the saloon to the spar deck, and ten chances to one that even if you did
manage to avoid stepping on a body you slipped and shot into seven sick
Hindoo ladies and a family of children.

There were six first-class passengers, all Europeans, and 1700 deck
passengers, all Asiatics, and the latter paid twelve rupees each for the four
days' passage, bringing with them their own food.

"THEY COULD NOT LIE DOWN WITHOUT OVERLAPPING."


The first evening all six of the Europeans appeared at dinner—a
Trichinopoly collector, a Madras tanning manager and his wife (who told me
that half your American boots and shoes are made from buffalo skins
shipped from Madras to the United States), a young lieutenant going to take
charge of a mountain battery of Punjabis at Maimyo in Upper Burmah, and a
young Armenian, son of a merchant at Rangoon, who had been to Europe
about his eyes.

After coffee the man next to me suddenly leapt from his chair with a
yell. He thought he had been bitten by a centipede. The centipede was there
right enough, but as the pain passed off the next day we supposed the brute
had only fastened his legs in and had not really bitten.

The nights were sultry and the ship rolled worse every watch. I think,
however, that I never saw people try harder than those natives did to keep
clean. They had all brought new palm-leaf mats to lie upon, but they could
not lie down without overlapping. I asked the captain what he did about
scrubbing decks, and he said it was always done at the end of the voyage!
Next morning the downpour, already referred to, began and did the business
with cruel effectiveness.

As we neared Burmah the sea grew calm again and the rain abated. The
sun dried sick bodies and cheered despondent hearts. I spoke to a woman
crouching by some sacks and tin cans, with an old yellow cloth round her
head and shoulders, and another cloth swathing her loins. She had very dark
brown eyes, and her fingernails were bright red and also the palms of her
hands from the "maradelli" tied round the nails at night. She was the wife of
a man the other side of fourteen people, some four yards away. I asked his
name, not knowing that a Hindoo woman may not pronounce her husband's
name. She called him "Veetkar," which means uncle or houseman: the man
was of the Palla caste, which is just a little higher than the Pariah, and they
had been married five years but had no children. This was the man's second
marriage, his first wife having died of some liver complaint he said. Like
most of the passengers they were going out for paddy-field work, but unlike
so many others, they were "on their own" not being taken over by a labour
contractor. The man said he should get work at Kisshoor village, about eight
miles from Rangoon. Every year for seven years he had been over.
Altogether, this man had saved, according to his own statement, two
hundred rupees in the seven years' work, and had invested this in bullocks
and a little field near his village, which was named Verloocooli. He had left
the son of his first wife to look after the house and the field.

MONGOLIAN TYPE OF MOHAMMEDAN.


Under a thin muslin an ayah was watching our talk. She said she was a
Christian and came from Lazarus Church. Her husband ran away, leaving
her with three children in Madras, so she works now as an ayah to an
Eurasian lady, while her mother looks after the children in Madras.

About twenty people round one corner of the open hatch seemed to
belong to one another. They came from the Soutakar district and were
drinking rice-water—that is the water poured off when rice is boiled. A
Mohammedan with two sons was going to sell things. The boys would watch
the goods, he told me. He was returning to Upper Burmah, where he had
lived twenty-four years, and he had only been over to Madras to visit his
mother and father. He has "just a little shop" for the sale of such goods as
dal, chili, salt, onions, coconut oil, sweet oil, tamarind, matches and candles.

Then there was the Mongolian type of Mohammedan. He was very fat
and greasy, and had one of his dog teeth long like a tusk. He was a tin-
worker and made large cans in his shop in Rangoon.

I went down between decks and never saw people packed so closely
before except on Coronation Day. Even "marked" men discarded all clothing
but a small loin cloth: most of them could not move hand or foot without
their neighbours feeling the change of position; and as upon the deck above,
they often lay partly over each other. Yet in spite of the general
overcrowding, I noticed a woman of the Brahmin caste lying at her ease in a
small open space marked out by boxes and tin trunks. There was a large
lamp in a white reflector hanging by the companion-way, and some of those
lying nearest to it held leaf fans over their faces to keep the light from their
eyes.

The next day was brighter. There was a light wind and the whole sunlit
crowd was a babel of excited talk. A little naked Hindoo baby, just able to
walk, was playing mischievously with me. I had been nursing her for a while
and now she was laughing, and with palms up-turned was moving her hands
like a Nautch dancer as her eyes twinkled with merriment. She was called
Mutama, and the poor mite's ears had had a big cut made in them and the
lobes were already pulled out more than two inches by the bunches of metal
rings fastened in for this purpose.
A purple shawl, tied up to dry, bellied out in the wind over the side of the
ship in a patch of vivid colour. It had a border of gold thread and was of
native make. Not that the gold thread itself is made in Madras. It is curious
that English manufacturers have tried in vain to make these shawls so that
their gold thread shall not tarnish, whereas the gold thread obtained from
France does not do so.

On a box in the midst of hubbub, a Mohammedan was praying, bending


his body up and down and looking toward the sun.
MUTAMA, A HINDOO BABY.

The following morning we reached very turbid water, thick and yellow,
with blue reflections of the sky in the ripples. We could just see the coast of
Burmah and about noon caught sight of the pilot brig, and entering the wide
Rangoon river, passed a Chinese junk with all sails spread. Now the mats
began to go overboard and gulls swooped round the ship. We had passed the
obelisk at the mouth of the river when, above a green strip of coast on a little
blue hill, the sun shone upon something golden.
"The Pagoda!" I cried, and a pagoda it was, but only one at Siriam where
there is a garrison detachment. The Golden Pagoda—the Shwe Dagon—
appeared at first grey and more to the north. The water was now as thick and
muddy as the Thames at the Tower Bridge. It was full of undercurrents too,
and there was a poor chance for anyone who fell in.

Over went the mats, scores and scores and scores of them!

There is a bar a little further on called the Hastings, and it was a question
whether we'd get over it that afternoon. A line of yellow sand detached itself
from the green, and then the water became like shot silk, showing a pale
flood of cerulean slowly spreading over its turbid golden brown. On the low
bank were green bushes and undergrowth, and beyond—flat levels of tawny-
yellow and low tree-clad rising ground that reminded me of the Thames
above Godstow.

Beyond the green point of Siriam, just after the Pegu River branches off
to the right, the Rangoon River sweeps round in a great curve, at the far end
of which stretches the city. It was pale violet in the afternoon light, with
smoke streaming from vessels in the harbour, and on the highest point the
Shwe Dagon just showing on one edge that it was gold. Far to the right were
some twenty tall chimney-stacks of the Burmah Oil Works, but their colour,
instead of being sooty and unclean, was all blue and amethyst under a citron
sky.

The Customs Officer came out in a long boat, pulled by four men in red
turbans, and in his launch the medical officer of the port with a lady doctor.
There is a constant but ineffectual struggle to keep plague out of Burmah,
and every one of our 1700 deck passengers had to be thoroughly examined
—stripped to the waist with arms up, while the doctor passed his hands
down each side of the body.

The same night, on shore, I drove to the Shwe Dagon past the race-
ground, where a military tattoo was going on by torchlight.

Two gigantic leogryphs of plaster-faced brick stand one on each side of


the long series of steps which lead under carved teak roofs and between rows
of pillars up to the open flagged space on which the Pagoda stands.
I left the "tikka gharry" on the roadway and went up the steps of the
entrance alone. It was a weird experience, walking up those gloomy stairs at
night. Alone? At first it seemed so—the stalls at the sides of each landing or
wide level space between the flights of steps were deserted; but, as I walked
on, a Pariah dog came snarling viciously towards me and another joined him,
and then like jackals, their eyes glowing in the darkness, more and more of
them came. I had no stick with me, and as I meant going on it was a relief to
find that among the shadows of the pillars, to right and left, men were
sleeping. One stirred himself to call off the dogs and I walked up another
flight of steps, which gleamed a little beneath a hidden lamp.

Between great pillars, faced with plaster, red on the lower portion and
white above, I walked on while more dogs came yelping and snarling
angrily. I heard a low human wail which changed to a louder note and died
away—someone praying perhaps. Then all was quite still except for the
crickets. Now I was in a hall of larger columns and walked under a series of
carved screens—arches of wood set between pairs of them. Half-way up
these columns hung branches of strange temple offerings, things made in
coloured papers with gold sticks hanging from them.

At last I came out upon the upper platform on which stands the Pagoda
itself. Facing the top of the last flight of steps at the back of a large many-
pillared porch, reeking with the odour of burnt wax, I saw a cavernous
hollow, and set within it, behind lighted candles, dimly a golden Buddha in
the dusk. Outside, a strip of matting was laid over the flagged pavement all
round the platform, and in the stones little channels cut transversely for
drainage in the time of the rains lay in wait to trip careless feet.

Some years ago when the great "Hti" was brought down from the summit
of the Pagoda, after an earthquake, to be restored and further embellished,
people of all classes brought offerings of money and jewellery through the
turnstiles on to this platform. What a sight it must have been to see the lines
of Burmese people crowding up through these two turnstiles, one for silver
and one for gold—one woman giving two jewelled bracelets and the next a
bangle; a receipt would be given to each donor and then bangle and bracelets
thrown into the melting-pot after their jewels had been taken out for adding
to the "Hti."
HINDOO GIRL, SHOWING ELABORATE JEWELLERY.

Glittering metal drops quivered from the edges of richly-decorated


umbrellas; columns, covered as in a kind of mosaic with jewels and bright
glass, shone and sparkled; colossal figures cast grim shadows, and over all
the vast mass of the Shwe Dagon rose in its strange curved grandeur of worn
and faded gold far up into the night sky with a compelling loveliness, and
from the air above came floating down the sweet silvery tinkle of jewelled
bells shaken by the breeze.

Night had driven unscourged the money-changers from the temple, and
the magic light of the moon weaving silver threads through every garish tint
of paint had changed crude colours to ideal harmonies. Not colour alone but
form also was glorified. The grotesque had become dramatic, confusion had
changed to dignity, all surrounding detraction was subdued and the great
ascending curves of the Pagoda rose in simple, uncontested beauty. Nature
adored, acknowledging conquest, and the sound of those far wind-caught
bells was like that of the voices of angels and fairies singing about the cradle
of a child.

I had seen no building of such emotional appeal nor any that seems so
perfectly designed to wed the air and light that bathe it and caress it. But
imagine the Shwe Dagon transplanted to the cold light of some gargantuan
museum near the Cromwell Road; the nicest taste, the most steadfast
determination, could not unlock its charm. Here, upon easy hinge, the door
swings back at every raising of the eyes, and illumination is for all
beholders.

The following afternoon I was again at the Shwe Dagon, and to watch its
beauty under the glory of the setting sun was a further revelation. It seemed
to show fresh and delicate charm at each part of the day, and after burning at
sunset, like a man filled with impetuous passion, shone in the after-glow
with the diviner loveliness of the woman who gives her heart.

The river front of Rangoon is a wide, busy and dusty thoroughfare, on to


which wide streets open—Phayre Street, Bark Street and the rest, and great
piles of office buildings face the water—buildings with Corinthian porticoes
and columns with great drums like those of the Temple of Diana at Ephesus
without their sculptures. A line of white stucco houses curves round the bend
of the Sule Pagoda Street, wide and tree-bordered, like a road at Dorchester
or a Paris boulevard, making a handsome vista with its Pagoda surmounting
a flight of steps at the far end.

Building proceeds at such a rate that the big city seems to be growing
while you look at it, but there are plenty of open spaces. Government House,
in red brick and white stone, with an old bronze bell hung in front of the
portico between two brass cannon, stands in a goodly park with fine trees
and wide lawns and the Royal Lakes, across which there is a beautiful view
of the Shwe Dagon, are surrounded by large grounds with trim, well-kept
walks and drives. While I was painting by one of the lakes a water-snake
every now and then lifted its head above the surface, sometimes a foot and a
half out of the water like some long-necked bird.
I was driving back towards the hotel along the Calvert Road when I
noticed a temporary wood-framed structure, covered with coloured papers
and painted trellis-work. On inquiry I found it had been erected by a
Buddhist Society of that quarter of the city, and that the same night upon a
stage close to it in the open air a "Pwe" would be given, to which I was
bidden welcome about nine o'clock.

At my hotel two people had been poisoned by tinned food a few weeks
earlier, but whatever the table lacked in quality it made up in
pretentiousness. I quote that day's menu for comparison with the items of
another repast the same evening:—

Canapes aux anchois.


Potage à la Livonienne,
Barfurt—sauce Ravigotte.
Inlets mignons à la Parisienne.
Civets de lièvre à la St Hubert.
Cannetons faits aux petits pois—salade.
Fanchonettes au confiture.
Glace—crême au chocolat.
Dessert.
Café.

It was after an early and somewhat abridged version of the above that I
drove in the cheerless discomfort of a "tikka gharry" through Rangoon again
in the moonlight. After twenty minutes I saw once more the paper temple.
There were two long lines of lanterns high in the air in the shape of a
horizontal V, and under them a great crowd of people. The trellised temple
itself was also charmingly decorated with lanterns.
ALTAR TABLE AT A BUDDHIST SOCIETY'S CELEBRATION.

Inside I was effusively welcomed. A chair was placed for me on gay-


coloured carpets at one side of a raised altar platform, at the back of which
was a glass-fronted shrine containing an alabaster Buddha and strange lamps
in front, with two large kneeling figures and a pair of bronze birds. The
whole raised space before the shrine, some ten yards long by four yards
deep, was covered with white cloths, on which was placed close together a
multitude of dishes and plates of rich cakes, fruits and dainties. There were
green coconuts, piles of oranges, melons with patterns cut upon them,
leaving the outer green rind in curves and spirals, while the incised pattern
was stained with red and green pigment, and a mighty pumpkin with a kind
of "Christmas tree" planted in it, decked with packets of dried durian pickle
pinched in at a little distance from each end so that they looked like Tom
Smith's crackers. Now refreshment was brought to me in the shape of dried
prawns and, upon a large plate in neat little separate heaps, the following
delicacies:—

Green ginger, minced.


Sweet potatoes, shredded.
Fried coconut.
Sesamum seeds in oil.
Dried seed potatoes.
Tea leaves.
Fried ground nuts.

The president of this Buddhist Society, a stout Burman, with a rose-pink


silk kerchief rolled loosely round his head, came and bowed to me, raising
his hands and then sat upon another chair at my side, while a young Burman
stood behind to interpret our mutual felicitations.

Four silver dishes were now brought to me on a lacquered box, and these
contained Burmah cheroots, betel leaves and areca nut, tobacco leaves and
chunam (lime). Chilis were also brought, which made me long in vain for a
cool drink.

Outside, beyond the walls of pale green trellis, glowed the lanterns, and
faces peered at us between the strips of wood. Cloth of red and white stripes
lined the roof, and countless flags, quite tiny ones, were fastened along the
outer green railing.

In front of the Buddha had now been placed some beautiful gold
chalices. The white alabaster figure of Gautama was half as high as a man,
and a band covered with gems glittered across its breast.

The interpreter informed me that the whole gathering was a festival of


the Buddha Kaitsa Wut Society, and he added:—"We are the people in
Burmah always polite to everybody—do please whatever you like here." He
spoke English with assurance, but to me his meaning was not always clear.
Here are some of his actual words in answer to my request for further
information:—"In time long past the monies of the members were according
to the orders of the chief here, but they always used to pray every night with
white dress, not any sort of fancy dress. Whenever we pray in order yearly
we used to give charity to everybody."

About ten o'clock I moved outside, where another arm-chair had been
placed for me, this time in the midst of a great crowd of people.

In front of me rose a staging of bamboo framework, with seven oil lamps


hanging before it. Immediately below this staging a native orchestra played
strange instruments by candle-light and upon the ground, which sloped
conveniently, were ranged considerably over a thousand people. I counted
thirty-six rows of over twenty-five each, and ever-increasing crowds
thronged back and sides. Most of the seated audience were on mats or low
bedsteads, and many were smoking the large light-coloured cheroots.

My interpreter had now gone to join some ladies, and I was left to make
the best I could of this, my first, Burmese "Pwe."

Two characters were dancing on the stage when I took my seat. Perhaps
they were a prince and princess—at any rate they were dressed in old
Burmese court style, in very narrow skirts similar to the "hobble," and
strange short jackets cut with curled bases like horned moons stretched and
held in shape by bamboo frames. There was much swaying and posturing of
the body, combined with quick, jerky movements, the arms were moved a
great deal with bent elbows and the hands with fingers straight and the palms
bent back sharply at the wrists. When these dancers left the stage two men
entered in long white gowns, with broad white bands tied round the head in
big bows. They turned their backs upon the audience at first, and then
turning round squatted upon the floor. Two more similarly dressed came in
in the same manner, and after they had squatted beside the others two quite
astounding figures came on the scene with long bare swords.

The music all this while kept up an accompaniment of jingle and clapper
and tum, tum, tum—jingle and clapper and tum, tum, tum, with a
particularly squeaky wind instrument going ahead at the same time like a
cork being drawn backward and forward over a pane of wet glass.
I discovered now that on turning their backs to the audience on first
entering, the performers made obeisance to a draped bench at the back of the
stage. Two more sword-bearing figures came in and two lance-bearers in
very lovely bejewelled dresses of old gold. There was a long shrill speech
now—then a loud bang, at which all the actors fell to the ground, and a
figure entered bearing a short-pointed mace and sat at once on the draped
bench.

It was the beginning of a long drama of old Burmese court-life which


would go on all night long. The sword and lance-bearers went out, leaving
the gentleman with the mace talking to the four white-gowned men (they
were probably a king and his ministers), and he went on talking to them for a
long half-hour, during which, at rare intervals, one of them sat up and made
some remarks. At last a curtain came down, leaving two of the white-
gowned ones outside it. These were joined by a manifestly "comic"
character, a man with bare chest and a dark blue skirt, who kept the audience
in continual merriment while he was on the scene.

Every now and then I turned my head to look up at the great V-shaped
line of lanterns hanging high in the air overhead from tall bamboo poles, and
the stars shining over all from the night sky. A number of the children were
sleeping, though their elders made a good deal of noise, laughing heartily at
the comic actor as the play went on and on and on. I should like to have
stayed longer, but an appointment with some elephants at an early hour the
next morning made me reluctantly leave the "Pwe" at midnight and hunt
among the back rows of the audience for the driver of that "tikka gharry."

Everyone has heard of the Burmese elephants piling timber. The largest
of the timber companies employing elephants is the Bombay Burmah
Trading Corporation, Limited. The logs, floated down the river from forest-
lands, eight hundred or a thousand miles upstream, are stranded at high rain-
tides at Poozoondoung, a tract of lowland to which I drove in the early
morning.

I reached there just after sunrise, before the dew of the night was yet
evaporated, and the logs, on which one had to walk to avoid the mud, were
very slippery and more difficult to negotiate with boots than without.
The work of the elephants is to push, drag or pile the teak logs, and on
the morning of my visit there were three of the great quadrupeds at work:—
Hpo Chem, aged fifty, a fine tusker who had been twenty years at the work,
and two female elephants, Mee Cyan, seventy years of age, and Mee Poo,
thirty. The male elephant has, of course, tremendous strength in his tusks and
uses them for carrying, holding the log firmly with his trunk as he gravely
walks up the pile of logs to place his burden on the top. Female elephants
can only pile by a combined lift and drag, and do not raise the log entirely
from the ground. Pushing with the head is called "ounging."

Most of the elephants in use in Burmah have been got by Kheddah


operations, the Kheddah being a big stockade built under Government
direction in a similar way to the Kraals of Ceylon. At the last Kheddah many
elephants died suddenly of anthrax (some two hundred in about three days),
and a number of the trained animals were lost as well as those newly
captured.

The hours of elephant labour at Poozoondoung are strictly limited, being


from six to nine in the morning and from three to six in the afternoon.

At Poozoondoung, not far from the timber-yards, the chief rice-mills are
situated. They were idle now, but when I saw them again after the harvest
their big chimneys were belching forth black smoke from the burning husk.
The husk obtained from the milled grain is not only sufficient for all fuel
requirements, but much has to be shot into the creek for waste.

The engine staffs are, as upon most of the flotilla steamers,


Chittagonians, Burmese being employed chiefly as clerks.

Native boats called "Loungoes" brought such of the "paddy" from the
country as did not come by rail.

"Hulling" the rice is the operation of breaking off the husk. There were
rows of pairs of round flat stones, the under ones stationary, the upper ones
revolving, not grinding but merely breaking off the husk. Both grain and
husk fell from these stones together to the floor below, and were carried by
bucket-elevators to a fanning-room, where the husk was blown off. After
leaving the fans the grain had its remaining inner skin taken off in "cones"—
cement-faced stones made to press the grain against an outer jacket of
perforated wire. At the base of the cone a cloth hung round an opening in the
floor, through which the rice dropped, while the white skin fell upon the
floor outside to be called "bran," and shipped to Europe for use in the
manufacture of cattle cakes.

In the process of "whitening" much of the grain is broken and sorted by


graduated sieves, into four or five degrees of size. Finally the rice bags are
shipped on to a cargo boat in the creek, for despatch by steamer to India or
Europe.

When the rice-mills are in full work the smoke of their chimneys hangs
above Rangoon, but overhead every evening the flying foxes pass as usual,
and the beautiful Pagoda is far enough away to remain untarnished upon its
little hill.
BOY SHOWING TATOOING CUSTOMARY WITH ALL BURMESE
MALES.

CHAPTER II

HIS HIGHNESS THE SAWBWA OF HSIPAW

I left the Phayre Street station at Rangoon on a bright morning, which


made me think of England and the perfect beginning of a warm summer day
at home. The paddy-fields were like an ocean on each side of the railway
line, and as yellow as ripe corn: some distant hills, the Eastern Yomans
which divide Burmah from Siam, were faintly visible and became clearer
after I had passed Pegu. There are no elephants in those hills, though they
are yet in their thousands in the Western Yomans (one man I met had
counted sixty in a single herd).

Railway journeys with unshuttered windows are like miscellaneous


collections of snapshot photographs—now men in the paddy-fields wearing
the huge low conical bamboo hats of the Shan States; then big anthills and
snipe; a banyan tree—the gutta-percha banyan tree, Burmese Nynung, out of
which the natives make their birdlime; grey squares of flat hard mud, the
Burmese threshing floor; a crowd of brown hawks about a group of natives
drying fish; a small eagle with four-foot spread of wings, sometimes called a
peacock hawk, having blue eyes instead of the usual eagle yellow; an Eng
tree, a taxed tree largely used for building purposes (a tree that comes up and
is of no use is called here a Powk-pin); in a stream a man swinging a fishing-
net hung on crossed arched hoops at the end of a pole—a net of just the same
pattern I have seen on Arno shallows at Florence; a dull leaden-coloured
layer of rotting fish on bamboo screens raised above the ground on poles—
when rotted enough and full enough of insects, it will be pounded up to
make a national dish called "Ngape."

You might also like