Skip to content

ASSIGNMENT 1 - ABDUL HANIF BIN ABDUL AZIZ U2101905#5

Open
Nipz652 wants to merge 5 commits intomainfrom
assignment1-AbdulHanif
Open

ASSIGNMENT 1 - ABDUL HANIF BIN ABDUL AZIZ U2101905#5
Nipz652 wants to merge 5 commits intomainfrom
assignment1-AbdulHanif

Conversation

@Nipz652
Copy link
Collaborator

@Nipz652 Nipz652 commented Dec 3, 2025

1. Addressed Issue

There is some issue that I have found during my exploration through the OpenHab bundles such as:

  • CPU and Disk I/O exhaustion caused by processing redundant events. (Resource Management Issues)

  • Unsafe access to shared memory resources (HashSet) which caused runtime crashes. (Resource Management Issues)

  • UI thread blocking caused by coarse-grained synchronization locks. (Synchronous, Blocking I/O)

  • Thread starvation caused by synchronous processing of high-frequency network packets. (Synchronous, Blocking I/O)

  • Sequential processing bottlenecks during "bursty" network traffic. (Synchronous, Blocking I/O)

  • Redundant thread locking (synchronized keyword) during slow hardware scanning. (Synchronous, Blocking I/O)

2. What I Have Reengineered

  • Implemented a Throttling Mechanism using a timestamp cache to drop duplicate events within a 2-second window.

  • Replaced blocking ArrayList with CopyOnWriteArrayList and removed synchronized blocks to allow non-blocking reads.

  • Implemented Asynchronous Batch Processing by decoupling event reception into a BlockingQueue.

  • Replaced non-thread-safe collections with ConcurrentHashMap.newKeySet() to ensure safe concurrent access.

  • Converted the remoteDeviceAdded callback to an Asynchronous Queue-based handler, moving logic to a background thread.

  • Removed the synchronized modifier from listener methods, relying on existing thread-safe collections.

3. Reengineering Strategy or Approach Used

For the approaches that I use, I have use rework strategy to overcome addressed issue and improvise the system performance. Strategy that I have use are:

  • Alteration. Altered the internal control flow to include conditional logic (throttling).

  • Concurrency Refactoring. Shifted the concurrency model from "Blocking" to "Non-Blocking".

  • Buffering. Introduced an intermediate buffer to manage data flow efficiency.

  • Thread Safety. Altered data structure implementation to support atomic operations.

  • Asynchronous Processing. Changed execution flow from synchronous to deferred/background execution.

  • Non-Blocking Concurrency. Removed redundant locking mechanisms to improve execution flow.

4. Impact of Changes

  • Reduced Resource Exhaustion. Prevented "Event Storms" from triggering excessive CPU processing and disk writes.

  • Improved UI Responsiveness. Allowed the Add-on Store to load instantly even while finders are updating in the background.

  • Prevented Thread Starvation. Ensured network bursts (device startups) are processed efficiently in chunks.

  • System Stability. Eliminated ConcurrentModificationException crashes during simultaneous read/write operations.

  • Decoupled Latency. Prevented network delays from freezing the main application logic.

  • Prevented Deadlocks. Ensured the OSGi service registry does not lock up during slow USB hardware scans.

@Nipz652 Nipz652 changed the title Assignment1 abdul hanif ASSIGNMENT 1 - ABDUL HANIF BIN ABDUL AZIZ U2101905 Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants