Lecture 01 · Introduction

المحاضرة 01 · مقدمة

Mapping tasks: RT = L1 + PT + L2, all-cloud and all-device

توزيع المهام (mapping): RT = L1 + PT + L2، كل شيء في السحابة وكل شيء على الجهاز

Slides 61–66 الشرائح 61–66 P1 MUST

The user waits for the whole trip, not just the computation. One addition and one percentage show why buying a faster cloud server barely helps a distant client.

المستخدم ينتظر الرحلة كاملة، لا الحساب وحده. عملية جمع واحدة ونسبة مئوية واحدة تُظهران لماذا لا يكاد شراء خادم سحابي أسرع يساعد عميلاً بعيداً.

What a mapping is

ما هو الـ mapping

An application is a pipeline of ordered tasks. The lecture's example is object detection on a photo: T1 image resize, T2 object detection, T3 drawing the bounding box. A mapping decides which layer of the E2C continuum runs each task. The pipeline says what must happen; the mapping says where. It is a design decision made by the architect, not a property of the app.

التطبيق عبارة عن pipeline من مهام مرتبة. مثال المحاضرة هو اكتشاف الأجسام في صورة: T1 تغيير حجم الصورة، وT2 اكتشاف الأجسام، وT3 رسم المربع المحيط (bounding box). وmapping يحدد أي طبقة من E2C continuum تشغّل كل مهمة. الـ pipeline يقول ماذا يجب أن يحدث، والـ mapping يقول أين. إنه قرار تصميمي يتخذه المعماري، لا خاصية في التطبيق.

Mapping #1: the whole pipeline in the cloud

Mapping #1: الـ pipeline كاملاً في السحابة

The server hosts the pipeline, and the server is in the cloud layer (slide 61). The request travels to the cloud (Latency 1), the server runs T1, T2 and T3 (Processing Time), and the result travels back (Latency 2).

الخادم يستضيف الـ pipeline، والخادم موجود في طبقة cloud (الشريحة 61). يسافر الطلب إلى cloud (Latency 1)، ويشغّل الخادم T1 وT2 وT3 (Processing Time)، ثم تعود النتيجة (Latency 2).

RT = L1 + PT + L2

زمن الاستجابة: RT = L1 + PT + L2.

Processing Time (PT) is the time the server takes to process T1, T2 and T3. Response Time (RT) is measured relative to the client: everything from sending the request to receiving the answer (slide 62).

Processing Time (PT) هو الزمن الذي يستغرقه الخادم لمعالجة T1 وT2 وT3. وResponse Time (RT) يُقاس من جهة العميل: كل شيء من إرسال الطلب حتى استلام الجواب (الشريحة 62).

NEW YORK CLIENT, CALIFORNIA CLOUD SERVER original server 2x server ∞ L1 70 PT 30 L2 70 170 L1 70 15 L2 70 155 L1 70 L2 70 140 the two orange network blocks never shrink, whatever the server does
Doubling server speed removes 15 ms out of 170. Even an infinitely fast server leaves 140 ms, all of it network.مضاعفة سرعة الخادم تزيل 15 ms من 170. وحتى خادم لا نهائي السرعة يترك 140 ms، كلها للشبكة.

The worked example (slide 63)

المثال المحلول (الشريحة 63)

Worked مثال محلول
client in New York, server in a California cloud data center

  Latency 1   NY to CA           70 ms
  PT          T1 + T2 + T3       30 ms
  Latency 2   CA to NY           70 ms

  RT = 70 + 30 + 70 = 170 ms

  computation share   30 / 170   = 0.176  = 17.6 %
  network share      140 / 170   = 0.824  = about 82 %

More than four fifths of what the user waits for is the network. The server's work is less than a fifth.

أكثر من أربعة أخماس ما ينتظره المستخدم هو الشبكة. وعمل الخادم أقل من الخُمس.

Make the server twice as fast

اجعل الخادم أسرع بمرتين

Worked مثال محلول
PT drops from 30 ms to 15 ms

  RT = 70 + 15 + 70 = 155 ms
  speedup = 170 / 155 = 1.097x        (about 9 % faster)

and with an infinitely fast server, PT = 0

  RT = 70 + 0 + 70 = 140 ms
  speedup ceiling = 170 / 140 = 1.21x

Twice the compute bought 9%. No amount of compute can ever buy more than 21%. The slide's conclusion: strong motivation for edge computing.

ضعف قدرة الحوسبة اشترى 9%. ولا يمكن لأي قدر من الحوسبة أن يشتري أكثر من 21%. خلاصة الشريحة: دافع قوي لـ edge computing.

The same answer with Amdahl's law

الجواب نفسه بـ Amdahl's law

Amdahl's law says that speeding up a fraction f of the work by a factor k gives an overall speedup of:

ينص Amdahl's law على أن تسريع جزء f من العمل بمعامل k يعطي تسريعاً كلياً قدره:

speedup = 1(1 − f) + f / k
Worked مثال محلول
f = 30 / 170 = 0.1765      (the part the server controls)
k = 2                      (server twice as fast)

  1 - f   = 0.8235
  f / k   = 0.0882
  sum     = 0.9118
  speedup = 1 / 0.9118 = 1.097x

as k grows without bound, f / k goes to 0:
  ceiling = 1 / (1 - f) = 1 / 0.8235 = 1.21x

Both routes agree. The 82% network share is the "serial part" that the faster server never touches.

الطريقتان متفقتان. نسبة الشبكة 82% هي "الجزء التسلسلي" الذي لا يمسه الخادم الأسرع أبداً.

Memory hook مفتاح للتذكر

"You cannot compute your way out of a distance problem." When L1 + L2 dominate RT, the answer is to shorten the distance (move work to the edge or fog), not to buy a faster server.

"You cannot compute your way out of a distance problem." أي: لا تستطيع حل مشكلة مسافة بالحوسبة. حين يهيمن L1 + L2 على RT، فالجواب هو تقصير المسافة (نقل العمل إلى edge أو fog)، لا شراء خادم أسرع.

Strengths and weaknesses of Mapping #1 (slide 64)

نقاط القوة والضعف في Mapping #1 (الشريحة 64)

Strengths

نقاط القوة

  • Centralized processing ensures consistency and reduces complexity for the client.

    المعالجة المركزية تضمن الاتساق وتقلّل التعقيد على العميل.

  • Easy to scale by adding more resources to the cloud.

    سهولة التوسع بإضافة موارد أكثر إلى cloud.

Weaknesses

نقاط الضعف

  • Latency becomes a bottleneck, especially for clients far from the server.

    يصبح زمن الانتقال عنق زجاجة، خاصة للعملاء البعيدين عن الخادم.

  • Not suitable for real-time applications like augmented reality or gaming, where milliseconds matter.

    غير مناسب لتطبيقات الزمن الحقيقي مثل الواقع المعزز (AR) أو الألعاب، حيث تهم كل ميلي ثانية.

Mapping #2: the whole pipeline on the device

Mapping #2: الـ pipeline كاملاً على الجهاز

The client hosts the pipeline: T1, T2 and T3 all run on the client side. Device layer only: no edge, fog or cloud (slide 65). With no network trip, L1 = L2 = 0, so:

العميل يستضيف الـ pipeline: T1 وT2 وT3 كلها تعمل على جهة العميل. طبقة الجهاز وحدها: لا edge ولا fog ولا cloud (الشريحة 65). وبلا رحلة شبكة، L1 = L2 = 0، إذن:

RT ≈ PTdevice

زمن الاستجابة: RT ≈ PTdevice.

That only looks ideal. The device has a small battery-powered chip, not a data center accelerator. T1 and T3 are cheap, but T2 (object detection) is heavy, so PT grows a lot. RT is a sum: if PT on the phone rises from 30 ms to, say, 400 ms, the total is worse than the 170 ms cloud round trip.

يبدو هذا مثالياً فقط. فالجهاز فيه شريحة صغيرة تعمل بالبطارية، لا مسرّع مركز بيانات. T1 وT3 رخيصتان، لكن T2 (اكتشاف الأجسام) ثقيلة، فيكبر PT كثيراً. وRT مجموع: فإذا ارتفع PT على الهاتف من 30 ms إلى 400 ms مثلاً، يصبح المجموع أسوأ من رحلة cloud البالغة 170 ms.

Impact on the client (slide 65)الأثر على العميل (الشريحة 65)BenefitالمكسبCostالتكلفة
NetworkالشبكةNo network dependency, works offlineلا اعتماد على الشبكة، ويعمل دون اتصال
PrivacyالخصوصيةData processed locally, reduced privacy concernsالبيانات تُعالج محلياً، فتقل مخاوف الخصوصية
ProcessingالمعالجةConsumes the device's processing power, limited by its hardwareيستهلك قدرة معالجة الجهاز، ومحدود بعتاده
BatteryالبطاريةConsumes the device's battery powerيستهلك طاقة بطارية الجهاز
User experienceتجربة المستخدمTrade-off: processing delay on weak hardwareمقايضة: تأخير المعالجة على عتاد ضعيف

الجدول: المكاسب: لا اعتماد على الشبكة ويعمل دون اتصال، والبيانات تُعالج محلياً فتقل مخاوف الخصوصية. والتكاليف: يستهلك قدرة معالجة الجهاز وهو محدود بعتاده، ويستهلك بطاريته، ويُضعف تجربة المستخدم بتأخير المعالجة على عتاد ضعيف.

Example: Edge AI on wearables (slide 66)

مثال: Edge AI على الأجهزة القابلة للارتداء (الشريحة 66)

A smartwatch detects running or cycling with an on-device AI model. It avoids sending data to the cloud (privacy), processes motion analysis locally, but is constrained by battery life and processing limits. This mapping is most effective for applications that need offline functionality and privacy, and is limited by the hardware of the client device.

ساعة ذكية تكتشف الجري أو ركوب الدراجة بنموذج ذكاء اصطناعي على الجهاز. تتجنب إرسال البيانات إلى cloud (خصوصية)، وتحلل الحركة محلياً، لكنها مقيّدة بعمر البطارية وحدود المعالجة. هذا الـ mapping هو الأنجع للتطبيقات التي تحتاج العمل دون اتصال والخصوصية، وهو محدود بعتاد جهاز العميل.

Practice computation

تمرين حسابي

A client has L1 = 40 ms, PT = 40 ms and L2 = 40 ms. (a) What is RT? (b) The server becomes twice as fast; what is the new RT and the speedup? (c) What is the best possible speedup from server upgrades alone?

عميل لديه L1 = 40 ms وPT = 40 ms وL2 = 40 ms. (أ) ما RT؟ (ب) صار الخادم أسرع بمرتين، فما RT الجديد والتسريع؟ (ج) ما أفضل تسريع ممكن من ترقية الخادم وحدها؟

Worked مثال محلول
(a)  RT = 40 + 40 + 40 = 120 ms
(b)  PT = 40 / 2 = 20 ms
     RT = 40 + 20 + 40 = 100 ms
     speedup = 120 / 100 = 1.2x
(c)  PT = 0:  RT = 40 + 0 + 40 = 80 ms
     ceiling = 120 / 80 = 1.5x

Amdahl check for (b): f = 40/120 = 1/3, k = 2
     1 / (2/3 + 1/6) = 1 / (5/6) = 1.2x

Compare with moving the server closer instead: if L1 and L2 fell to 10 ms each with the same 40 ms PT, RT = 10 + 40 + 10 = 60 ms, a 2× speedup that no server upgrade could reach.

قارن ذلك بتقريب الخادم بدلاً من تسريعه: لو انخفض L1 وL2 إلى 10 ms لكل منهما مع بقاء PT = 40 ms، يصبح RT = 10 + 40 + 10 = 60 ms، أي تسريع 2× لا تبلغه أي ترقية للخادم.

Exam traps فخاخ الامتحان

Halving PT does not halve RT. Only the PT term halves. 170 becomes 155, not 85. Always rebuild the full sum.

تنصيف PT لا ينصّف RT. الحد PT وحده ينتصف. 170 تصبح 155، لا 85. أعد بناء المجموع كاملاً دائماً.

The 70 ms is a teaching number. Measured ping between New York and San Francisco averages about 63 ms round trip, so roughly 31 ms one way. Use the exam's numbers, not real-world ones, unless asked.

70 ms رقم تعليمي. الـ ping المقاس بين نيويورك وسان فرانسيسكو متوسطه نحو 63 ms ذهاباً وإياباً، أي نحو 31 ms في اتجاه واحد. استخدم أرقام الامتحان لا أرقام الواقع، إلا إذا طُلب ذلك.

"How do we cut RT?" answer: shorten the distance, not "buy a faster server". The network terms are about 82% of RT.

جواب "كيف نقلّل RT؟": قصّر المسافة، لا "اشترِ خادماً أسرع". حدود الشبكة تمثّل نحو 82% من RT.

Zero latency is not automatically fastest. Mapping #2 removes L1 and L2, but a slow device can make PT larger than the whole cloud round trip.

انعدام زمن الانتقال لا يعني تلقائياً الأسرع. Mapping #2 يزيل L1 وL2، لكن جهازاً بطيئاً قد يجعل PT أكبر من رحلة cloud كاملة.

Everything on one card

كل شيء في بطاقة واحدة

Mapping cheat card

بطاقة مراجعة الـ mapping

Check yourself

اختبر نفسك

Latency 1 = 70 ms, PT = 30 ms, Latency 2 = 70 ms. What percentage of the response time is computation?

Latency 1 = 70 ms وPT = 30 ms وLatency 2 = 70 ms. ما نسبة الحوسبة من زمن الاستجابة؟

RT = 70 + 30 + 70 = 170 ms, and 30 / 170 = 17.6%. Option C divides by one latency only (30 / 70). Option D is the network share, 140 / 170. Option A treats 30 ms as a percentage.

RT = 70 + 30 + 70 = 170 ms، و30 / 170 = 17.6%. الخيار C يقسم على زمن انتقال واحد فقط (30 / 70). والخيار D هو حصة الشبكة 140 / 170. والخيار A يعامل 30 ms كنسبة مئوية.

In the same setup, the server is made twice as fast. What is the new response time?

في الإعداد نفسه، صار الخادم أسرع بمرتين. ما زمن الاستجابة الجديد؟

Only PT halves: 30 → 15 ms, so RT = 70 + 15 + 70 = 155 ms, a speedup of 170 / 155 ≈ 1.097×. Option A halves the whole RT, the classic trap. Option B is the infinitely fast server.

PT وحده ينتصف: 30 → 15 ms، إذن RT = 70 + 15 + 70 = 155 ms، بتسريع 170 / 155 ≈ 1.097×. الخيار A ينصّف RT كله، وهو الفخ الكلاسيكي. والخيار B هو الخادم ذو السرعة اللانهائية.

With L1 = 70, PT = 30 and L2 = 70 ms, what is the maximum speedup any server upgrade can give?

مع L1 = 70 وPT = 30 وL2 = 70 ms، ما أقصى تسريع يمكن أن تعطيه أي ترقية للخادم؟

With PT = 0 the RT is 140 ms, so the ceiling is 170 / 140 ≈ 1.21×. By Amdahl, 1 / (1 − f) with f = 30/170. Option D is 170 / 30, which wrongly assumes the network disappears too.

مع PT = 0 يصبح RT = 140 ms، فالسقف 170 / 140 ≈ 1.21×. وبـ Amdahl: 1 / (1 − f) مع f = 30/170. والخيار D هو 170 / 30، ويفترض خطأً أن الشبكة تختفي أيضاً.

L1 = PT = L2 = 40 ms, and the server becomes twice as fast. What is the new RT?

L1 = PT = L2 = 40 ms، وصار الخادم أسرع بمرتين. ما RT الجديد؟

40 + 20 + 40 = 100 ms (from 120 ms, a 1.2× speedup). Option A halves everything, option B drops PT entirely, and option C is the original RT.

40 + 20 + 40 = 100 ms (من 120 ms، تسريع 1.2×). الخيار A ينصّف كل شيء، والخيار B يحذف PT كلياً، والخيار C هو RT الأصلي.

A smartwatch runs the whole activity-detection pipeline on the watch (Mapping #2). Which is a cost of this design?

ساعة ذكية تشغّل pipeline اكتشاف النشاط كاملاً على الساعة (Mapping #2). أي مما يلي تكلفة لهذا التصميم؟

Slide 65: it consumes the device's processing power and battery power. In exchange it has no network dependency (so D is false), keeps data local for privacy (so C is false), and has no network trips at all (so A is false).

الشريحة 65: يستهلك قدرة معالجة الجهاز وطاقة بطاريته. وفي المقابل لا يعتمد على الشبكة (فالخيار D خاطئ)، ويبقي البيانات محلية للخصوصية (فالخيار C خاطئ)، ولا توجد رحلات شبكة أصلاً (فالخيار A خاطئ).